MessageHandler.c 815 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192
  1. #include "Module_OcppBackend20.h"
  2. #include "define.h"
  3. static char *APNAuthenticationEnumTypeStr[] = {
  4. MACROSTR(CHAP),
  5. MACROSTR(NONE),
  6. MACROSTR(PAP),
  7. MACROSTR(AUTO)
  8. };
  9. static char *AttributeEnumTypeStr[] = {
  10. MACROSTR(Actual),
  11. MACROSTR(Target),
  12. MACROSTR(MinSet),
  13. MACROSTR(MaxSet)
  14. };
  15. static char *AuthorizationStatusEnumTypeStr[] = {
  16. MACROSTR(Accepted),
  17. MACROSTR(Blocked),
  18. MACROSTR(ConcurrentTx),
  19. MACROSTR(Expired),
  20. MACROSTR(Invalid),
  21. MACROSTR(NoCredit),
  22. MACROSTR(NotAllowedTypeEVSE),
  23. MACROSTR(NotAtThisLocation),
  24. MACROSTR(NotAtThisTime),
  25. MACROSTR(Unknown)
  26. };
  27. #if 0
  28. static char *AuthorizeCertificateStatusEnumTypeStr[] = {
  29. MACROSTR(Accepted),
  30. MACROSTR(SignatureError),
  31. MACROSTR(CertificateExpired),
  32. MACROSTR(CertificateRevoked),
  33. MACROSTR(NoCertificateAvailable),
  34. MACROSTR(CertChainError),
  35. MACROSTR(ContractCancelled)
  36. };
  37. #endif
  38. static char *BootReasonEnumTypeStr[] = {
  39. MACROSTR(ApplicationReset),
  40. MACROSTR(FirmwareUpdate),
  41. MACROSTR(LocalReset),
  42. MACROSTR(PowerUp),
  43. MACROSTR(RemoteReset),
  44. MACROSTR(ScheduledReset),
  45. MACROSTR(Triggered),
  46. MACROSTR(Unknown),
  47. MACROSTR(Watchdog)
  48. };
  49. static char *CancelReservationStatusEnumTypeStr[] = {
  50. MACROSTR(Accepted),
  51. MACROSTR(Rejected)
  52. };
  53. static char *CertificateActionEnumTypeStr[] = {
  54. MACROSTR(Install),
  55. MACROSTR(Update)
  56. };
  57. static char *CertificateSignedStatusEnumTypeStr[] = {
  58. MACROSTR(Accepted),
  59. MACROSTR(Rejected)
  60. };
  61. static char *CertificateSigningUseEnumTypeStr[] = {
  62. MACROSTR(ChargingStationCertificate),
  63. MACROSTR(V2GCertificate)
  64. };
  65. static char *ChangeAvailabilityStatusEnumTypeStr[] = {
  66. MACROSTR(Accepted),
  67. MACROSTR(Rejected),
  68. MACROSTR(Scheduled)
  69. };
  70. #if 0
  71. static char *ChargingLimitSourceEnumTypeStr[] = {
  72. MACROSTR(EMS),
  73. MACROSTR(Other),
  74. MACROSTR(SO),
  75. MACROSTR(CSO)
  76. };
  77. #endif
  78. static char *ChargingProfileKindEnumTypeStr[] = {
  79. MACROSTR(Absolute),
  80. MACROSTR(Recurring),
  81. MACROSTR(Relative)
  82. };
  83. static char *ChargingProfilePurposeEnumTypeStr[] = {
  84. MACROSTR(ChargingStationExternalConstraints),
  85. MACROSTR(ChargingStationMaxProfile),
  86. MACROSTR(TxDefaultProfile),
  87. MACROSTR(TxProfile)
  88. };
  89. static char *ChargingProfileStatusEnumTypeStr[] = {
  90. MACROSTR(Accepted),
  91. MACROSTR(Rejected)
  92. };
  93. static char *ChargingRateUnitEnumTypeStr[] = {
  94. MACROSTR(W),
  95. MACROSTR(A)
  96. };
  97. static char *ChargingStateEnumTypeStr[] = {
  98. MACROSTR(Charging),
  99. MACROSTR(EVConnected),
  100. MACROSTR(SuspendedEV),
  101. MACROSTR(SuspendedEVSE),
  102. MACROSTR(Idle)
  103. };
  104. static char *ClearCacheStatusEnumTypeStr[] = {
  105. MACROSTR(Accepted),
  106. MACROSTR(Rejected)
  107. };
  108. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  109. MACROSTR(Accepted),
  110. MACROSTR(Unknown)
  111. };
  112. static char *ClearMessageStatusEnumTypeStr[] = {
  113. MACROSTR(Accepted),
  114. MACROSTR(Unknown)
  115. };
  116. static char *ClearMonitoringStatusEnumTypeStr[] = {
  117. MACROSTR(Accepted),
  118. MACROSTR(Rejected),
  119. MACROSTR(NotFound)
  120. };
  121. static char *ComponentCriterionEnumTypeStr[] = {
  122. MACROSTR(Active),
  123. MACROSTR(Available),
  124. MACROSTR(Enabled),
  125. MACROSTR(Problem)
  126. };
  127. #if 0
  128. static char *ConnectorEnumTypeStr[] = {
  129. MACROSTR(cCCS1),
  130. MACROSTR(cCCS2),
  131. MACROSTR(cG105),
  132. MACROSTR(cTesla),
  133. MACROSTR(cType1),
  134. MACROSTR(cType2),
  135. MACROSTR(s309-1P-16A),
  136. MACROSTR(s309-1P-32A),
  137. MACROSTR(s309-3P-16A),
  138. MACROSTR(s309-3P-32A),
  139. MACROSTR(sBS1361),
  140. MACROSTR(sCEE-7-7),
  141. MACROSTR(sType2),
  142. MACROSTR(sType3),
  143. MACROSTR(Other1PhMax16A),
  144. MACROSTR(Other1PhOver16A),
  145. MACROSTR(Other3Ph),
  146. MACROSTR(Pan),
  147. MACROSTR(wInductive),
  148. MACROSTR(wResonant),
  149. MACROSTR(Undetermined),
  150. MACROSTR(Unknown)
  151. };
  152. #endif
  153. static char *ConnectorStatusEnumTypeStr[] = {
  154. MACROSTR(Available),
  155. MACROSTR(Occupied),
  156. MACROSTR(Reserved),
  157. MACROSTR(Unavailable),
  158. MACROSTR(Faulted)
  159. };
  160. #if 0
  161. static char *CostKindEnumTypeStr[] = {
  162. MACROSTR(CarbonDioxideEmission),
  163. MACROSTR(RelativePricePercentage),
  164. MACROSTR(RenewableGenerationPercentage)
  165. };
  166. #endif
  167. static char *CustomerInformationStatusEnumTypeStr[] = {
  168. MACROSTR(Accepted),
  169. MACROSTR(Rejected),
  170. MACROSTR(Invalid)
  171. };
  172. static char *DataEnumTypeStr[] = {
  173. MACROSTR(string),
  174. MACROSTR(decimal),
  175. MACROSTR(integer),
  176. MACROSTR(dateTime),
  177. MACROSTR(boolean),
  178. MACROSTR(OptionList),
  179. MACROSTR(SequenceList),
  180. MACROSTR(MemberList)
  181. };
  182. static char *DataTransferStatusEnumTypeStr[] = {
  183. MACROSTR(Accepted),
  184. MACROSTR(Rejected),
  185. MACROSTR(UnknownMessageId),
  186. MACROSTR(UnknownVendorId)
  187. };
  188. static char *DeleteCertificateStatusEnumTypeStr[] = {
  189. MACROSTR(Accepted),
  190. MACROSTR(Failed),
  191. MACROSTR(NotFound)
  192. };
  193. static char *DisplayMessageStatusEnumTypeStr[] = {
  194. MACROSTR(Accepted),
  195. MACROSTR(NotSupportedMessageFormat),
  196. MACROSTR(Rejected),
  197. MACROSTR(NotSupportedPriority),
  198. MACROSTR(NotSupportedState),
  199. MACROSTR(UnknownTransaction)
  200. };
  201. #if 0
  202. static char *EnergyTransferModeEnumTypeStr[] = {
  203. MACROSTR(DC),
  204. MACROSTR(AC_single_phase),
  205. MACROSTR(AC_two_phase),
  206. MACROSTR(AC_three_phase)
  207. };
  208. #endif
  209. static char *EventNotificationEnumTypeStr[] = {
  210. MACROSTR(HardWiredNotification),
  211. MACROSTR(HardWiredMonitor),
  212. MACROSTR(PreconfiguredMonitor),
  213. MACROSTR(CustomMonitor)
  214. };
  215. static char *EventTriggerEnumTypeStr[] = {
  216. MACROSTR(Alerting),
  217. MACROSTR(Delta),
  218. MACROSTR(Periodic)
  219. };
  220. static char *FirmwareStatusEnumTypeStr[] = {
  221. MACROSTR(Downloaded),
  222. MACROSTR(DownloadFailed),
  223. MACROSTR(Downloading),
  224. MACROSTR(DownloadScheduled),
  225. MACROSTR(DownloadPaused),
  226. MACROSTR(Idle),
  227. MACROSTR(InstallationFailed),
  228. MACROSTR(Installing),
  229. MACROSTR(Installed),
  230. MACROSTR(InstallRebooting),
  231. MACROSTR(InstallScheduled),
  232. MACROSTR(InstallVerificationFailed),
  233. MACROSTR(InvalidSignature),
  234. MACROSTR(SignatureVerified)
  235. };
  236. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  237. MACROSTR(Accepted),
  238. MACROSTR(Rejected),
  239. MACROSTR(NotSupported),
  240. MACROSTR(EmptyResultSet)
  241. };
  242. static char *GenericStatusEnumTypeStr[] = {
  243. MACROSTR(Accepted),
  244. MACROSTR(Rejected)
  245. };
  246. static char *GetCertificateIdUseEnumTypeStr[] = {
  247. MACROSTR(V2GRootCertificate),
  248. MACROSTR(MORootCertificate),
  249. MACROSTR(CSMSRootCertificate),
  250. MACROSTR(V2GCertificateChain),
  251. MACROSTR(ManufacturerRootCertificate)
  252. };
  253. static char *GetCertificateStatusEnumTypeStr[] = {
  254. MACROSTR(Accepted),
  255. MACROSTR(Failed)
  256. };
  257. static char *GetChargingProfileStatusEnumTypeStr[] = {
  258. MACROSTR(Accepted),
  259. MACROSTR(NoProfiles)
  260. };
  261. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  262. MACROSTR(Accepted),
  263. MACROSTR(Unknown)
  264. };
  265. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  266. MACROSTR(Accepted),
  267. MACROSTR(NotFound)
  268. };
  269. static char *GetVariableStatusEnumTypeStr[] = {
  270. MACROSTR(Accepted),
  271. MACROSTR(Rejected),
  272. MACROSTR(UnknownComponent),
  273. MACROSTR(UnknownVariable),
  274. MACROSTR(NotSupportedAttributeType)
  275. };
  276. static char *HashAlgorithmEnumTypeStr[] = {
  277. MACROSTR(SHA256),
  278. MACROSTR(SHA384),
  279. MACROSTR(SHA512)
  280. };
  281. static char *IdTokenEnumTypeStr[] = {
  282. MACROSTR(Central),
  283. MACROSTR(eMAID),
  284. MACROSTR(ISO14443),
  285. MACROSTR(KeyCode),
  286. MACROSTR(Local),
  287. MACROSTR(NoAuthorization),
  288. MACROSTR(ISO15693)
  289. };
  290. static char *InstallCertificateUseEnumTypeStr[] = {
  291. MACROSTR(V2GRootCertificate),
  292. MACROSTR(MORootCertificate),
  293. MACROSTR(CSMSRootCertificate),
  294. MACROSTR(ManufacturerRootCertificate)
  295. };
  296. static char *InstallCertificateStatusEnumTypeStr[]={
  297. MACROSTR(Accepted),
  298. MACROSTR(Failed),
  299. MACROSTR(Rejected)
  300. };
  301. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  302. MACROSTR(Accepted),
  303. MACROSTR(Failed)
  304. };
  305. static char *LocationEnumTypeStr[] = {
  306. MACROSTR(Body),
  307. MACROSTR(Cable),
  308. MACROSTR(EV),
  309. MACROSTR(Inlet),
  310. MACROSTR(Outlet)
  311. };
  312. static char *LogEnumTypeStr[] = {
  313. MACROSTR(DiagnosticsLog),
  314. MACROSTR(SecurityLog)
  315. };
  316. static char *LogStatusEnumTypeStr[] = {
  317. MACROSTR(Accepted),
  318. MACROSTR(Rejected),
  319. MACROSTR(AcceptedCanceled)
  320. };
  321. static char *MeasurandEnumTypeStr[] = {
  322. MACROSTR(Current.Export),
  323. MACROSTR(Current.Import),
  324. MACROSTR(Current.Offered),
  325. MACROSTR(Energy.Active.Export.Register),
  326. MACROSTR(Energy.Active.Import.Register),
  327. MACROSTR(Energy.Reactive.Export.Register),
  328. MACROSTR(Energy.Reactive.Import.Register),
  329. MACROSTR(Energy.Active.Export.Interval),
  330. MACROSTR(Energy.Active.Import.Interval),
  331. MACROSTR(Energy.Active.Net),
  332. MACROSTR(Energy.Reactive.Export.Interval),
  333. MACROSTR(Energy.Reactive.Import.Interval),
  334. MACROSTR(Energy.Reactive.Net),
  335. MACROSTR(Energy.Apparent.Net),
  336. MACROSTR(Energy.Apparent.Import),
  337. MACROSTR(Energy.Apparent.Export),
  338. MACROSTR(Frequency),
  339. MACROSTR(Power.Active.Export),
  340. MACROSTR(Power.Active.Import),
  341. MACROSTR(Power.Factor),
  342. MACROSTR(Power.Offered),
  343. MACROSTR(Power.Reactive.Export),
  344. MACROSTR(Power.Reactive.Import),
  345. MACROSTR(SoC),
  346. MACROSTR(Voltage)
  347. };
  348. static char *MessageFormatEnumTypeStr[] = {
  349. MACROSTR(ASCII),
  350. MACROSTR(HTML),
  351. MACROSTR(URI),
  352. MACROSTR(UTF8)
  353. };
  354. static char *MessagePriorityEnumTypeStr[] = {
  355. MACROSTR(AlwaysFront),
  356. MACROSTR(InFront),
  357. MACROSTR(NormalCycle)
  358. };
  359. static char *MessageStateEnumTypeStr[] = {
  360. MACROSTR(Charging),
  361. MACROSTR(Faulted),
  362. MACROSTR(Idle),
  363. MACROSTR(Unavailable)
  364. };
  365. static char *MessageTriggerEnumTypeStr[] = {
  366. MACROSTR(BootNotification),
  367. MACROSTR(LogStatusNotification),
  368. MACROSTR(FirmwareStatusNotification),
  369. MACROSTR(Heartbeat),
  370. MACROSTR(MeterValues),
  371. MACROSTR(SignChargingStationCertificate),
  372. MACROSTR(SignV2GCertificate),
  373. MACROSTR(StatusNotification),
  374. MACROSTR(TransactionEvent),
  375. MACROSTR(SignCombinedCertificate),
  376. MACROSTR(PublishFirmwareStatusNotification)
  377. };
  378. static char *MonitorEnumTypeStr[] = {
  379. MACROSTR(UpperThreshold),
  380. MACROSTR(LowerThreshold),
  381. MACROSTR(Delta),
  382. MACROSTR(Periodic),
  383. MACROSTR(PeriodicClockAligned)
  384. };
  385. static char *MonitoringBaseEnumTypeStr[] = {
  386. MACROSTR(All),
  387. MACROSTR(FactoryDefault),
  388. MACROSTR(HardWiredOnly)
  389. };
  390. static char *MonitoringCriterionEnumTypeStr[] = {
  391. MACROSTR(ThresholdMonitoring),
  392. MACROSTR(DeltaMonitoring),
  393. MACROSTR(PeriodicMonitoring)
  394. };
  395. static char *MutabilityEnumTypeStr[] = {
  396. MACROSTR(ReadOnly),
  397. MACROSTR(WriteOnly),
  398. MACROSTR(ReadWrite)
  399. };
  400. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  401. MACROSTR(Accepted),
  402. MACROSTR(Rejected),
  403. MACROSTR(Processing)
  404. };
  405. static char *OCPPInterfaceEnumTypeStr[] = {
  406. MACROSTR(Wired0),
  407. MACROSTR(Wired1),
  408. MACROSTR(Wired2),
  409. MACROSTR(Wired3),
  410. MACROSTR(Wireless0),
  411. MACROSTR(Wireless1),
  412. MACROSTR(Wireless2),
  413. MACROSTR(Wireless3)
  414. };
  415. static char *OCPPTransportEnumTypeStr[] = {
  416. MACROSTR(JSON),
  417. MACROSTR(SOAP)
  418. };
  419. static char *OCPPVersionEnumTypeStr[] = {
  420. MACROSTR(OCPP12),
  421. MACROSTR(OCPP15),
  422. MACROSTR(OCPP16),
  423. MACROSTR(OCPP20)
  424. };
  425. static char *OperationalStatusEnumTypeStr[] = {
  426. MACROSTR(Inoperative),
  427. MACROSTR(Operative)
  428. };
  429. static char *PhaseEnumTypeStr[] = {
  430. MACROSTR(L1),
  431. MACROSTR(L2),
  432. MACROSTR(L3),
  433. MACROSTR(N),
  434. MACROSTR(L1-N),
  435. MACROSTR(L2-N),
  436. MACROSTR(L3-N),
  437. MACROSTR(L1-L2),
  438. MACROSTR(L2-L3),
  439. MACROSTR(L3-L1)
  440. };
  441. static char *PublishFirmwareStatusEnumTypeStr[] = {
  442. MACROSTR(Downloaded),
  443. MACROSTR(DownloadFailed),
  444. MACROSTR(Downloading),
  445. MACROSTR(DownloadScheduled),
  446. MACROSTR(DownloadPaused),
  447. MACROSTR(PublishFailed),
  448. MACROSTR(Published),
  449. MACROSTR(InvalidChecksum),
  450. MACROSTR(ChecksumVerified)
  451. };
  452. static char *ReadingContextEnumTypeStr[] = {
  453. MACROSTR(Interruption.Begin),
  454. MACROSTR(Interruption.End),
  455. MACROSTR(Other),
  456. MACROSTR(Sample.Clock),
  457. MACROSTR(Sample.Periodic),
  458. MACROSTR(Transaction.Begin),
  459. MACROSTR(Transaction.End),
  460. MACROSTR(Trigger)
  461. };
  462. #if 0
  463. static char *ReasonEnumTypeStr[] = {
  464. MACROSTR(DeAuthorized),
  465. MACROSTR(EmergencyStop),
  466. MACROSTR(EnergyLimitReached),
  467. MACROSTR(EVDisconnected),
  468. MACROSTR(GroundFault),
  469. MACROSTR(ImmediateReset),
  470. MACROSTR(Local),
  471. MACROSTR(LocalOutOfCredit),
  472. MACROSTR(MasterPass),
  473. MACROSTR(Other),
  474. MACROSTR(OvercurrentFault),
  475. MACROSTR(PowerLoss),
  476. MACROSTR(PowerQuality),
  477. MACROSTR(Reboot),
  478. MACROSTR(Remote),
  479. MACROSTR(SOCLimitReached),
  480. MACROSTR(StoppedByEV),
  481. MACROSTR(TimeLimitReached),
  482. MACROSTR(TimeLimitReached)
  483. };
  484. #endif
  485. static char *RecurrencyKindEnumTypeStr[] = {
  486. MACROSTR(Daily),
  487. MACROSTR(Weekly)
  488. };
  489. static char *RegistrationStatusEnumTypeStr[] = {
  490. MACROSTR(Accepted),
  491. MACROSTR(Pending),
  492. MACROSTR(Rejected)
  493. };
  494. static char *ReportBaseEnumTypeStr[] = {
  495. MACROSTR(ConfigurationInventory),
  496. MACROSTR(FullInventory),
  497. MACROSTR(SummaryInventory)
  498. };
  499. static char *RequestStartStopStatusEnumTypeStr[] = {
  500. MACROSTR(Accepted),
  501. MACROSTR(Rejected)
  502. };
  503. static char *ReservationUpdateStatusEnumTypeStr[] = {
  504. MACROSTR(Expired),
  505. MACROSTR(Removed)
  506. };
  507. static char *ReserveNowStatusEnumTypeStr[] = {
  508. MACROSTR(Accepted),
  509. MACROSTR(Faulted),
  510. MACROSTR(Occupied),
  511. MACROSTR(Rejected),
  512. MACROSTR(Unavailable)
  513. };
  514. static char *ResetEnumTypeStr[] = {
  515. MACROSTR(Immediate),
  516. MACROSTR(OnIdle)
  517. };
  518. static char *ResetStatusEnumTypeStr[] = {
  519. MACROSTR(Accepted),
  520. MACROSTR(Rejected),
  521. MACROSTR(Scheduled)
  522. };
  523. static char *SetMonitoringStatusEnumTypeStr[] = {
  524. MACROSTR(Accepted),
  525. MACROSTR(UnknownComponent),
  526. MACROSTR(UnknownVariable),
  527. MACROSTR(UnsupportedMonitorType),
  528. MACROSTR(Rejected),
  529. MACROSTR(OutOfRange),
  530. MACROSTR(Duplicate)
  531. };
  532. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  533. MACROSTR(Accepted),
  534. MACROSTR(Rejected),
  535. MACROSTR(Failed)
  536. };
  537. static char *SetVariableStatusEnumTypeStr[] = {
  538. MACROSTR(Accepted),
  539. MACROSTR(Rejected),
  540. MACROSTR(InvalidValue),
  541. MACROSTR(UnknownComponent),
  542. MACROSTR(UnknownVariable),
  543. MACROSTR(NotSupportedAttributeType),
  544. MACROSTR(OutOfRange),
  545. MACROSTR(RebootRequired)
  546. };
  547. static char *TransactionEventEnumTypeStr[] = {
  548. MACROSTR(Ended),
  549. MACROSTR(Started),
  550. MACROSTR(Updated)
  551. };
  552. static char *TriggerMessageStatusEnumTypeStr[] = {
  553. MACROSTR(Accepted),
  554. MACROSTR(Rejected),
  555. MACROSTR(NotImplemented)
  556. };
  557. static char *TriggerReasonEnumTypeStr[] = {
  558. MACROSTR(Authorized),
  559. MACROSTR(CablePluggedIn),
  560. MACROSTR(ChargingRateChanged),
  561. MACROSTR(ChargingStateChanged),
  562. MACROSTR(Deauthorized),
  563. MACROSTR(EnergyLimitReached),
  564. MACROSTR(EVCommunicationLost),
  565. MACROSTR(EVConnectTimeout),
  566. MACROSTR(MeterValueClock),
  567. MACROSTR(MeterValuePeriodic),
  568. MACROSTR(TimeLimitReached),
  569. MACROSTR(Trigger),
  570. MACROSTR(UnlockCommand),
  571. MACROSTR(StopAuthorized),
  572. MACROSTR(EVDeparted),
  573. MACROSTR(EVDetected),
  574. MACROSTR(RemoteStop),
  575. MACROSTR(RemoteStart),
  576. MACROSTR(AbnormalCondition),
  577. MACROSTR(SignedDataReceived),
  578. MACROSTR(ResetCommand)
  579. };
  580. static char *UnlockStatusEnumTypeStr[] = {
  581. MACROSTR(Unlocked),
  582. MACROSTR(UnlockFailed),
  583. MACROSTR(OngoingAuthorizedTransaction),
  584. MACROSTR(UnknownConnector)
  585. };
  586. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  587. MACROSTR(DownloadOngoing),
  588. MACROSTR(NoFirmware),
  589. MACROSTR(Unpublished)
  590. };
  591. static char *UpdateEnumTypeStr[] = {
  592. MACROSTR(Differential),
  593. MACROSTR(Full)
  594. };
  595. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  596. MACROSTR(Accepted),
  597. MACROSTR(Rejected),
  598. MACROSTR(AcceptedCanceled),
  599. MACROSTR(InvalidCertificate),
  600. MACROSTR(RevokedCertificate)
  601. };
  602. static char *UpdateStatusEnumTypeStr[] = {
  603. MACROSTR(Accepted),
  604. MACROSTR(Failed),
  605. MACROSTR(VersionMismatch)
  606. };
  607. static char *UploadLogStatusEnumTypeStr[] = {
  608. MACROSTR(BadMessage),
  609. MACROSTR(Idle),
  610. MACROSTR(NotSupportedOperation),
  611. MACROSTR(PermissionDenied),
  612. MACROSTR(Uploaded),
  613. MACROSTR(UploadFailure),
  614. MACROSTR(Uploading)
  615. };
  616. static char *VPNEnumTypeStr[] = {
  617. MACROSTR(IKEv2),
  618. MACROSTR(IPSec),
  619. MACROSTR(L2TP),
  620. MACROSTR(PPTP)
  621. };
  622. #if 0
  623. static char *ChargePointErrorCodeEnumTypeStr[] = {
  624. MACROSTR(ConnectorLockFailure),
  625. MACROSTR(EVCommunicationError),
  626. MACROSTR(GroundFailure),
  627. MACROSTR(HighTemperature),
  628. MACROSTR(InternalError),
  629. MACROSTR(LocalListConflict),
  630. MACROSTR(NoError),
  631. MACROSTR(OtherError),
  632. MACROSTR(OverCurrentFailure),
  633. MACROSTR(OverVoltage),
  634. MACROSTR(PowerMeterFailure),
  635. MACROSTR(PowerSwitchFailure),
  636. MACROSTR(ReaderFailure),
  637. MACROSTR(ResetFailure),
  638. MACROSTR(UnderVoltage),
  639. MACROSTR(WeakSignal)
  640. };
  641. #endif
  642. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  643. MACROSTR(Accepted),
  644. MACROSTR(Rejected)
  645. };
  646. static char *RemoteStartStopStatusEnumTypeStr[] = {
  647. MACROSTR(Accepted),
  648. MACROSTR(Rejected)
  649. };
  650. #if 0
  651. static char * StopTransactionReasonEnumTypeStr[] = {
  652. MACROSTR(EmergencyStop),
  653. MACROSTR(EVDisconnected),
  654. MACROSTR(HardReset),
  655. MACROSTR(Local),
  656. MACROSTR(Other),
  657. MACROSTR(PowerLoss),
  658. MACROSTR(Reboot),
  659. MACROSTR(Remote),
  660. MACROSTR(SoftReset),
  661. MACROSTR(UnlockCommand),
  662. MACROSTR(DeAuthorized)
  663. };
  664. #endif
  665. //ChargePointMaxProfile
  666. #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile_OCPP20.json"
  667. //TxDefaultProfile
  668. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  669. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  670. struct StatusCodeData *ShmStatusCodeData;
  671. struct PsuData *ShmPsuData ;
  672. struct OCPP20Data *ShmOCPP20Data;
  673. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  674. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  675. //===============================
  676. // Gun Total Numbers
  677. //===============================
  678. static int gunTotalNumber = 0;
  679. static uint8_t gunType[4] = {0};
  680. //===============================
  681. // Local List Version
  682. //===============================
  683. static int localversion=0;
  684. //===============================
  685. // OCPP sign variable
  686. //===============================
  687. static int server_sign = FALSE;
  688. int server_pending = FALSE;
  689. static int BootNotificationInterval = 10;
  690. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  691. //===============================
  692. // OCPP auth variable
  693. //===============================
  694. static int authorizeRetryTimes = 0; //number of Retry times
  695. //===============================
  696. // OCPP other variables
  697. //===============================
  698. static int HeartBeatWaitTime = 10;
  699. static int FirstHeartBeat = 0;
  700. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  701. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  702. static char CurrentChargingProfileScheduleStr[30] = {0};
  703. //========================================
  704. // OCPP status/previous related variables
  705. //========================================
  706. static int GunStatusInterval = 10;
  707. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  708. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  709. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  710. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  711. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  712. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  713. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  714. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  715. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  716. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  717. static int TransactionMessageAttemptsValue = 0;
  718. static int TransactionMessageRetryIntervalValue = 0;
  719. static struct AuthorizationData idTagQuery;
  720. //=============================================
  721. // OCPP HeartBeat Response Not Receive Counts
  722. //============================================
  723. static int HeartBeatWithNOResponse = 0;
  724. static int HeartBeatCountPerHour = 0;
  725. sqlite3 *db;
  726. int TransactionMessageAttemptsGet(void);
  727. int TransactionMessageRetryIntervalGet(void);
  728. int GetOcppConnStatus(void);
  729. void SetOcppConnStatus(uint8_t status);
  730. int setKeyValue(char *key, char *value);
  731. void OCPP_get_TableAuthlocalAllData(void);
  732. void processUnkownKey(void);
  733. struct StructOCPPMeterValue
  734. {
  735. unsigned char TimeStamp[28];
  736. struct StructSampledValue SampledValue[10];
  737. };
  738. struct ClientTime
  739. {
  740. unsigned int Heartbeat;
  741. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  742. unsigned int StartTransaction;
  743. unsigned int StopTransaction;
  744. unsigned int MeterValues[CONNECTOR_QUANTITY];
  745. }clientTime;
  746. typedef union
  747. {
  748. //Operations Initiated by Central System
  749. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  750. struct
  751. {
  752. //CsMsgValue[0]
  753. unsigned char StatusNotificationReq:1; //bit 0,
  754. unsigned char StatusNotificationConf:1; //bit 1,
  755. unsigned char TriggerMeterValueReq:1; //bit 2,
  756. unsigned char TransactionEventReq:1; //bit 3,
  757. unsigned char SampleMeterReq:1; //bit 4,
  758. unsigned char ClockAlignMeterReq:1; //bit 5,
  759. unsigned char :2;
  760. }bits[CONNECTOR_QUANTITY];
  761. }CpinitiateMsg;
  762. CpinitiateMsg cpinitateMsg;
  763. //=========================================
  764. // Date time related function
  765. //=========================================
  766. void getNowDatetime(uint8_t *data)
  767. {
  768. time_t t = time(NULL);
  769. struct tm tm = *localtime(&t);
  770. 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);
  771. }
  772. //=========================================
  773. // Sqlite3 related function
  774. //=========================================
  775. int DB_Initial()
  776. {
  777. int result = PASS;
  778. char* errMsg = NULL;
  779. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  780. "idToken text UNIQUE,"
  781. "type text,"
  782. "status text,"
  783. "cacheExpiryDateTime text,"
  784. "chargingPriority integer,"
  785. "language1 text,"
  786. "evseId text,"
  787. "language2 text,"
  788. "groupIdToken_idToken text,"
  789. "groupIdToken_type text,"
  790. "personalMessage text);";
  791. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  792. "idToken text UNIQUE,"
  793. "type text,"
  794. "status text,"
  795. "cacheExpiryDateTime text,"
  796. "chargingPriority integer,"
  797. "language1 text,"
  798. "evseId text,"
  799. "language2 text,"
  800. "groupIdToken_idToken text,"
  801. "groupIdToken_type text,"
  802. "personalMessage text,"
  803. "version text);";
  804. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  805. "componentName text NOT NULL ,"
  806. "componentInstance text, "
  807. "variableName text NOT NULL, "
  808. "variableInstance text, "
  809. "variableCharacteristicsDataType integer, "
  810. "variableCharacteristicsUnit text, "
  811. "variableCharacteristicsMaxLimit real,"
  812. "variableAttributesType text, "
  813. "variableAttributesTypeMutability text, "
  814. "variableAttributesTypeValue text, "
  815. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  816. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  817. "type text);";
  818. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  819. "slot integer UNIQUE, connectionData text);";
  820. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  821. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  822. {
  823. result = FAIL;
  824. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  825. sqlite3_close(db);
  826. }
  827. else
  828. {
  829. DEBUG_INFO( "OCPP local database open successfully.\n");
  830. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  831. {
  832. result = FAIL;
  833. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  834. }
  835. else
  836. {
  837. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  838. }
  839. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  840. {
  841. result = FAIL;
  842. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  843. }
  844. else
  845. {
  846. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  847. }
  848. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  849. {
  850. result = FAIL;
  851. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  852. }
  853. else
  854. {
  855. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  856. }
  857. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  858. {
  859. result = FAIL;
  860. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  861. }
  862. else
  863. {
  864. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  865. }
  866. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  867. {
  868. result = FAIL;
  869. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  870. }
  871. else
  872. {
  873. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  874. }
  875. //sqlite3_close(db);
  876. }
  877. return result;
  878. }
  879. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  880. {
  881. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  882. return 0;
  883. }
  884. void DB_getListVerion()
  885. {
  886. char sql[256];
  887. char* errMsg = NULL;
  888. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  889. /* Execute SQL statement */
  890. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  891. {
  892. DEBUG_INFO("SQL error: %s", errMsg);
  893. }
  894. }
  895. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  896. {
  897. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  898. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  899. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  900. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  901. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  902. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  903. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  904. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  905. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  906. return 0;
  907. }
  908. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  909. {
  910. char sql[256];
  911. char* errMsg = NULL;
  912. memset(&idTagQuery, 0, sizeof(idTagQuery));
  913. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  914. if(isQueryFromCache)
  915. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  916. else
  917. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  918. /* Execute SQL statement */
  919. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  920. {
  921. DEBUG_INFO("SQL error: %s", errMsg);
  922. }
  923. }
  924. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  925. {
  926. for (int i = 0; i < columnCount; i++)
  927. {
  928. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  929. }
  930. return 0;
  931. }
  932. void DB_get_TableAuthlocalAllData(void)
  933. {
  934. char sql[256];
  935. char* errMsg = NULL;
  936. sprintf(sql,"select * from ocpp20_auth_local;");
  937. /* Execute SQL statement */
  938. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  939. {
  940. DEBUG_INFO("SQL error: %s", errMsg);
  941. }
  942. }
  943. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  944. {
  945. for(int i = 0; i<columnCount; i++)
  946. {
  947. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  948. }
  949. return 0;
  950. }
  951. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  952. {
  953. int result = PASS;
  954. char sql[512];
  955. char* errMsg = NULL;
  956. 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;",
  957. data->idToken.idToken,
  958. data->idToken.type,
  959. data->idTokenInfo.status,
  960. data->idTokenInfo.cacheExpiryDateTime,
  961. data->idTokenInfo.chargingPriority,
  962. data->idTokenInfo.language1,
  963. data->idTokenInfo.language2,
  964. data->idTokenInfo.groupIdToken.idToken,
  965. data->idTokenInfo.groupIdToken.type,
  966. listVersion);
  967. //* Execute SQL statement */
  968. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  969. {
  970. DEBUG_INFO("SQL error: %s\n", errMsg);
  971. result = FAIL;
  972. }
  973. else
  974. {
  975. memset(sql, 0, ARRAY_SIZE(sql));
  976. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  977. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  978. {
  979. DEBUG_INFO("SQL error: %s\n", errMsg);
  980. result = FAIL;
  981. }
  982. }
  983. return result;
  984. }
  985. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  986. {
  987. int result = PASS;
  988. char sql[512];
  989. char* errMsg = NULL;
  990. 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;",
  991. idToken->idToken,
  992. idToken->type,
  993. idTokenInfo->status,
  994. idTokenInfo->cacheExpiryDateTime,
  995. idTokenInfo->chargingPriority,
  996. idTokenInfo->language1,
  997. idTokenInfo->language2,
  998. idTokenInfo->groupIdToken.idToken,
  999. idTokenInfo->groupIdToken.type);
  1000. //* Execute SQL statement */
  1001. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1002. {
  1003. DEBUG_INFO("SQL error: %s\n", errMsg);
  1004. result = FAIL;
  1005. }
  1006. return result;
  1007. }
  1008. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1009. {
  1010. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1011. // printf("localversion=%d\n", localversion);
  1012. return 0;
  1013. }
  1014. void DB_deleteIdTag(char idTag[])
  1015. {
  1016. char sql[512];
  1017. char* errMsg = NULL;
  1018. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1019. //* Execute SQL statement */
  1020. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1021. {
  1022. DEBUG_INFO("SQL error: %s", errMsg);
  1023. }
  1024. }
  1025. int DB_cleanLocalList()
  1026. {
  1027. int result = PASS;
  1028. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1029. char *errMsg = 0;
  1030. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1031. {
  1032. DEBUG_INFO("%s\n", errMsg);
  1033. result = FAIL;
  1034. }
  1035. return result;
  1036. }
  1037. int DB_cleanLocalCache()
  1038. {
  1039. int result = PASS;
  1040. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1041. char *errMsg = 0;
  1042. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1043. {
  1044. DEBUG_INFO("%s\n", errMsg);
  1045. result = FAIL;
  1046. }
  1047. return result;
  1048. }
  1049. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1050. {
  1051. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1052. return 0;
  1053. }
  1054. void DB_getBooType()
  1055. {
  1056. char sql[256];
  1057. char* errMsg = NULL;
  1058. sprintf(sql,"select * from ocpp20_boot_type;");
  1059. /* Execute SQL statement */
  1060. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1061. {
  1062. DEBUG_INFO("SQL error: %s\n", errMsg);
  1063. }
  1064. }
  1065. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1066. {
  1067. for(int i = 0; i<columnCount; i++)
  1068. {
  1069. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1070. }
  1071. return 0;
  1072. }
  1073. int DB_updateBootType(BootReasonEnumType reason)
  1074. {
  1075. int result = PASS;
  1076. char sql[512];
  1077. char* errMsg = NULL;
  1078. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1079. //* Execute SQL statement */
  1080. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1081. {
  1082. DEBUG_INFO("SQL error: %s\n", errMsg);
  1083. result = FAIL;
  1084. }
  1085. return result;
  1086. }
  1087. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1088. {
  1089. for(int i = 0; i<columnCount; i++)
  1090. {
  1091. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1092. }
  1093. return 0;
  1094. }
  1095. int DB_variableSaveToDb(struct ReportDataType *variable)
  1096. {
  1097. int result = FAIL;
  1098. char sql[4096];
  1099. char* errMsg = NULL;
  1100. 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;",
  1101. variable->component.name,
  1102. variable->component.instance,
  1103. variable->variable.name,
  1104. variable->variable.instance,
  1105. variable->variableCharacteristics.dataType,
  1106. variable->variableCharacteristics.unit,
  1107. variable->variableCharacteristics.maxLimit,
  1108. variable->variableAttribute[0].type,
  1109. variable->variableAttribute[0].mutability,
  1110. variable->variableAttribute[0].value);
  1111. //* Execute SQL statement */
  1112. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1113. {
  1114. DEBUG_INFO("SQL error: %s\n", errMsg);
  1115. result = FAIL;
  1116. }
  1117. return result;
  1118. }
  1119. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1120. {
  1121. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1122. if(atoi(columnValue[0]) == 0)
  1123. {
  1124. DB_updateBootType(BootReasonEnumType_PowerUp);
  1125. // Create variable table content
  1126. /* AlignedDataCtrlr Required item */
  1127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1133. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1140. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1146. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1148. else
  1149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1150. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1155. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 10;
  1156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1159. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1166. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1173. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1179. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1181. else
  1182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1183. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1191. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1192. /* AuthCtrlrVariable Required item */
  1193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1199. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1206. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1213. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1220. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1227. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1234. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1238. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1242. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1243. /* AuthCacheCtrlr Variable Required item*/
  1244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1250. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1257. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1265. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1269. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*100);
  1270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1273. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1280. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1281. /* ClockCtrlr Variable Required item */
  1282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1287. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1288. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1295. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1303. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1310. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1317. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1325. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1332. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1339. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1340. /* ChargingStation Required item */
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1347. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1354. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1361. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1362. /* Connector Required item */
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1369. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1376. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1383. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1384. /* CustomizationCtrlr Required item */
  1385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1391. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1392. /* DeviceDataCtrlr Required item */
  1393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1400. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1408. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1416. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1424. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1427. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1432. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1435. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1440. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1448. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1456. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1457. /* DisplayMessageCtrlr Required item */
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1464. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1471. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "0");
  1478. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1485. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1492. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1493. /* EVSE Required item */
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1500. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1507. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1514. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1521. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1522. /* LocalAuthListCtrlr Required item */
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1529. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1536. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1543. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "50");
  1551. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "2048");
  1559. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1563. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = 1024*1024;
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "5000");
  1567. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1568. /* MonitoringCtrlr Required item */
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1575. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1582. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1583. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1590. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1591. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1598. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1606. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1614. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1621. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1622. /* OCPPCommCtrlr Required item */
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1629. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1638. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1645. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1653. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1659. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1660. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1667. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1675. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1682. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1691. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1700. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1707. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1715. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1720. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1722. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1729. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1730. /* ReservationCtrlr Required item */
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1737. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1744. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1751. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1752. /* SampledDataCtrlr Required item */
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1759. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1766. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1773. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, " ");
  1780. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1788. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1795. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1796. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, " ");
  1802. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1807. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 10;
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
  1811. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1812. /* SecurityCtrlr Required item */
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1816. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
  1820. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1821. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1824. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
  1828. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1829. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
  1835. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1836. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1842. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1843. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
  1849. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1850. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1856. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1857. /* SmartChargingCtrlr Required item */
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1864. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1865. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1871. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1878. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1885. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  1892. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  1899. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  1906. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  1913. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  1920. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "3");
  1927. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  1928. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  1929. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  1934. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  1935. /* TariffCostCtrlr Required item */
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  1943. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  1944. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  1951. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  1952. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1955. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1958. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  1959. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  1960. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1964. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1966. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  1967. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  1968. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  1975. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1979. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  1983. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1987. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  1988. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  1991. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  1992. /* TxCtrlr Required item */
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1999. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  2000. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2005. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2007. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2014. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2019. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2020. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2021. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2028. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2035. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2036. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "60000");
  2043. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2044. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2045. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2046. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2047. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2048. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2050. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2051. }
  2052. else
  2053. {
  2054. // Variable name init
  2055. /* AlignedDataCtrlr Required item */
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2065. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2066. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2072. /* AuthCtrlrVariable Required item */
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2087. /* AuthCacheCtrlr Variable Required item */
  2088. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2098. /* ClockCtrlr Variable Required item */
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2117. /* ChargingStation Required item */
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2124. /* Connector Required item */
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2131. /* CustomizationCtrlr Required item */
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  2134. /* DeviceDataCtrlr Required item */
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2157. /* DisplayMessageCtrlr Required item */
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2168. /* EVSE Required item */
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2177. /* LocalAuthListCtrlr Required item */
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2192. /* MonitoringCtrlr Required item */
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2211. /* OCPPCommCtrlr Required item */
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2243. /* ReservationCtrlr Required item */
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2250. /* SampledDataCtrlr Required item */
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2267. /* SecurityCtrlr Required item */
  2268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2280. /* SmartChargingCtrlr Required item */
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2303. /* TariffCostCtrlr Required item */
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2322. /* TxCtrlr Required item */
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2339. }
  2340. return 0;
  2341. }
  2342. void DB_variableIsCreate()
  2343. {
  2344. char sql[512];
  2345. char* errMsg = NULL;
  2346. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2347. /* Execute SQL statement */
  2348. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2349. {
  2350. DEBUG_INFO("SQL error: %s\n", errMsg);
  2351. }
  2352. }
  2353. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2354. {
  2355. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2356. {
  2357. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) == 0) &&
  2358. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) == 0) &&
  2359. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) == 0) &&
  2360. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) == 0))
  2361. {
  2362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2364. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2368. }
  2369. }
  2370. return 0;
  2371. }
  2372. void DB_variableLoadFromDb()
  2373. {
  2374. char sql[512];
  2375. char* errMsg = NULL;
  2376. sprintf(sql,"select * from ocpp20_variable order by idx;");
  2377. /* Execute SQL statement */
  2378. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2379. {
  2380. DEBUG_INFO("SQL error: %s\n", errMsg);
  2381. }
  2382. }
  2383. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2384. {
  2385. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2386. if(columnCount > 0)
  2387. {
  2388. for(int idx=0;idx<columnCount;idx++)
  2389. {
  2390. json_object *SetNetworkProfile;
  2391. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2392. if(!is_error(SetNetworkProfile))
  2393. {
  2394. // Required data
  2395. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2396. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2397. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2398. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2399. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2400. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2401. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2402. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2403. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2404. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2405. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2406. {
  2407. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2408. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2409. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2410. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2411. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2412. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2413. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2414. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2415. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2416. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2417. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2418. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2419. }
  2420. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2421. {
  2422. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2423. {
  2424. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2425. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2426. }
  2427. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2428. {
  2429. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2430. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2431. }
  2432. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2433. {
  2434. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2435. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2436. }
  2437. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2438. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2439. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2440. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2441. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2442. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2443. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2444. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2445. }
  2446. }
  2447. json_object_put(SetNetworkProfile);
  2448. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2449. }
  2450. }
  2451. return 0;
  2452. }
  2453. void DB_getNetworkProfileFromDb()
  2454. {
  2455. char sql[512];
  2456. char* errMsg = NULL;
  2457. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2458. /* Execute SQL statement */
  2459. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2460. {
  2461. DEBUG_INFO("SQL error: %s\n", errMsg);
  2462. }
  2463. }
  2464. int DB_addNetworkProfile(int slot, char *data)
  2465. {
  2466. int result = PASS;
  2467. char sql[512];
  2468. char* errMsg = NULL;
  2469. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2470. slot,
  2471. data);
  2472. //* Execute SQL statement */
  2473. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2474. {
  2475. DEBUG_INFO("SQL error: %s\n", errMsg);
  2476. result = FAIL;
  2477. }
  2478. return result;
  2479. }
  2480. int DB_deleteNetworkProfile(int slot)
  2481. {
  2482. int result = PASS;
  2483. char sql[512];
  2484. char* errMsg = NULL;
  2485. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2486. //* Execute SQL statement */
  2487. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2488. {
  2489. DEBUG_INFO("SQL error: %s", errMsg);
  2490. result = FAIL;
  2491. }
  2492. return result;
  2493. }
  2494. //==========================================
  2495. // Check time passed since today
  2496. //==========================================
  2497. long long DiffTimebWithNow(struct timeb ST)
  2498. {
  2499. //return milli-second
  2500. struct timeb ET;
  2501. long long StartTime,StopTime;
  2502. ftime(&ET);
  2503. StartTime=(long long)ST.time;
  2504. StopTime=(long long)ET.time;
  2505. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2506. }
  2507. int getTimePassSinceToday()
  2508. {
  2509. int result = -1;
  2510. time_t t;
  2511. struct tm *tmStartToday;
  2512. struct timeb tbStartToday;
  2513. t=time(NULL);
  2514. tmStartToday=localtime(&t);
  2515. tmStartToday->tm_hour = 0;
  2516. tmStartToday->tm_min = 0;
  2517. tmStartToday->tm_sec = 0;
  2518. tbStartToday.time = mktime(tmStartToday);
  2519. tbStartToday.millitm = 0;
  2520. result = DiffTimebWithNow(tbStartToday)/1000;
  2521. return result;
  2522. }
  2523. //==========================================
  2524. // GetCompositeSchedule logic related function
  2525. //==========================================
  2526. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2527. {
  2528. //return milli-second
  2529. unsigned int StartTime,StopTime;
  2530. StartTime=(unsigned int)ST.time;
  2531. StopTime=(unsigned int)ET.time;
  2532. return (StopTime-StartTime);
  2533. }
  2534. int DiffTimebWithNowSec(struct timeb ST)
  2535. {
  2536. //return milli-second
  2537. struct timeb ET;
  2538. unsigned int StartTime,StopTime;
  2539. ftime(&ET);
  2540. StartTime=(unsigned int)ST.time;
  2541. StopTime=(unsigned int)ET.time;
  2542. return (StopTime-StartTime);
  2543. }
  2544. int getStartStop(uint8_t *start, uint8_t *stop)
  2545. {
  2546. int result = -1;
  2547. struct tm tmStart;
  2548. struct timeb tbStart;
  2549. struct tm tmStop;
  2550. struct timeb tbStop;
  2551. 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) &&
  2552. (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))
  2553. {
  2554. //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);
  2555. //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);
  2556. tmStart.tm_year -= 1900;
  2557. tmStart.tm_mon -= 1;
  2558. tbStart.time = mktime(&tmStart);
  2559. tbStart.millitm = 0;
  2560. tmStop.tm_year -= 1900;
  2561. tmStop.tm_mon -= 1;
  2562. tbStop.time = mktime(&tmStop);
  2563. tbStop.millitm = 0;
  2564. result = DiffTimebSec(tbStart, tbStop);
  2565. //DEBUG_INFO("getStartStop(): %d\n", result);
  2566. }
  2567. else
  2568. {
  2569. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2570. }
  2571. return result;
  2572. }
  2573. int isOvertNow(uint8_t *start)
  2574. {
  2575. int result = NO;
  2576. struct tm tmStart;
  2577. struct timeb tbStart;
  2578. 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))
  2579. {
  2580. //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);
  2581. tmStart.tm_year -= 1900;
  2582. tmStart.tm_mon -= 1;
  2583. tbStart.time = mktime(&tmStart);
  2584. tbStart.millitm = 0;
  2585. if(DiffTimebWithNowSec(tbStart) <= 0)
  2586. result = NO;
  2587. else
  2588. result = YES;
  2589. }
  2590. else
  2591. {
  2592. DEBUG_WARN("Start date parsing error.\n");
  2593. }
  2594. return result;
  2595. }
  2596. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2597. {
  2598. int result = -1;
  2599. struct tm tmStart;
  2600. struct timeb tbStart;
  2601. struct tm tmStop;
  2602. struct timeb tbStop;
  2603. 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) &&
  2604. (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))
  2605. {
  2606. tmStart.tm_year -= 1900;
  2607. tmStart.tm_mon -= 1;
  2608. tbStart.time = mktime(&tmStart);
  2609. tbStart.millitm = 0;
  2610. tmStop.tm_year -= 1900;
  2611. tmStop.tm_mon -= 1;
  2612. tbStop.time = mktime(&tmStop);
  2613. tbStop.millitm = 0;
  2614. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2615. }
  2616. return result;
  2617. }
  2618. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile)
  2619. {
  2620. FILE *fp;
  2621. char profileFileName[128];
  2622. char *line = NULL;
  2623. size_t len = 0;
  2624. time_t CurrentTime;
  2625. struct tm *tmComposite;
  2626. struct ChargingProfileType maxProfile;
  2627. struct ChargingProfileType defaultTxProfile;
  2628. struct ChargingProfileType txProfile;
  2629. struct ChargingSchedulePeriodType tmpPeriod;
  2630. uint8_t limitMax=0;
  2631. uint8_t limitDef=0;
  2632. uint8_t limitTx=0;
  2633. int compositePeriodIdx = 0;
  2634. CurrentTime = time(NULL);
  2635. tmComposite=localtime(&CurrentTime);
  2636. 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);
  2637. sprintf((char*)compositeProfile->chargingSchedule[0].chargingRateUnit, "A");
  2638. compositeProfile->chargingSchedule[0].duration = durationReq;
  2639. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2640. {
  2641. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2642. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2643. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2644. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  2645. }
  2646. compositeProfile->id = 0;
  2647. compositeProfile->stackLevel = 99 ;
  2648. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  2649. maxProfile.id = -1;
  2650. defaultTxProfile.id = -1;
  2651. txProfile.id = -1;
  2652. maxProfile.chargingSchedule[0].duration = -1;
  2653. defaultTxProfile.chargingSchedule[0].duration = -1;
  2654. txProfile.chargingSchedule[0].duration = -1;
  2655. system("yes|rm /tmp/*.json");
  2656. system("cp /Storage/OCPP/*.json /tmp");
  2657. /*
  2658. * Search valid charging profile
  2659. */
  2660. //DEBUG_INFO("====================================\n");
  2661. // Search tx profile
  2662. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  2663. if((access(profileFileName, F_OK))!=-1)
  2664. {
  2665. fp = fopen(profileFileName, "r");
  2666. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2667. {
  2668. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2669. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2670. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2671. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2672. }
  2673. txProfile.id = -1;
  2674. txProfile.stackLevel = -1;
  2675. while(getline(&line, &len, fp) != -1)
  2676. {
  2677. json_object *obj = NULL;
  2678. obj = json_tokener_parse(line);
  2679. if(is_error(obj))
  2680. {
  2681. DEBUG_ERROR("Parse txProfile from file error.\n");
  2682. }
  2683. else
  2684. {
  2685. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  2686. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  2687. )
  2688. {
  2689. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2690. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2691. )
  2692. {
  2693. struct tm tmFrom, tmTo;
  2694. struct timeb tbFrom, tbTo;
  2695. 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) &&
  2696. (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))
  2697. {
  2698. tmFrom.tm_year -= 1900;
  2699. tmFrom.tm_mon -= 1;
  2700. tbFrom.time = mktime(&tmFrom);
  2701. tmTo.tm_year -= 1900;
  2702. tmTo.tm_mon -= 1;
  2703. tbTo.time = mktime(&tmTo);
  2704. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2705. {
  2706. if(txProfile.id == -1)
  2707. DEBUG_INFO("TxProfile found.\n");
  2708. else
  2709. DEBUG_INFO("TxProfile updated.\n");
  2710. // Required item
  2711. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2712. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2713. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2714. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2715. 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++)
  2716. {
  2717. 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"));
  2718. 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?
  2719. 3:
  2720. 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")));
  2721. 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")));
  2722. }
  2723. // Optional item
  2724. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2725. {
  2726. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2727. }
  2728. else
  2729. {
  2730. sprintf((char*)txProfile.validFrom, " ");
  2731. }
  2732. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2733. {
  2734. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2735. }
  2736. else
  2737. {
  2738. sprintf((char*)txProfile.validTo, " ");
  2739. }
  2740. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2741. {
  2742. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2743. }
  2744. else
  2745. {
  2746. sprintf((char*)txProfile.recurrencyKind, " ");
  2747. }
  2748. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2749. {
  2750. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2751. }
  2752. else
  2753. {
  2754. sprintf((char*)txProfile.transactionId, " ");
  2755. }
  2756. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2757. {
  2758. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2759. }
  2760. else
  2761. {
  2762. txProfile.chargingSchedule[0].duration = 86400;
  2763. }
  2764. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2765. {
  2766. 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")));
  2767. }
  2768. else
  2769. {
  2770. 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));
  2771. }
  2772. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2773. {
  2774. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2775. }
  2776. else
  2777. {
  2778. txProfile.chargingSchedule[0].minChargingRate = -1;
  2779. }
  2780. }
  2781. }
  2782. }
  2783. else
  2784. {
  2785. if(txProfile.id == -1)
  2786. DEBUG_INFO("TxProfile found.\n");
  2787. else
  2788. DEBUG_INFO("TxProfile updated.\n");
  2789. // Required item
  2790. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2791. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2792. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2793. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2794. 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++)
  2795. {
  2796. 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"));
  2797. 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?
  2798. 3:
  2799. 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")));
  2800. 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")));
  2801. }
  2802. // Optional item
  2803. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2804. {
  2805. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2806. }
  2807. else
  2808. {
  2809. sprintf((char*)txProfile.validFrom, " ");
  2810. }
  2811. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2812. {
  2813. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2814. }
  2815. else
  2816. {
  2817. sprintf((char*)txProfile.validTo, " ");
  2818. }
  2819. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2820. {
  2821. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2822. }
  2823. else
  2824. {
  2825. sprintf((char*)txProfile.recurrencyKind, " ");
  2826. }
  2827. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2828. {
  2829. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2830. }
  2831. else
  2832. {
  2833. sprintf((char*)txProfile.transactionId, " ");
  2834. }
  2835. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2836. {
  2837. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2838. }
  2839. else
  2840. {
  2841. txProfile.chargingSchedule[0].duration = 86400;
  2842. }
  2843. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2844. {
  2845. 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")));
  2846. }
  2847. else
  2848. {
  2849. 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));
  2850. }
  2851. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2852. {
  2853. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2854. }
  2855. else
  2856. {
  2857. txProfile.chargingSchedule[0].minChargingRate = -1;
  2858. }
  2859. }
  2860. }
  2861. }
  2862. json_object_put(obj);
  2863. }
  2864. fclose(fp);
  2865. /*
  2866. if(txProfile.ChargingProfileId != -1)
  2867. {
  2868. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  2869. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  2870. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  2871. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  2872. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  2873. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  2874. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  2875. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[0].StartSchedule);
  2876. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  2877. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  2878. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  2879. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2880. {
  2881. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2882. {
  2883. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2884. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2885. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2886. }
  2887. }
  2888. }
  2889. else
  2890. DEBUG_INFO("TxProfile not found.\n");*/
  2891. }
  2892. // Search default tx profile
  2893. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  2894. if((access(profileFileName, F_OK))==-1)
  2895. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  2896. if((access(profileFileName, F_OK))!=-1)
  2897. {
  2898. fp = fopen(profileFileName, "r");
  2899. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2900. {
  2901. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2902. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2903. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2904. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2905. }
  2906. defaultTxProfile.id = -1;
  2907. defaultTxProfile.stackLevel = -1;
  2908. while(getline(&line, &len, fp) != -1)
  2909. {
  2910. json_object *obj = NULL;
  2911. obj = json_tokener_parse(line);
  2912. if(is_error(obj))
  2913. {
  2914. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  2915. }
  2916. else
  2917. {
  2918. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  2919. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  2920. )
  2921. {
  2922. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2923. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2924. )
  2925. {
  2926. struct tm tmFrom, tmTo;
  2927. struct timeb tbFrom, tbTo;
  2928. 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) &&
  2929. (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))
  2930. {
  2931. tmFrom.tm_year -= 1900;
  2932. tmFrom.tm_mon -= 1;
  2933. tbFrom.time = mktime(&tmFrom);
  2934. tmTo.tm_year -= 1900;
  2935. tmTo.tm_mon -= 1;
  2936. tbTo.time = mktime(&tmTo);
  2937. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2938. {
  2939. if(defaultTxProfile.id == -1)
  2940. DEBUG_INFO("TxDefaultProfile found.\n");
  2941. else
  2942. DEBUG_INFO("TxDefaultProfile updated.\n");
  2943. // Required item
  2944. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2945. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2946. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2947. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2948. 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++)
  2949. {
  2950. 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"));
  2951. 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?
  2952. 3:
  2953. 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")));
  2954. 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")));
  2955. }
  2956. // Optional item
  2957. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2958. {
  2959. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2960. }
  2961. else
  2962. {
  2963. sprintf((char*)defaultTxProfile.validFrom, " ");
  2964. }
  2965. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2966. {
  2967. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2968. }
  2969. else
  2970. {
  2971. sprintf((char*)defaultTxProfile.validTo, " ");
  2972. }
  2973. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2974. {
  2975. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2976. }
  2977. else
  2978. {
  2979. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2980. }
  2981. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2982. {
  2983. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2984. }
  2985. else
  2986. {
  2987. sprintf((char*)defaultTxProfile.transactionId, " ");
  2988. }
  2989. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2990. {
  2991. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2992. }
  2993. else
  2994. {
  2995. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2996. }
  2997. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2998. {
  2999. 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")));
  3000. }
  3001. else
  3002. {
  3003. 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));
  3004. }
  3005. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3006. {
  3007. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3008. }
  3009. else
  3010. {
  3011. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3012. }
  3013. }
  3014. }
  3015. }
  3016. else
  3017. {
  3018. if(defaultTxProfile.id == -1)
  3019. DEBUG_INFO("TxDefaultProfile found.\n");
  3020. else
  3021. DEBUG_INFO("TxDefaultProfile updated.\n");
  3022. // Required item
  3023. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3024. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3025. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3026. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3027. 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++)
  3028. {
  3029. 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"));
  3030. 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?
  3031. 3:
  3032. 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")));
  3033. 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")));
  3034. }
  3035. // Optional item
  3036. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3037. {
  3038. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3039. }
  3040. else
  3041. {
  3042. sprintf((char*)defaultTxProfile.validFrom, " ");
  3043. }
  3044. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3045. {
  3046. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3047. }
  3048. else
  3049. {
  3050. sprintf((char*)defaultTxProfile.validTo, " ");
  3051. }
  3052. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3053. {
  3054. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3055. }
  3056. else
  3057. {
  3058. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3059. }
  3060. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3061. {
  3062. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3063. }
  3064. else
  3065. {
  3066. sprintf((char*)defaultTxProfile.transactionId, " ");
  3067. }
  3068. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3069. {
  3070. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3071. }
  3072. else
  3073. {
  3074. defaultTxProfile.chargingSchedule[0].duration = 86400;
  3075. }
  3076. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3077. {
  3078. 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")));
  3079. }
  3080. else
  3081. {
  3082. 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));
  3083. }
  3084. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3085. {
  3086. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3087. }
  3088. else
  3089. {
  3090. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3091. }
  3092. }
  3093. }
  3094. }
  3095. json_object_put(obj);
  3096. }
  3097. fclose(fp);
  3098. /*
  3099. if(defaultTxProfile.ChargingProfileId != -1)
  3100. {
  3101. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3102. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3103. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3104. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3105. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3106. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3107. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3108. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[0].StartSchedule);
  3109. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3110. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3111. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3112. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3113. {
  3114. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3115. {
  3116. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3117. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3118. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3119. }
  3120. }
  3121. }
  3122. else
  3123. DEBUG_INFO("TxDefaultProfile not found.\n");
  3124. DEBUG_INFO("------------------------------------\n");*/
  3125. }
  3126. // Search max profile
  3127. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  3128. if((access(profileFileName, F_OK))!=-1)
  3129. {
  3130. fp = fopen(profileFileName, "r");
  3131. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3132. {
  3133. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3134. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  3135. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3136. }
  3137. maxProfile.id = -1;
  3138. maxProfile.stackLevel = -1;
  3139. while(getline(&line, &len, fp) != -1)
  3140. {
  3141. json_object *obj = NULL;
  3142. obj = json_tokener_parse(line);
  3143. if(is_error(obj))
  3144. {
  3145. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3146. }
  3147. else
  3148. {
  3149. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  3150. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3151. )
  3152. {
  3153. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3154. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3155. )
  3156. {
  3157. struct tm tmFrom, tmTo;
  3158. struct timeb tbFrom, tbTo;
  3159. 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) &&
  3160. (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))
  3161. {
  3162. tmFrom.tm_year -= 1900;
  3163. tmFrom.tm_mon -= 1;
  3164. tbFrom.time = mktime(&tmFrom);
  3165. tmTo.tm_year -= 1900;
  3166. tmTo.tm_mon -= 1;
  3167. tbTo.time = mktime(&tmTo);
  3168. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3169. {
  3170. if(maxProfile.id == -1)
  3171. DEBUG_INFO("MaxProfile found.\n");
  3172. else
  3173. DEBUG_INFO("MaxProfile updated.\n");
  3174. // Required item
  3175. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3176. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3177. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3178. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3179. 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++)
  3180. {
  3181. 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"));
  3182. 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?
  3183. 3:
  3184. 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")));
  3185. 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")));
  3186. }
  3187. // Optional item
  3188. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3189. {
  3190. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3191. }
  3192. else
  3193. {
  3194. sprintf((char*)maxProfile.validFrom, " ");
  3195. }
  3196. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3197. {
  3198. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3199. }
  3200. else
  3201. {
  3202. sprintf((char*)maxProfile.validTo, " ");
  3203. }
  3204. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3205. {
  3206. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3207. }
  3208. else
  3209. {
  3210. sprintf((char*)maxProfile.recurrencyKind, " ");
  3211. }
  3212. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3213. {
  3214. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3215. }
  3216. else
  3217. {
  3218. sprintf((char*)maxProfile.transactionId, " ");
  3219. }
  3220. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3221. {
  3222. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3223. }
  3224. else
  3225. {
  3226. maxProfile.chargingSchedule[0].duration = 86400;
  3227. }
  3228. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3229. {
  3230. 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")));
  3231. }
  3232. else
  3233. {
  3234. 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));
  3235. }
  3236. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3237. {
  3238. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3239. }
  3240. else
  3241. {
  3242. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3243. }
  3244. }
  3245. }
  3246. }
  3247. else
  3248. {
  3249. if(maxProfile.id == -1)
  3250. DEBUG_INFO("MaxProfile found.\n");
  3251. else
  3252. DEBUG_INFO("MaxProfile updated.\n");
  3253. // Required item
  3254. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3255. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3256. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3257. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3258. 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++)
  3259. {
  3260. 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"));
  3261. 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?
  3262. 3:
  3263. 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")));
  3264. 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")));
  3265. }
  3266. // Optional item
  3267. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3268. {
  3269. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3270. }
  3271. else
  3272. {
  3273. sprintf((char*)maxProfile.validFrom, " ");
  3274. }
  3275. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3276. {
  3277. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3278. }
  3279. else
  3280. {
  3281. sprintf((char*)maxProfile.validTo, " ");
  3282. }
  3283. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3284. {
  3285. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3286. }
  3287. else
  3288. {
  3289. sprintf((char*)maxProfile.recurrencyKind, " ");
  3290. }
  3291. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3292. {
  3293. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3294. }
  3295. else
  3296. {
  3297. sprintf((char*)maxProfile.transactionId, " ");
  3298. }
  3299. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3300. {
  3301. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3302. }
  3303. else
  3304. {
  3305. maxProfile.chargingSchedule[0].duration = 86400;
  3306. }
  3307. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3308. {
  3309. 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")));
  3310. }
  3311. else
  3312. {
  3313. 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));
  3314. }
  3315. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3316. {
  3317. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3318. }
  3319. else
  3320. {
  3321. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3322. }
  3323. }
  3324. }
  3325. }
  3326. json_object_put(obj);
  3327. }
  3328. fclose(fp);
  3329. /*
  3330. if(maxProfile.ChargingProfileId !=-1)
  3331. {
  3332. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3333. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3334. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3335. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3336. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3337. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3338. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3339. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[0].StartSchedule);
  3340. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3341. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3342. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3343. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3344. {
  3345. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3346. {
  3347. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3348. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3349. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3350. }
  3351. }
  3352. }
  3353. else
  3354. DEBUG_INFO("MaxProfile not found.\n");
  3355. DEBUG_INFO("------------------------------------\n");*/
  3356. }
  3357. /*
  3358. * Align found profile start schedule & periods
  3359. */
  3360. //DEBUG_INFO("====================================\n");
  3361. /*
  3362. // For local test usage, force modify found profile start schedule info
  3363. 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);
  3364. 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);
  3365. 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);
  3366. */
  3367. if(txProfile.id != -1)
  3368. {
  3369. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3370. {
  3371. if(txProfile.chargingSchedule[0].duration != -1)
  3372. {
  3373. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3374. 0:
  3375. (txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3376. }
  3377. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3378. {
  3379. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3380. {
  3381. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3382. 0:
  3383. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3384. if(idxPeriod > 0)
  3385. {
  3386. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3387. {
  3388. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3389. }
  3390. }
  3391. }
  3392. }
  3393. }
  3394. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3395. {
  3396. if(txProfile.chargingSchedule[0].duration != -1)
  3397. {
  3398. 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?
  3399. 0:
  3400. (txProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3401. }
  3402. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3403. {
  3404. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3405. {
  3406. 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?
  3407. 0:
  3408. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3409. if(idxPeriod > 0)
  3410. {
  3411. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3412. {
  3413. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3414. }
  3415. }
  3416. }
  3417. }
  3418. }
  3419. else
  3420. {
  3421. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3422. {
  3423. if(txProfile.chargingSchedule[0].duration != -1)
  3424. {
  3425. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3426. 0:
  3427. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3428. }
  3429. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3430. {
  3431. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3432. {
  3433. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3434. 0:
  3435. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3436. if(idxPeriod > 0)
  3437. {
  3438. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3439. {
  3440. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3441. }
  3442. }
  3443. }
  3444. }
  3445. }
  3446. else
  3447. {
  3448. if(txProfile.chargingSchedule[0].duration != -1)
  3449. {
  3450. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3451. 0:
  3452. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3453. }
  3454. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3455. {
  3456. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3457. {
  3458. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3459. 0:
  3460. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3461. if(idxPeriod > 0)
  3462. {
  3463. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3464. {
  3465. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3466. }
  3467. }
  3468. }
  3469. }
  3470. }
  3471. }
  3472. /*
  3473. DEBUG_INFO("txProfile after align.\n");
  3474. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3475. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3476. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3477. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3478. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3479. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3480. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3481. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3482. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  3483. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  3484. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  3485. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3486. {
  3487. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3488. {
  3489. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3490. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3491. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3492. }
  3493. }*/
  3494. }
  3495. if(defaultTxProfile.id != -1)
  3496. {
  3497. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3498. {
  3499. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3500. {
  3501. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3502. 0:
  3503. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3504. }
  3505. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3506. {
  3507. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3508. {
  3509. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3510. 0:
  3511. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3512. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3513. {
  3514. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3515. }
  3516. if(idxPeriod > 0)
  3517. {
  3518. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3519. {
  3520. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3521. }
  3522. }
  3523. }
  3524. }
  3525. }
  3526. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3527. {
  3528. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3529. {
  3530. 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?
  3531. 0:
  3532. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3533. }
  3534. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3535. {
  3536. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3537. {
  3538. 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?
  3539. 0:
  3540. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3541. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3542. {
  3543. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3544. }
  3545. if(idxPeriod > 0)
  3546. {
  3547. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3548. {
  3549. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3550. }
  3551. }
  3552. }
  3553. }
  3554. }
  3555. else
  3556. {
  3557. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3558. {
  3559. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3560. {
  3561. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3562. 0:
  3563. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3564. }
  3565. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3566. {
  3567. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3568. {
  3569. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3570. 0:
  3571. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3572. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3573. {
  3574. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3575. }
  3576. if(idxPeriod > 0)
  3577. {
  3578. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3579. {
  3580. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3581. }
  3582. }
  3583. }
  3584. }
  3585. }
  3586. else
  3587. {
  3588. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3589. {
  3590. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3591. 0:
  3592. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3593. }
  3594. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3595. {
  3596. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3597. {
  3598. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3599. 0:
  3600. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3601. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3602. {
  3603. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3604. }
  3605. if(idxPeriod > 0)
  3606. {
  3607. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3608. {
  3609. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3610. }
  3611. }
  3612. }
  3613. }
  3614. }
  3615. }
  3616. /*
  3617. DEBUG_INFO("defaultTxProfile after align.\n");
  3618. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3619. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3620. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3621. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3622. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3623. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3624. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3625. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3626. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3627. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3628. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3629. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3630. {
  3631. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3632. {
  3633. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3634. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3635. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3636. }
  3637. }
  3638. DEBUG_INFO("------------------------------------\n");*/
  3639. }
  3640. if(maxProfile.id != -1)
  3641. {
  3642. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3643. {
  3644. if(maxProfile.chargingSchedule[0].duration != -1)
  3645. {
  3646. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3647. 0:
  3648. (maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3649. }
  3650. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3651. {
  3652. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3653. {
  3654. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3655. 0:
  3656. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3657. if(idxPeriod > 0)
  3658. {
  3659. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3660. {
  3661. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3662. }
  3663. }
  3664. }
  3665. }
  3666. }
  3667. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3668. {
  3669. if(maxProfile.chargingSchedule[0].duration != -1)
  3670. {
  3671. 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?
  3672. 0:
  3673. (maxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  3674. }
  3675. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3676. {
  3677. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3678. {
  3679. 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?
  3680. 0:
  3681. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3682. if(idxPeriod > 0)
  3683. {
  3684. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3685. {
  3686. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3687. }
  3688. }
  3689. }
  3690. }
  3691. }
  3692. else
  3693. {
  3694. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3695. {
  3696. if(maxProfile.chargingSchedule[0].duration != -1)
  3697. {
  3698. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3699. 0:
  3700. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3701. }
  3702. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3703. {
  3704. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3705. {
  3706. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3707. 0:
  3708. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3709. if(idxPeriod > 0)
  3710. {
  3711. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3712. {
  3713. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3714. }
  3715. }
  3716. }
  3717. }
  3718. }
  3719. else
  3720. {
  3721. if(maxProfile.chargingSchedule[0].duration != -1)
  3722. {
  3723. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3724. 0:
  3725. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3726. }
  3727. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3728. {
  3729. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3730. {
  3731. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3732. 0:
  3733. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3734. if(idxPeriod > 0)
  3735. {
  3736. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3737. {
  3738. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3739. }
  3740. }
  3741. }
  3742. }
  3743. }
  3744. }
  3745. /*
  3746. DEBUG_INFO("MaxProfile after align.\n");
  3747. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3748. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3749. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3750. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3751. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3752. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3753. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3754. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3755. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3756. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3757. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3758. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3759. {
  3760. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3761. {
  3762. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3763. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3764. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3765. }
  3766. }
  3767. DEBUG_INFO("------------------------------------\n");*/
  3768. }
  3769. /*
  3770. * Merge to conposite schedule
  3771. */
  3772. //DEBUG_INFO("====================================\n");
  3773. // Find each profile period quantity
  3774. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3775. {
  3776. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3777. limitMax = idx+1;
  3778. }
  3779. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3780. {
  3781. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3782. limitDef = idx+1;
  3783. }
  3784. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3785. {
  3786. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3787. limitTx = idx+1;
  3788. }
  3789. // TxProfile found, composite schedule based on it
  3790. if(txProfile.id != -1)
  3791. {
  3792. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  3793. {
  3794. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  3795. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  3796. (txProfile.chargingSchedule[0].duration > 0))
  3797. {
  3798. if(maxProfile.id != -1)
  3799. {
  3800. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3801. {
  3802. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  3803. {
  3804. if((maxProfile.chargingSchedule[0].duration > 0))
  3805. {
  3806. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3807. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3808. 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);
  3809. }
  3810. else
  3811. {
  3812. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3813. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3814. tmpPeriod.limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit;
  3815. }
  3816. }
  3817. if(idxMaxPeriod == (limitMax-1))
  3818. {
  3819. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3820. {
  3821. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3822. {
  3823. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3824. compositePeriodIdx++;
  3825. }
  3826. else
  3827. {
  3828. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3829. }
  3830. }
  3831. }
  3832. }
  3833. }
  3834. else
  3835. {
  3836. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3837. {
  3838. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3839. compositePeriodIdx++;
  3840. }
  3841. else
  3842. {
  3843. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3844. }
  3845. }
  3846. }
  3847. if(idxTxPeriod == (limitTx-1))
  3848. {
  3849. if(defaultTxProfile.id != -1)
  3850. {
  3851. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3852. {
  3853. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  3854. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3855. (defaultTxProfile.chargingSchedule[0].duration>0))
  3856. {
  3857. if(maxProfile.id != -1)
  3858. {
  3859. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3860. {
  3861. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3862. {
  3863. if((maxProfile.chargingSchedule[0].duration > 0))
  3864. {
  3865. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3866. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3867. 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);
  3868. }
  3869. else
  3870. {
  3871. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3872. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3873. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3874. }
  3875. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3876. {
  3877. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3878. {
  3879. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3880. compositePeriodIdx++;
  3881. }
  3882. else
  3883. {
  3884. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3885. }
  3886. }
  3887. break;
  3888. }
  3889. }
  3890. }
  3891. else
  3892. {
  3893. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3894. {
  3895. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3896. compositePeriodIdx++;
  3897. }
  3898. else
  3899. {
  3900. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3901. }
  3902. }
  3903. }
  3904. }
  3905. }
  3906. }
  3907. }
  3908. }
  3909. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  3910. else if(defaultTxProfile.id != -1)
  3911. {
  3912. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3913. {
  3914. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  3915. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3916. (defaultTxProfile.chargingSchedule[0].duration > 0))
  3917. {
  3918. if(maxProfile.id != -1)
  3919. {
  3920. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3921. {
  3922. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3923. {
  3924. if((maxProfile.chargingSchedule[0].duration > 0))
  3925. {
  3926. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3927. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3928. 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);
  3929. }
  3930. else
  3931. {
  3932. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3933. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3934. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3935. }
  3936. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3937. {
  3938. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3939. {
  3940. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3941. compositePeriodIdx++;
  3942. }
  3943. else
  3944. {
  3945. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3946. }
  3947. }
  3948. break;
  3949. }
  3950. }
  3951. }
  3952. else
  3953. {
  3954. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3955. {
  3956. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3957. compositePeriodIdx++;
  3958. }
  3959. else
  3960. {
  3961. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3962. }
  3963. }
  3964. }
  3965. }
  3966. }
  3967. // Fill other period by MaxProfile
  3968. if(maxProfile.id != -1)
  3969. {
  3970. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3971. {
  3972. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3973. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3974. (maxProfile.chargingSchedule[0].duration > 0))
  3975. {
  3976. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  3977. (maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3978. {
  3979. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  3980. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  3981. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3982. }
  3983. if((maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3984. {
  3985. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].duration;
  3986. tmpPeriod.numberPhases = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  3987. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3988. }
  3989. if(tmpPeriod.limit != -1)
  3990. {
  3991. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3992. {
  3993. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3994. {
  3995. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3996. compositePeriodIdx++;
  3997. }
  3998. else
  3999. {
  4000. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4001. }
  4002. }
  4003. }
  4004. }
  4005. }
  4006. }
  4007. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  4008. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[0].startSchedule);
  4009. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[0].duration);
  4010. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[0].chargingRateUnit);
  4011. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  4012. {
  4013. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  4014. {
  4015. compositeProfile->id = 1;
  4016. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  4017. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit);
  4018. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases);
  4019. }
  4020. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit == -1)
  4021. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit =0;
  4022. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  4023. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  4024. }
  4025. if(line)
  4026. free(line);
  4027. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  4028. }
  4029. //==========================================
  4030. // Init all share memory
  4031. //==========================================
  4032. int InitShareMemory()
  4033. {
  4034. int result = PASS;
  4035. int MeterSMId;
  4036. //creat ShmSysConfigAndInfo
  4037. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  4038. {
  4039. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  4040. result = FAIL;
  4041. }
  4042. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4043. {
  4044. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  4045. result = FAIL;
  4046. }
  4047. else
  4048. {}
  4049. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  4050. {
  4051. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  4052. result = FAIL;
  4053. }
  4054. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4055. {
  4056. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  4057. result = FAIL;
  4058. }
  4059. else
  4060. {}
  4061. //creat ShmPsuData
  4062. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  4063. {
  4064. DEBUG_ERROR("shmget ShmPsuData NG\n");
  4065. result = FAIL;
  4066. }
  4067. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4068. {
  4069. DEBUG_ERROR("shmat ShmPsuData NG\n");
  4070. result = FAIL;
  4071. }
  4072. else
  4073. {}
  4074. //creat ShmOCPP20Data
  4075. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  4076. {
  4077. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  4078. result = FAIL;
  4079. }
  4080. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4081. {
  4082. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  4083. result = FAIL;
  4084. }
  4085. else
  4086. {}
  4087. /****************************** For Initial Settings************************************************/
  4088. /*
  4089. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  4090. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  4091. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  4092. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  4093. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  4094. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  4095. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  4096. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  4097. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  4098. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  4099. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  4100. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  4101. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  4102. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  4103. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  4104. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  4105. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  4106. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  4107. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  4108. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  4109. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  4110. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  4111. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  4112. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  4113. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  4114. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  4115. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  4116. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  4117. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  4118. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  4119. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  4120. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  4121. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  4122. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  4123. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  4124. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  4125. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  4126. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  4127. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  4128. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  4129. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  4130. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  4131. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  4132. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  4133. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  4134. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  4135. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  4136. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  4137. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  4138. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  4139. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  4140. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  4141. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  4142. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  4143. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  4144. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  4145. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  4146. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  4147. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  4148. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  4149. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  4150. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  4151. */
  4152. return result;
  4153. }
  4154. int ProcessShareMemory()
  4155. {
  4156. if(InitShareMemory() == FAIL)
  4157. {
  4158. DEBUG_ERROR("InitShareMemory NG\n");
  4159. if(ShmStatusCodeData!=NULL)
  4160. {
  4161. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  4162. }
  4163. sleep(5);
  4164. return FAIL;
  4165. }
  4166. return PASS;
  4167. }
  4168. //---------------------common routine---------------------------//
  4169. void checkNetworkProfile(void)
  4170. {
  4171. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  4172. json_object *priority;
  4173. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  4174. if(!is_error(priority))
  4175. {
  4176. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  4177. {
  4178. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  4179. {
  4180. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  4181. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  4182. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  4183. {
  4184. memcpy(ShmOCPP20Data->OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  4185. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  4186. break;
  4187. }
  4188. }
  4189. }
  4190. }
  4191. json_object_put(priority);
  4192. DEBUG_INFO("Get network profile URL: %s\n", ShmOCPP20Data->OcppServerURL);
  4193. }
  4194. void CheckSystemValue(void)
  4195. {
  4196. char filenmae[100]={0};
  4197. char str[100]={0};
  4198. int tempIndex = 0;
  4199. //===============================
  4200. // EVSE operation check
  4201. //===============================
  4202. //===============================
  4203. // Heartbeat check
  4204. //===============================
  4205. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  4206. {
  4207. clientTime.Heartbeat = time((time_t*)NULL);
  4208. if(server_sign == TRUE)
  4209. {
  4210. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  4211. }
  4212. else
  4213. {
  4214. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  4215. }
  4216. }
  4217. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  4218. {
  4219. //parameter for test
  4220. sendHeartbeatRequest(0);
  4221. //==============================================
  4222. // Reset Waiting Time
  4223. //==============================================
  4224. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  4225. }
  4226. //===============================
  4227. // CSU Trigger Reset Conf
  4228. //===============================
  4229. if(isWebsocketSendable && (ShmOCPP20Data->MsMsg.bits.ResetConf == ON))
  4230. {
  4231. sendResetConfirmation((char *)ShmOCPP20Data->Reset.guid);
  4232. }
  4233. //===============================
  4234. // CSU Trigger Authorize Request
  4235. //===============================
  4236. if(isWebsocketSendable &&
  4237. (server_sign == TRUE) &&
  4238. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4239. (authorizeRetryTimes < 3))
  4240. {
  4241. sendAuthorizeRequest(0);
  4242. authorizeRetryTimes = authorizeRetryTimes + 1;
  4243. if(authorizeRetryTimes < 3)
  4244. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4245. }
  4246. else if((server_sign == TRUE) &&
  4247. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4248. (authorizeRetryTimes >= 3))
  4249. {
  4250. authorizeRetryTimes = 0;
  4251. SetOcppConnStatus(FALSE);
  4252. server_sign = FALSE;
  4253. }
  4254. else if((server_sign == FALSE) &&
  4255. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  4256. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  4257. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  4258. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  4259. {
  4260. sendAuthorizeRequest(0);
  4261. }
  4262. if(isWebsocketSendable &&
  4263. (server_sign == TRUE) &&
  4264. (ShmOCPP20Data->GetReport.requestId > 0))
  4265. {
  4266. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetReport.componentCriteria);idxCriterion++)
  4267. {
  4268. if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Active]) == 0)
  4269. {
  4270. /*
  4271. * TODO:
  4272. * 1. Report component that are active
  4273. */
  4274. }
  4275. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Available]) == 0)
  4276. {
  4277. /*
  4278. * TODO:
  4279. * 1. Report component that are available
  4280. */
  4281. }
  4282. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Enabled]) == 0)
  4283. {
  4284. /*
  4285. * TODO:
  4286. * 1. Report component that are enable
  4287. */
  4288. }
  4289. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Problem]) == 0)
  4290. {
  4291. /*
  4292. * TODO:
  4293. * 1. Report component that are problem
  4294. */
  4295. }
  4296. else
  4297. {
  4298. /*
  4299. * TODO:
  4300. * 1. Process unknown criteria condition
  4301. */
  4302. }
  4303. }
  4304. ShmOCPP20Data->GetReport.requestId = 0;
  4305. }
  4306. if(isWebsocketSendable &&
  4307. (server_sign == TRUE) &&
  4308. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  4309. {
  4310. uint8_t reportIdx = 0;
  4311. ShmOCPP20Data->NotifyReport.requestId = ShmOCPP20Data->GetBaseReport.requestId;
  4312. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  4313. {
  4314. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  4315. {
  4316. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  4317. {
  4318. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]) == 0) || (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]) == 0))
  4319. {
  4320. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  4321. reportIdx++;
  4322. }
  4323. }
  4324. else
  4325. {
  4326. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4327. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4328. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4329. else
  4330. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4331. sendNotifyReportRequest();
  4332. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4333. reportIdx = 0;
  4334. }
  4335. }
  4336. }
  4337. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  4338. {
  4339. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  4340. {
  4341. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  4342. {
  4343. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  4344. reportIdx++;
  4345. }
  4346. else
  4347. {
  4348. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4349. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4350. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4351. else
  4352. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4353. sendNotifyReportRequest();
  4354. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4355. reportIdx = 0;
  4356. }
  4357. }
  4358. }
  4359. else
  4360. {
  4361. /*
  4362. * TODO:
  4363. * 1. Fill out summary inventory to response message, currently not support
  4364. */
  4365. }
  4366. if(reportIdx > 0)
  4367. {
  4368. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4369. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4370. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4371. else
  4372. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4373. sendNotifyReportRequest();
  4374. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4375. reportIdx = 0;
  4376. }
  4377. ShmOCPP20Data->GetBaseReport.requestId = 0;
  4378. }
  4379. if(isWebsocketSendable &&
  4380. (server_sign == TRUE) &&
  4381. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  4382. {
  4383. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  4384. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  4385. if(ShmOCPP20Data->NotifyEvent.seqNo < INT_MAX)
  4386. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  4387. else
  4388. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  4389. sendNotifyEventRequest();
  4390. memset(&ShmOCPP20Data->NotifyEvent.eventData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)* sizeof(struct EventDataType ));
  4391. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  4392. }
  4393. if(isWebsocketSendable &&
  4394. (server_sign == TRUE) &&
  4395. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq)
  4396. {
  4397. if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Install]) == 0)
  4398. {
  4399. }
  4400. else if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Update]) == 0)
  4401. {
  4402. }
  4403. else
  4404. {
  4405. }
  4406. sendGet15118EVCertificateRequest();
  4407. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  4408. }
  4409. //===============================
  4410. // Each connector operation check
  4411. //===============================
  4412. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  4413. {
  4414. //==========================================
  4415. // csu trigger DataTransferReq
  4416. //==========================================
  4417. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4418. {
  4419. sendDataTransferRequest(gun_index);
  4420. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  4421. }
  4422. //===============================
  4423. // CSU Trigger Smart Charging Profilw
  4424. //===============================
  4425. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4426. {
  4427. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index]);
  4428. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4429. }
  4430. //==============================================
  4431. // Charger start transaction
  4432. //==============================================
  4433. /*
  4434. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  4435. {
  4436. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4437. sendStartTransactionRequest(gun_index);
  4438. clientTime.StartTransaction = time((time_t*)NULL);
  4439. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4440. }*/
  4441. //==============================================
  4442. // Charger stop transaction
  4443. //==============================================
  4444. /*
  4445. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  4446. {
  4447. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  4448. sendStopTransactionRequest(gun_index);
  4449. clientTime.StopTransaction = time((time_t*)NULL);
  4450. }*/
  4451. //==============================================
  4452. // Charger status notification & Transaction event report
  4453. //==============================================
  4454. //--- Check Mode Change ---//
  4455. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4456. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  4457. {
  4458. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4459. {
  4460. tempIndex = ((gun_index==2) ? 1: 0);
  4461. }
  4462. else
  4463. {
  4464. tempIndex = gun_index;
  4465. }
  4466. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4467. {
  4468. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4469. {
  4470. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4471. {
  4472. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4473. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4474. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4475. if((SystemInitial == 0) &&
  4476. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4477. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4478. {
  4479. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4480. }
  4481. }
  4482. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4483. {
  4484. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4485. if((access(filenmae,F_OK))!=-1)
  4486. {
  4487. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4488. sprintf(str,"rm -f %s",filenmae);
  4489. system(str);
  4490. }
  4491. }
  4492. #if 1 // for TempStopTransaction
  4493. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4494. {
  4495. checkTempStopTransaction(gun_index);
  4496. }
  4497. #endif
  4498. }
  4499. }
  4500. }
  4501. else if(gunType[gun_index] == GUN_TYPE_CCS)
  4502. {
  4503. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4504. {
  4505. tempIndex = ((gun_index==2) ? 1: 0);
  4506. }
  4507. else
  4508. {
  4509. tempIndex = gun_index;
  4510. }
  4511. for (int index = 0; index < CCS_QUANTITY; index++)
  4512. {
  4513. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4514. {
  4515. 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]*/ )
  4516. {
  4517. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4518. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4519. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4520. if((SystemInitial == 0) &&
  4521. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4522. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4523. {
  4524. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4525. }
  4526. }
  4527. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4528. {
  4529. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4530. if((access(filenmae,F_OK))!=-1)
  4531. {
  4532. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4533. sprintf(str,"rm -f %s",filenmae);
  4534. system(str);
  4535. }
  4536. }
  4537. #if 1 // for TempStopTransaction
  4538. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4539. {
  4540. checkTempStopTransaction(gun_index);
  4541. }
  4542. #endif
  4543. }
  4544. }
  4545. }
  4546. else if(gunType[gun_index] == GUN_TYPE_GBT)
  4547. {
  4548. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4549. {
  4550. tempIndex = ((gun_index==2) ? 1: 0);
  4551. }
  4552. else
  4553. {
  4554. tempIndex = gun_index;
  4555. }
  4556. for (int index = 0; index < GB_QUANTITY; index++)
  4557. {
  4558. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4559. {
  4560. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4561. {
  4562. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4563. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4564. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4565. if((SystemInitial == 0) &&
  4566. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4567. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4568. {
  4569. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4570. }
  4571. }
  4572. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4573. {
  4574. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4575. if((access(filenmae,F_OK))!=-1)
  4576. {
  4577. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4578. sprintf(str,"rm -f %s",filenmae);
  4579. system(str);
  4580. }
  4581. }
  4582. #if 1 // for TempStopTransaction
  4583. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4584. {
  4585. checkTempStopTransaction(gun_index);
  4586. }
  4587. #endif
  4588. }
  4589. }
  4590. }
  4591. else if(gunType[gun_index] == GUN_TYPE_DO)
  4592. {
  4593. tempIndex = gun_index;
  4594. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4595. {
  4596. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4597. {
  4598. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4599. {
  4600. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4601. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4602. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4603. if((SystemInitial == 0) &&
  4604. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING) &&
  4605. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE))
  4606. {
  4607. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4608. }
  4609. }
  4610. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4611. {
  4612. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4613. if((access(filenmae,F_OK))!=-1)
  4614. {
  4615. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4616. sprintf(str,"rm -f %s",filenmae);
  4617. system(str);
  4618. }
  4619. }
  4620. #if 1 // for TempStopTransaction
  4621. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4622. {
  4623. checkTempStopTransaction(gun_index);
  4624. }
  4625. #endif
  4626. }
  4627. }
  4628. }
  4629. else
  4630. {
  4631. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4632. {
  4633. tempIndex = 2;
  4634. }
  4635. else
  4636. {
  4637. tempIndex = gun_index;
  4638. }
  4639. for (int index = 0; index < AC_QUANTITY; index++)
  4640. {
  4641. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4642. {
  4643. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4644. {
  4645. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4646. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4647. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4648. if((SystemInitial == 0) &&
  4649. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4650. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4651. {
  4652. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4653. }
  4654. }
  4655. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4656. {
  4657. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4658. if((access(filenmae,F_OK))!=-1)
  4659. {
  4660. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4661. sprintf(str,"rm -f %s",filenmae);
  4662. system(str);
  4663. }
  4664. }
  4665. #if 1 // for TempStopTransaction
  4666. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4667. {
  4668. checkTempStopTransaction(gun_index);
  4669. }
  4670. #endif
  4671. }
  4672. }// END
  4673. }
  4674. if(isWebsocketSendable &&
  4675. (cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) &&
  4676. ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 5) )
  4677. {
  4678. if(SystemInitial > 0)
  4679. SystemInitial -= 1;
  4680. sendStatusNotificationRequest(gun_index);
  4681. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4682. }
  4683. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  4684. {
  4685. sendTransactionEventRequest(gun_index);
  4686. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  4687. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  4688. }
  4689. //==============================================
  4690. // Meter report
  4691. //==============================================
  4692. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  4693. {
  4694. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4695. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  4696. }
  4697. // ClockAlign MeterValue
  4698. 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))
  4699. {
  4700. //check Transaction active
  4701. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  4702. {
  4703. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4704. {
  4705. tempIndex = ((gun_index==2) ? 1: 0);
  4706. }
  4707. else
  4708. {
  4709. tempIndex = gun_index;
  4710. }
  4711. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4712. {
  4713. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4714. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4715. {
  4716. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4717. {
  4718. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4719. }
  4720. }
  4721. }// End for CHAdeMO
  4722. }
  4723. else if(gunType[gun_index] == GUN_TYPE_CCS)
  4724. {
  4725. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4726. {
  4727. tempIndex = ((gun_index==2) ? 1: 0);
  4728. }
  4729. else
  4730. {
  4731. tempIndex = gun_index;
  4732. }
  4733. for (int index = 0; index < CCS_QUANTITY; index++)
  4734. {
  4735. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4736. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4737. {
  4738. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4739. {
  4740. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4741. }
  4742. }
  4743. } // End for CCS
  4744. }
  4745. else if(gunType[gun_index] == GUN_TYPE_GBT)
  4746. {
  4747. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4748. {
  4749. tempIndex = ((gun_index==2) ? 1: 0);
  4750. }
  4751. else
  4752. {
  4753. tempIndex = gun_index;
  4754. }
  4755. for (int index = 0; index < GB_QUANTITY; index++)
  4756. {
  4757. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4758. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4759. {
  4760. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4761. {
  4762. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4763. }
  4764. }
  4765. }// End for GB
  4766. }
  4767. else if(gunType[gun_index] == GUN_TYPE_DO)
  4768. {
  4769. tempIndex = gun_index;
  4770. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4771. {
  4772. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4773. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4774. {
  4775. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_CHARGING)
  4776. {
  4777. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4778. }
  4779. }
  4780. }
  4781. }
  4782. else
  4783. {
  4784. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4785. {
  4786. tempIndex = 2;
  4787. }
  4788. else
  4789. {
  4790. tempIndex = gun_index;
  4791. }
  4792. for (int index = 0; index < AC_QUANTITY; index++)
  4793. {
  4794. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4795. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4796. {
  4797. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4798. {
  4799. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4800. }
  4801. }
  4802. }//End for AC
  4803. }
  4804. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  4805. {
  4806. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  4807. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  4808. }
  4809. }
  4810. // Sample period MeterValue
  4811. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)))
  4812. {
  4813. //check Transaction active
  4814. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  4815. {
  4816. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4817. {
  4818. tempIndex = ((gun_index==2) ? 1: 0);
  4819. }
  4820. else
  4821. {
  4822. tempIndex = gun_index;
  4823. }
  4824. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4825. {
  4826. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4827. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4828. {
  4829. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4830. {
  4831. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4832. }
  4833. }
  4834. }// End for CHAdeMO
  4835. }
  4836. else if(gunType[gun_index] == GUN_TYPE_CCS)
  4837. {
  4838. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4839. {
  4840. tempIndex = ((gun_index==2) ? 1: 0);
  4841. }
  4842. else
  4843. {
  4844. tempIndex = gun_index;
  4845. }
  4846. for (int index = 0; index < CCS_QUANTITY; index++)
  4847. {
  4848. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4849. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4850. {
  4851. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4852. {
  4853. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4854. }
  4855. }
  4856. } // End for CCS
  4857. }
  4858. else if(gunType[gun_index] == GUN_TYPE_GBT)
  4859. {
  4860. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4861. {
  4862. tempIndex = ((gun_index==2) ? 1: 0);
  4863. }
  4864. else
  4865. {
  4866. tempIndex = gun_index;
  4867. }
  4868. for (int index = 0; index < GB_QUANTITY; index++)
  4869. {
  4870. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4871. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4872. {
  4873. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4874. {
  4875. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4876. }
  4877. }
  4878. }// End for GB
  4879. }
  4880. else if(gunType[gun_index] == GUN_TYPE_DO)
  4881. {
  4882. tempIndex = gun_index;
  4883. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4884. {
  4885. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4886. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4887. {
  4888. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  4889. {
  4890. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4891. }
  4892. }
  4893. }
  4894. }
  4895. else
  4896. {
  4897. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4898. {
  4899. tempIndex = 2;
  4900. }
  4901. else
  4902. {
  4903. tempIndex = gun_index;
  4904. }
  4905. for (int index = 0; index < AC_QUANTITY; index++)
  4906. {
  4907. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4908. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4909. {
  4910. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4911. {
  4912. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4913. }
  4914. }
  4915. }//End for AC
  4916. }
  4917. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  4918. {
  4919. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  4920. storeTempStopTransaction(gun_index);
  4921. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  4922. }
  4923. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4924. }
  4925. //==============================================
  4926. // Check Connector reserved
  4927. //==============================================
  4928. //===============================
  4929. // Check if Reserve is expired
  4930. //===============================
  4931. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  4932. {
  4933. double diff_t;
  4934. struct tm tp;
  4935. // current time
  4936. time_t t = time(NULL);
  4937. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  4938. tp.tm_isdst = -1;
  4939. time_t utc = mktime(&tp);
  4940. diff_t = difftime(utc, t);
  4941. if(diff_t <= 0)
  4942. {
  4943. DEBUG_INFO("reserve expired.\n");
  4944. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  4945. }
  4946. }//END OF Check if Reserve is expired
  4947. //==========================================
  4948. // csu trigger FirmwareStatusNotificationReq
  4949. //==========================================
  4950. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  4951. {
  4952. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  4953. }
  4954. //==========================================
  4955. // csu cleared charging limit request
  4956. //==========================================
  4957. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq == ON))
  4958. {
  4959. sendClearedChargingLimitRequest(gun_index);
  4960. }
  4961. //==========================================
  4962. // csu trigger CancelReservationConf
  4963. //==========================================
  4964. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  4965. {
  4966. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  4967. }
  4968. //==========================================
  4969. // csu notify EV charging need request
  4970. //==========================================
  4971. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq == ON))
  4972. {
  4973. sendNotifyEVChargingNeedsRequest(gun_index);
  4974. }
  4975. //==========================================
  4976. // csu trigger ChangeAvailabilityConf
  4977. //==========================================
  4978. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  4979. {
  4980. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  4981. }
  4982. //==========================================
  4983. // csu trigger UnlockConnectorConf
  4984. //==========================================
  4985. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  4986. {
  4987. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  4988. }
  4989. //==========================================
  4990. // csu trigger ReserveNowConf
  4991. //==========================================
  4992. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  4993. {
  4994. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  4995. }
  4996. }
  4997. }
  4998. //==========================================
  4999. // send request routine
  5000. //==========================================
  5001. int sendAuthorizeRequest(int gun_index)
  5002. {
  5003. mtrace();
  5004. int result = FAIL;
  5005. char message[4096]={0};
  5006. char guid[37];
  5007. char tempdata[128]={0};
  5008. json_object *Authorize = json_object_new_object();
  5009. json_object *idToken = json_object_new_object();
  5010. DEBUG_INFO("sendAuthorizeRequest...\n");
  5011. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  5012. //Local Authorize
  5013. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  5014. {
  5015. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  5016. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  5017. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  5018. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  5019. result = PASS;
  5020. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5021. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  5022. authorizeRetryTimes = 0;
  5023. return result;
  5024. }
  5025. 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)) ||
  5026. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  5027. {
  5028. // Query idtag from cache
  5029. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  5030. // Query idtag from list
  5031. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  5032. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  5033. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  5034. {
  5035. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  5036. {
  5037. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  5038. }
  5039. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  5040. {
  5041. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  5042. }
  5043. // Return authorize result if does not connect to server
  5044. if(!ShmOCPP20Data->OcppConnStatus)
  5045. {
  5046. DEBUG_INFO("Local Authorization Fail.\n");
  5047. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  5048. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  5049. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  5050. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  5051. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5052. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  5053. authorizeRetryTimes = 0;
  5054. return result;
  5055. }
  5056. }
  5057. else
  5058. {
  5059. DEBUG_INFO("Local Authorization get result.\n");
  5060. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  5061. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  5062. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  5063. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  5064. else
  5065. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  5066. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  5067. result = PASS;
  5068. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5069. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  5070. authorizeRetryTimes = 0;
  5071. return result;
  5072. }
  5073. }
  5074. //get data from shared memory
  5075. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  5076. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  5077. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  5078. json_object_object_add(Authorize, "idToken", idToken);
  5079. random_uuid(guid);
  5080. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  5081. json_object_put(Authorize);
  5082. LWS_Send(message);
  5083. sprintf(tempdata, "Authorize,%d", gun_index);
  5084. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5085. {
  5086. result = PASS;
  5087. }
  5088. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5089. return result;
  5090. }
  5091. int sendBootNotificationRequest()
  5092. {
  5093. mtrace();
  5094. int result = FAIL;
  5095. char message[4096]={0};
  5096. char guid[37]={0};
  5097. char tempdata[128]={0};
  5098. json_object *BootNotification = json_object_new_object();
  5099. json_object *chargingStation = json_object_new_object();
  5100. json_object *modem = json_object_new_object();
  5101. DEBUG_INFO("sendBootNotificationRequest...\n");
  5102. // Fill BootNotification fields
  5103. DB_getBooType();
  5104. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  5105. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  5106. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  5107. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  5108. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  5109. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  5110. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  5111. {
  5112. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  5113. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  5114. json_object_object_add(chargingStation, "modem", modem);
  5115. }
  5116. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  5117. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  5118. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  5119. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  5120. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  5121. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  5122. random_uuid(guid);
  5123. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  5124. json_object_put(BootNotification);
  5125. LWS_Send(message);
  5126. sprintf(tempdata, "BootNotification,0");
  5127. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5128. {
  5129. result = PASS;
  5130. }
  5131. return result;
  5132. }
  5133. int sendClearedChargingLimitRequest(int gun_index)
  5134. {
  5135. mtrace();
  5136. int result = FAIL;
  5137. char message[4096]={0};
  5138. char guid[37]={0};
  5139. char tempdata[128]={0};
  5140. json_object *ClearedChargingLimit = json_object_new_object();
  5141. DEBUG_INFO("sendClearedChargingLimitRequest...\n");
  5142. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  5143. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  5144. random_uuid(guid);
  5145. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  5146. json_object_put(ClearedChargingLimit);
  5147. LWS_Send(message);
  5148. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  5149. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5150. {
  5151. result = PASS;
  5152. }
  5153. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  5154. return result;
  5155. }
  5156. int sendDataTransferRequest(int gun_index)
  5157. {
  5158. mtrace();
  5159. char message[1000]={0};
  5160. char guid[37]={0};
  5161. char tempdata[65]={0};
  5162. int result = FAIL;
  5163. DEBUG_INFO("sendDataTransferRequest...\n");
  5164. random_uuid(guid);
  5165. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  5166. MESSAGE_TYPE_CALL,
  5167. guid,
  5168. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  5169. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  5170. ShmOCPP20Data->DataTransfer[gun_index].data);
  5171. LWS_Send(message);
  5172. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  5173. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5174. {
  5175. result = PASS;
  5176. }
  5177. return result;
  5178. }
  5179. int sendFirmwareStatusNotificationRequest(char *status)
  5180. {
  5181. mtrace();
  5182. int result = FAIL;
  5183. char message[110]={0};
  5184. char guid[37]={0};
  5185. char tempdata[65]={0};
  5186. json_object *FirmwareStatusNotification = json_object_new_object();
  5187. DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
  5188. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  5189. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  5190. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  5191. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  5192. random_uuid(guid);
  5193. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  5194. json_object_put(FirmwareStatusNotification);
  5195. LWS_SendNow(message);
  5196. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  5197. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5198. {
  5199. result = PASS;
  5200. }
  5201. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  5202. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  5203. //record status
  5204. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  5205. {
  5206. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  5207. }
  5208. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  5209. {
  5210. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  5211. }
  5212. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  5213. {
  5214. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  5215. }
  5216. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  5217. {
  5218. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  5219. }
  5220. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  5221. {
  5222. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  5223. }
  5224. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  5225. {
  5226. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  5227. }
  5228. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  5229. {
  5230. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  5231. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5232. }
  5233. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  5234. {
  5235. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  5236. }
  5237. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  5238. {
  5239. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  5240. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5241. }
  5242. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  5243. {
  5244. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  5245. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5246. }
  5247. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  5248. {
  5249. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  5250. }
  5251. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  5252. {
  5253. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  5254. }
  5255. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  5256. {
  5257. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  5258. }
  5259. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  5260. {
  5261. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  5262. }
  5263. return result;
  5264. }
  5265. int sendGet15118EVCertificateRequest()
  5266. {
  5267. mtrace();
  5268. int result = FAIL;
  5269. char message[4096]={0};
  5270. char guid[37]={0};
  5271. char tempdata[128]={0};
  5272. json_object *Get15118EVCertificate = json_object_new_object();
  5273. DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
  5274. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  5275. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  5276. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  5277. random_uuid(guid);
  5278. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  5279. json_object_put(Get15118EVCertificate);
  5280. LWS_Send(message);
  5281. sprintf(tempdata, "Get15118EVCertificate,0");
  5282. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5283. {
  5284. result = PASS;
  5285. }
  5286. return result;
  5287. }
  5288. int sendGetCertificateStatusRequest()
  5289. {
  5290. mtrace();
  5291. int result = FAIL;
  5292. char message[4096]={0};
  5293. char guid[37]={0};
  5294. char tempdata[128]={0};
  5295. json_object *GetCertificateStatus = json_object_new_object();
  5296. json_object *ocspRequestData = json_object_new_object();
  5297. DEBUG_INFO("sendGetCertificateStatusRequest...\n");
  5298. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  5299. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  5300. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  5301. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  5302. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  5303. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  5304. random_uuid(guid);
  5305. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  5306. json_object_put(GetCertificateStatus);
  5307. LWS_Send(message);
  5308. sprintf(tempdata, "GetCertificateStatus,0");
  5309. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5310. {
  5311. result = PASS;
  5312. }
  5313. return result;
  5314. }
  5315. int sendHeartbeatRequest()
  5316. {
  5317. mtrace();
  5318. int result = FAIL;
  5319. char message[40096]={0};
  5320. char guid[37]={0};
  5321. char tempdata[128]={0};
  5322. DEBUG_INFO("sendHeartbeatRequest...\n");
  5323. random_uuid(guid);
  5324. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  5325. , MESSAGE_TYPE_CALL
  5326. , guid );
  5327. LWS_Send(message);
  5328. sprintf(tempdata, "Heartbeat,%d", 0);
  5329. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5330. {
  5331. result = PASS;
  5332. }
  5333. return result;
  5334. }
  5335. int sendLogStatusNotificationRequest(char *status)
  5336. {
  5337. mtrace();
  5338. int result = FAIL;
  5339. char message[4096]={0};
  5340. char guid[37]={0};
  5341. char tempdata[128]={0};
  5342. json_object *LogStatusNotification = json_object_new_object();
  5343. DEBUG_INFO("sendLogStatusNotificationRequest...\n");
  5344. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  5345. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  5346. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  5347. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  5348. random_uuid(guid);
  5349. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  5350. json_object_put(LogStatusNotification);
  5351. LWS_SendNow(message);
  5352. sprintf(tempdata, "LogStatusNotification,%d", 0);
  5353. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5354. {
  5355. result = PASS;
  5356. }
  5357. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  5358. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  5359. //record status
  5360. if(strcmp(status,"BadMessage")==0)
  5361. {
  5362. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  5363. }
  5364. else if(strcmp(status,"Idle")==0)
  5365. {
  5366. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  5367. }
  5368. else if(strcmp(status,"NotSupportedOperation")==0)
  5369. {
  5370. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  5371. }
  5372. else if(strcmp(status,"PermissionDenied")==0)
  5373. {
  5374. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  5375. }
  5376. else if(strcmp(status,"Uploaded")==0)
  5377. {
  5378. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  5379. }
  5380. else if(strcmp(status,"UploadFailure")==0)
  5381. {
  5382. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  5383. }
  5384. else if(strcmp(status,"Uploading")==0)
  5385. {
  5386. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  5387. }
  5388. return result;
  5389. }
  5390. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  5391. {
  5392. mtrace();
  5393. int result = FAIL;
  5394. char guid[37]={0};
  5395. char tempdata[65]={0};
  5396. int tempIndex = 0;
  5397. json_object *MeterValueReq = json_object_new_object();
  5398. json_object *meterValues = json_object_new_array();
  5399. json_object *sampledValues = json_object_new_array();
  5400. DEBUG_INFO("sendMeterValuesRequest...\n");
  5401. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  5402. //set value
  5403. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  5404. //UTC Date time
  5405. struct timeval tmnow;
  5406. struct tm *tm;
  5407. char buf[28];//, usec_buf[6];
  5408. gettimeofday(&tmnow, NULL);
  5409. time_t t;
  5410. t = time(NULL);
  5411. /*UTC time and date*/
  5412. tm = gmtime(&t);
  5413. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  5414. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  5415. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  5416. //idx_sample=0;
  5417. //********************************(1)Current.Import L1************************************************/
  5418. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5419. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5420. {
  5421. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5422. {
  5423. tempIndex = ((gun_index==2) ? 1: 0);
  5424. }
  5425. else
  5426. {
  5427. tempIndex = gun_index;
  5428. }
  5429. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5430. {
  5431. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5432. {
  5433. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  5434. }
  5435. }
  5436. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5437. }
  5438. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5439. {
  5440. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5441. {
  5442. tempIndex = ((gun_index==2) ? 1: 0);
  5443. }
  5444. else
  5445. {
  5446. tempIndex = gun_index;
  5447. }
  5448. for (int index = 0; index < CCS_QUANTITY; index++)
  5449. {
  5450. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5451. {
  5452. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  5453. }
  5454. }
  5455. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5456. }
  5457. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5458. {
  5459. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5460. {
  5461. tempIndex = ((gun_index==2) ? 1: 0);
  5462. }
  5463. else
  5464. {
  5465. tempIndex = gun_index;
  5466. }
  5467. for (int index = 0; index < GB_QUANTITY; index++)
  5468. {
  5469. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5470. {
  5471. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  5472. }
  5473. }
  5474. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5475. }
  5476. else if(gunType[gun_index] == GUN_TYPE_DO)
  5477. {
  5478. tempIndex = gun_index;
  5479. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5480. {
  5481. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5482. {
  5483. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
  5484. }
  5485. }
  5486. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5487. }
  5488. else
  5489. {
  5490. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5491. {
  5492. tempIndex = 2;
  5493. }
  5494. else
  5495. {
  5496. tempIndex = gun_index;
  5497. }
  5498. for (int index = 0; index < AC_QUANTITY; index++)
  5499. {
  5500. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5501. {
  5502. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  5503. }
  5504. }
  5505. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5506. }
  5507. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  5508. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5509. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5510. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  5511. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  5512. //idx_sample=1;
  5513. //********************************(2)Energy.Active.Import.Register ************************************************/
  5514. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5515. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5516. {
  5517. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5518. {
  5519. tempIndex = ((gun_index==2) ? 1: 0);
  5520. }
  5521. else
  5522. {
  5523. tempIndex = gun_index;
  5524. }
  5525. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5526. {
  5527. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5528. {
  5529. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5530. }
  5531. }
  5532. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5533. }
  5534. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5535. {
  5536. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5537. {
  5538. tempIndex = ((gun_index==2) ? 1: 0);
  5539. }
  5540. else
  5541. {
  5542. tempIndex = gun_index;
  5543. }
  5544. for (int index = 0; index < CCS_QUANTITY; index++)
  5545. {
  5546. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5547. {
  5548. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5549. }
  5550. }
  5551. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5552. }
  5553. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5554. {
  5555. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5556. {
  5557. tempIndex = ((gun_index==2) ? 1: 0);
  5558. }
  5559. else
  5560. {
  5561. tempIndex = gun_index;
  5562. }
  5563. for (int index = 0; index < GB_QUANTITY; index++)
  5564. {
  5565. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5566. {
  5567. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5568. }
  5569. }
  5570. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5571. }
  5572. else if(gunType[gun_index] == GUN_TYPE_DO)
  5573. {
  5574. tempIndex = gun_index;
  5575. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5576. {
  5577. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5578. {
  5579. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5580. }
  5581. }
  5582. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5583. }
  5584. else
  5585. {
  5586. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5587. {
  5588. tempIndex = 2;
  5589. }
  5590. else
  5591. {
  5592. tempIndex = gun_index;
  5593. }
  5594. for (int index = 0; index < AC_QUANTITY; index++)
  5595. {
  5596. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5597. {
  5598. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5599. }
  5600. }
  5601. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5602. }
  5603. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  5604. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  5605. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5606. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  5607. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5608. //idx_sample=2;
  5609. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  5610. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5611. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5612. {
  5613. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5614. {
  5615. tempIndex = ((gun_index==2) ? 1: 0);
  5616. }
  5617. else
  5618. {
  5619. tempIndex = gun_index;
  5620. }
  5621. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5622. {
  5623. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5624. {
  5625. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  5626. }
  5627. } // END OF FOR CHAdeMO_QUANTITY
  5628. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5629. }
  5630. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5631. {
  5632. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5633. {
  5634. tempIndex = ((gun_index==2) ? 1: 0);
  5635. }
  5636. else
  5637. {
  5638. tempIndex = gun_index;
  5639. }
  5640. for (int index = 0; index < CCS_QUANTITY; index++)
  5641. {
  5642. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5643. {
  5644. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  5645. }
  5646. } // END OF CCS_QUANTITY
  5647. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5648. }
  5649. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5650. {
  5651. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5652. {
  5653. tempIndex = ((gun_index==2) ? 1: 0);
  5654. }
  5655. else
  5656. {
  5657. tempIndex = gun_index;
  5658. }
  5659. for (int index = 0; index < GB_QUANTITY; index++)
  5660. {
  5661. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5662. {
  5663. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  5664. }
  5665. } // END OF GB_QUANTITY
  5666. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5667. }
  5668. else if(gunType[gun_index] == GUN_TYPE_DO)
  5669. {
  5670. tempIndex = gun_index;
  5671. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5672. {
  5673. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5674. {
  5675. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
  5676. }
  5677. }
  5678. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5679. }
  5680. else
  5681. {
  5682. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5683. {
  5684. tempIndex = 2;
  5685. }
  5686. else
  5687. {
  5688. tempIndex = gun_index;
  5689. }
  5690. for (int index = 0; index < AC_QUANTITY; index++)
  5691. {
  5692. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5693. {
  5694. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  5695. }
  5696. }
  5697. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5698. }
  5699. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  5700. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  5701. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5702. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  5703. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5704. //idx_sample=3;
  5705. //********************************(4)Power.Active.Import************************************************/
  5706. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5707. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5708. {
  5709. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5710. {
  5711. tempIndex = ((gun_index==2) ? 1: 0);
  5712. }
  5713. else
  5714. {
  5715. tempIndex = gun_index;
  5716. }
  5717. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5718. {
  5719. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5720. {
  5721. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  5722. }
  5723. } // END OF FOR
  5724. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5725. }
  5726. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5727. {
  5728. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5729. {
  5730. tempIndex = ((gun_index==2) ? 1: 0);
  5731. }
  5732. else
  5733. {
  5734. tempIndex = gun_index;
  5735. }
  5736. for (int index = 0; index < CCS_QUANTITY; index++)
  5737. {
  5738. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5739. {
  5740. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  5741. }
  5742. }
  5743. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5744. }
  5745. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5746. {
  5747. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5748. {
  5749. tempIndex = ((gun_index==2) ? 1: 0);
  5750. }
  5751. else
  5752. {
  5753. tempIndex = gun_index;
  5754. }
  5755. for (int index = 0; index < GB_QUANTITY; index++)
  5756. {
  5757. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5758. {
  5759. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5760. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  5761. }
  5762. }
  5763. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5764. }
  5765. else if(gunType[gun_index] == GUN_TYPE_DO)
  5766. {
  5767. tempIndex = gun_index;
  5768. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5769. {
  5770. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5771. {
  5772. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5773. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
  5774. }
  5775. }
  5776. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5777. }
  5778. else
  5779. {
  5780. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5781. {
  5782. tempIndex = 2;
  5783. }
  5784. else
  5785. {
  5786. tempIndex = gun_index;
  5787. }
  5788. for (int index = 0; index < AC_QUANTITY; index++)
  5789. {
  5790. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5791. {
  5792. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  5793. }
  5794. }
  5795. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5796. }
  5797. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  5798. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  5799. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5800. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  5801. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  5802. //idx_sample=4;
  5803. //***********************************************(5)VOLTAGE L1******************************************************/
  5804. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5805. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5806. {
  5807. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5808. {
  5809. tempIndex = ((gun_index==2) ? 1: 0);
  5810. }
  5811. else
  5812. {
  5813. tempIndex = gun_index;
  5814. }
  5815. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5816. {
  5817. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5818. {
  5819. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  5820. }
  5821. }
  5822. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5823. }
  5824. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5825. {
  5826. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5827. {
  5828. tempIndex = ((gun_index==2) ? 1: 0);
  5829. }
  5830. else
  5831. {
  5832. tempIndex = gun_index;
  5833. }
  5834. for (int index = 0; index < CCS_QUANTITY; index++)
  5835. {
  5836. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5837. {
  5838. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  5839. }
  5840. }
  5841. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5842. }
  5843. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5844. {
  5845. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5846. {
  5847. tempIndex = ((gun_index==2) ? 1: 0);
  5848. }
  5849. else
  5850. {
  5851. tempIndex = gun_index;
  5852. }
  5853. for (int index = 0; index < GB_QUANTITY; index++)
  5854. {
  5855. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5856. {
  5857. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  5858. }
  5859. }
  5860. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5861. }
  5862. else if(gunType[gun_index] == GUN_TYPE_DO)
  5863. {
  5864. tempIndex = gun_index;
  5865. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5866. {
  5867. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5868. {
  5869. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
  5870. }
  5871. }
  5872. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5873. }
  5874. else
  5875. {
  5876. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5877. {
  5878. tempIndex = 2;
  5879. }
  5880. else
  5881. {
  5882. tempIndex = gun_index;
  5883. }
  5884. for (int index = 0; index < AC_QUANTITY; index++)
  5885. {
  5886. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5887. {
  5888. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  5889. }
  5890. }
  5891. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5892. }
  5893. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  5894. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5895. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5896. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  5897. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  5898. //***********************************************(6)SOC******************************************************/
  5899. if((gunType[gun_index] == GUN_TYPE_CHAdeMO)||(gunType[gun_index] == GUN_TYPE_CCS)||(gunType[gun_index] == GUN_TYPE_GBT)||(gunType[gun_index] == GUN_TYPE_DO))
  5900. {
  5901. if((ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0') && (gunType[gun_index] != GUN_TYPE_DO))
  5902. {
  5903. tempIndex = ((gun_index==2) ? 1: 0);
  5904. }
  5905. else
  5906. {
  5907. tempIndex = gun_index;
  5908. }
  5909. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5910. {
  5911. //tempIndex = ((gun_index==2) ? 1: 0);
  5912. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5913. {
  5914. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5915. {
  5916. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  5917. }
  5918. }
  5919. }
  5920. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5921. {
  5922. //tempIndex = ((gun_index==2) ? 1: 0);
  5923. for (int index = 0; index < CCS_QUANTITY; index++)
  5924. {
  5925. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5926. {
  5927. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  5928. }
  5929. }
  5930. }
  5931. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5932. {
  5933. //tempIndex = ((gun_index==2) ? 1: 0);
  5934. for (int index = 0; index < GB_QUANTITY; index++)
  5935. {
  5936. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5937. {
  5938. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  5939. }
  5940. }
  5941. }
  5942. else if(gunType[gun_index] == GUN_TYPE_DO)
  5943. {
  5944. //tempIndex = ((gun_index==2) ? 1: 0);
  5945. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5946. {
  5947. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5948. {
  5949. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  5950. }
  5951. }
  5952. }
  5953. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  5954. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  5955. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5956. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  5957. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  5958. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  5959. }
  5960. //********************************(7)Current.Import L2************************************************/
  5961. // Only for AC 3 phase
  5962. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  5963. {
  5964. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5965. {
  5966. tempIndex = 2;
  5967. }
  5968. else
  5969. {
  5970. tempIndex = gun_index;
  5971. }
  5972. for (int index = 0; index < AC_QUANTITY; index++)
  5973. {
  5974. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5975. {
  5976. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  5977. }
  5978. }
  5979. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5980. }
  5981. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  5982. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5983. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5984. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  5985. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  5986. //********************************(8)Current.Import L3************************************************/
  5987. // Only for AC 3 phase
  5988. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  5989. {
  5990. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5991. {
  5992. tempIndex = 2;
  5993. }
  5994. else
  5995. {
  5996. tempIndex = gun_index;
  5997. }
  5998. for (int index = 0; index < AC_QUANTITY; index++)
  5999. {
  6000. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6001. {
  6002. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  6003. }
  6004. }
  6005. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6006. }
  6007. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  6008. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  6009. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6010. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  6011. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  6012. //***********************************************(9)VOLTAGE L2******************************************************/
  6013. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  6014. {
  6015. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6016. {
  6017. tempIndex = 2;
  6018. }
  6019. else
  6020. {
  6021. tempIndex = gun_index;
  6022. }
  6023. for (int index = 0; index < AC_QUANTITY; index++)
  6024. {
  6025. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6026. {
  6027. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  6028. }
  6029. }
  6030. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  6031. }
  6032. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  6033. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  6034. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6035. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  6036. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  6037. //***********************************************(10)VOLTAGE L3******************************************************/
  6038. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  6039. {
  6040. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6041. {
  6042. tempIndex = 2;
  6043. }
  6044. else
  6045. {
  6046. tempIndex = gun_index;
  6047. }
  6048. for (int index = 0; index < AC_QUANTITY; index++)
  6049. {
  6050. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6051. {
  6052. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  6053. }
  6054. }
  6055. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6056. }
  6057. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  6058. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  6059. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6060. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  6061. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  6062. // Message create ====================================================================================================
  6063. random_uuid(guid);
  6064. for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
  6065. {
  6066. json_object *meterValue = json_object_new_object();
  6067. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  6068. {
  6069. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  6070. {
  6071. json_object *sampledValue = json_object_new_object();
  6072. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  6073. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  6074. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  6075. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  6076. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  6077. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  6078. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  6079. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  6080. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  6081. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  6082. {
  6083. json_object *unitOfMeasure = json_object_new_object();
  6084. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  6085. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  6086. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  6087. }
  6088. json_object_array_add(sampledValues, sampledValue);
  6089. }
  6090. }
  6091. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  6092. json_object_object_add(meterValue, "sampledValue", sampledValues);
  6093. json_object_array_add(meterValues, meterValue);
  6094. idxMeter++;
  6095. }
  6096. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  6097. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  6098. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  6099. ,gun_index + 1
  6100. ,MESSAGE_TYPE_CALL
  6101. ,guid
  6102. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  6103. json_object_put(MeterValueReq);
  6104. if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]) == 0) ||
  6105. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]) == 0) ||
  6106. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]) == 0))
  6107. {
  6108. // Transaction meter value send by TransactionEvent message
  6109. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  6110. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  6111. result = PASS;
  6112. }
  6113. else
  6114. {
  6115. // Put request guid to hash map
  6116. sprintf(tempdata, "MeterValues,%d", (gun_index));
  6117. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6118. {
  6119. result = PASS;
  6120. }
  6121. if((dataType != ReadingContextEnumType_Trigger) &&
  6122. (dataType != ReadingContextEnumType_Sample_Clock))
  6123. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  6124. else
  6125. {
  6126. if(FirstHeartBeat)
  6127. LWS_Send(queuedata +2);
  6128. }
  6129. }
  6130. return result;
  6131. }
  6132. int sendNotifyChargingLimitRequest(int gun_index)
  6133. {
  6134. mtrace();
  6135. int result = FAIL;
  6136. char message[4096]={0};
  6137. char guid[37]={0};
  6138. char tempdata[128]={0};
  6139. json_object *NotifyChargingLimit = json_object_new_object();
  6140. json_object *chargingLimit = json_object_new_object();
  6141. DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
  6142. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  6143. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  6144. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  6145. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  6146. random_uuid(guid);
  6147. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  6148. json_object_put(NotifyChargingLimit);
  6149. LWS_Send(message);
  6150. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  6151. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6152. {
  6153. result = PASS;
  6154. }
  6155. return result;
  6156. }
  6157. int sendNotifyCustomerInformationRequest()
  6158. {
  6159. mtrace();
  6160. int result = FAIL;
  6161. char message[4096]={0};
  6162. char guid[37]={0};
  6163. char tempdata[128]={0};
  6164. json_object *NotifyCustomerInformation = json_object_new_object();
  6165. DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
  6166. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  6167. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  6168. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  6169. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  6170. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  6171. random_uuid(guid);
  6172. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  6173. json_object_put(NotifyCustomerInformation);
  6174. LWS_Send(message);
  6175. sprintf(tempdata, "NotifyCustomerInformation,0");
  6176. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6177. {
  6178. result = PASS;
  6179. }
  6180. return result;
  6181. }
  6182. int sendNotifyDisplayMessagesRequest()
  6183. {
  6184. mtrace();
  6185. int result = FAIL;
  6186. char message[4096]={0};
  6187. char guid[37]={0};
  6188. char tempdata[128]={0};
  6189. json_object *NotifyDisplayMessages = json_object_new_object();
  6190. json_object *messageInfos = json_object_new_array();
  6191. DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
  6192. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  6193. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  6194. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  6195. {
  6196. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  6197. {
  6198. json_object *messageInfo = json_object_new_object();
  6199. json_object *message = json_object_new_object();
  6200. json_object *display = json_object_new_object();
  6201. json_object *evse = json_object_new_object();
  6202. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  6203. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  6204. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  6205. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  6206. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  6207. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  6208. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  6209. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  6210. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  6211. json_object_object_add(messageInfo, "message", message);
  6212. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  6213. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  6214. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  6215. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  6216. json_object_object_add(display, "evse",evse);
  6217. json_object_object_add(messageInfo, "evse", display);
  6218. json_object_array_add(messageInfos, messageInfo);
  6219. }
  6220. }
  6221. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  6222. random_uuid(guid);
  6223. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  6224. json_object_put(NotifyDisplayMessages);
  6225. LWS_Send(message);
  6226. sprintf(tempdata, "NotifyDisplayMessages,0");
  6227. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6228. {
  6229. result = PASS;
  6230. }
  6231. return result;
  6232. }
  6233. int sendNotifyEVChargingNeedsRequest(int gun_index)
  6234. {
  6235. mtrace();
  6236. int result = FAIL;
  6237. char message[4096]={0};
  6238. char guid[37]={0};
  6239. char tempdata[128]={0};
  6240. json_object *NotifyEVChargingNeeds = json_object_new_object();
  6241. json_object *chargingNeeds = json_object_new_object();
  6242. json_object *acChargingParameters = json_object_new_object();
  6243. json_object *dcChargingParameters = json_object_new_object();
  6244. DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
  6245. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  6246. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  6247. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  6248. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  6249. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  6250. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  6251. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  6252. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  6253. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  6254. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  6255. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  6256. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  6257. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  6258. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  6259. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  6260. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  6261. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  6262. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  6263. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  6264. random_uuid(guid);
  6265. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  6266. json_object_put(NotifyEVChargingNeeds);
  6267. LWS_Send(message);
  6268. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  6269. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6270. {
  6271. result = PASS;
  6272. }
  6273. return result;
  6274. }
  6275. int sendNotifyEVChargingScheduleRequest(int gun_index)
  6276. {
  6277. mtrace();
  6278. int result = FAIL;
  6279. char message[4096]={0};
  6280. char guid[37]={0};
  6281. char tempdata[128]={0};
  6282. json_object *NotifyEVChargingSchedule = json_object_new_object();
  6283. json_object *chargingSchedule = json_object_new_object();
  6284. json_object *periods = json_object_new_array();
  6285. DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
  6286. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  6287. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  6288. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  6289. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  6290. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  6291. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  6292. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  6293. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  6294. {
  6295. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  6296. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  6297. {
  6298. json_object *Period = json_object_new_object();
  6299. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  6300. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  6301. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  6302. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  6303. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  6304. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  6305. json_object_array_add(periods, Period);
  6306. }
  6307. }
  6308. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  6309. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  6310. random_uuid(guid);
  6311. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  6312. json_object_put(NotifyEVChargingSchedule);
  6313. LWS_Send(message);
  6314. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  6315. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6316. {
  6317. result = PASS;
  6318. }
  6319. return result;
  6320. }
  6321. int sendNotifyEventRequest()
  6322. {
  6323. mtrace();
  6324. int result = FAIL;
  6325. char message[4096]={0};
  6326. char guid[37]={0};
  6327. char tempdata[128]={0};
  6328. json_object *NotifyEvent = json_object_new_object();
  6329. json_object *eventDatas = json_object_new_array();
  6330. DEBUG_INFO("sendNotifyEventRequest...\n");
  6331. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  6332. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  6333. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  6334. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  6335. {
  6336. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  6337. {
  6338. json_object *eventData = json_object_new_object();
  6339. json_object *component = json_object_new_object();
  6340. json_object *evse = json_object_new_object();
  6341. json_object *variable = json_object_new_object();
  6342. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  6343. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  6344. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  6345. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  6346. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  6347. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  6348. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  6349. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  6350. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  6351. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  6352. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  6353. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  6354. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  6355. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  6356. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  6357. json_object_object_add(component, "evse",evse);
  6358. json_object_object_add(eventData, "component", component);
  6359. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  6360. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  6361. json_object_object_add(eventData, "variable", variable);
  6362. json_object_array_add(eventDatas, eventData);
  6363. }
  6364. }
  6365. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  6366. random_uuid(guid);
  6367. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  6368. json_object_put(NotifyEvent);
  6369. LWS_Send(message);
  6370. sprintf(tempdata, "NotifyEvent,0");
  6371. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6372. {
  6373. result = PASS;
  6374. }
  6375. return result;
  6376. }
  6377. int sendNotifyMonitoringReportRequest()
  6378. {
  6379. mtrace();
  6380. int result = FAIL;
  6381. char message[4096]={0};
  6382. char guid[37]={0};
  6383. char tempdata[128]={0};
  6384. json_object *NotifyMonitoringReport = json_object_new_object();
  6385. json_object *monitors = json_object_new_array();
  6386. DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
  6387. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  6388. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  6389. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  6390. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  6391. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  6392. {
  6393. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  6394. {
  6395. json_object *monitor = json_object_new_object();
  6396. json_object *component = json_object_new_object();
  6397. json_object *evse = json_object_new_object();
  6398. json_object *variable = json_object_new_object();
  6399. json_object *variableMonitorings = json_object_new_array();
  6400. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  6401. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  6402. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  6403. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  6404. json_object_object_add(component, "evse",evse);
  6405. json_object_object_add(monitor, "component", component);
  6406. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  6407. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  6408. json_object_object_add(monitor, "variable", variable);
  6409. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  6410. {
  6411. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  6412. {
  6413. json_object *variableMonitoring = json_object_new_object();
  6414. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  6415. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  6416. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  6417. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  6418. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  6419. json_object_array_add(variableMonitorings, variableMonitoring);
  6420. }
  6421. }
  6422. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  6423. json_object_array_add(monitors, monitor);
  6424. }
  6425. }
  6426. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  6427. random_uuid(guid);
  6428. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  6429. json_object_put(NotifyMonitoringReport);
  6430. LWS_Send(message);
  6431. sprintf(tempdata, "NotifyMonitoringReport,0");
  6432. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6433. {
  6434. result = PASS;
  6435. }
  6436. return result;
  6437. }
  6438. int sendNotifyReportRequest()
  6439. {
  6440. mtrace();
  6441. int result = FAIL;
  6442. char message[4096]={0};
  6443. char guid[37]={0};
  6444. char tempdata[128]={0};
  6445. json_object *NotifyReport = json_object_new_object();
  6446. json_object *reportDatas = json_object_new_array();
  6447. DEBUG_INFO("sendNotifyReportRequest...\n");
  6448. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  6449. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  6450. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  6451. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  6452. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  6453. {
  6454. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  6455. {
  6456. json_object *reportData = json_object_new_object();
  6457. json_object *component = json_object_new_object();
  6458. json_object *evse = json_object_new_object();
  6459. json_object *variable = json_object_new_object();
  6460. json_object *variableAttributes = json_object_new_array();
  6461. json_object *variableCharacteristics = json_object_new_object();
  6462. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  6463. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  6464. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  6465. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  6466. json_object_object_add(component, "evse",evse);
  6467. json_object_object_add(reportData, "component", component);
  6468. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  6469. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  6470. json_object_object_add(reportData, "variable",variable);
  6471. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  6472. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  6473. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  6474. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  6475. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  6476. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  6477. {
  6478. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  6479. {
  6480. json_object *variableAttribute = json_object_new_object();
  6481. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  6482. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  6483. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  6484. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  6485. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  6486. json_object_array_add(variableAttributes, variableAttribute);
  6487. }
  6488. }
  6489. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  6490. json_object_array_add(reportDatas, reportData);
  6491. }
  6492. }
  6493. json_object_object_add(NotifyReport, "reportData", reportDatas);
  6494. random_uuid(guid);
  6495. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  6496. json_object_put(NotifyReport);
  6497. LWS_SendNow(message);
  6498. sprintf(tempdata, "NotifyReport,0");
  6499. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6500. {
  6501. result = PASS;
  6502. }
  6503. return result;
  6504. }
  6505. int sendPublishFirmwareStatusNotificationRequest()
  6506. {
  6507. mtrace();
  6508. int result = FAIL;
  6509. char message[4096]={0};
  6510. char guid[37]={0};
  6511. char tempdata[128]={0};
  6512. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  6513. json_object *locations = json_object_new_array();
  6514. DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
  6515. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  6516. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  6517. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  6518. {
  6519. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  6520. }
  6521. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  6522. random_uuid(guid);
  6523. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6524. json_object_put(PublishFirmwareStatusNotification);
  6525. LWS_Send(message);
  6526. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  6527. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6528. {
  6529. result = PASS;
  6530. }
  6531. return result;
  6532. }
  6533. int sendReportChargingProfilesRequest(int gun_index)
  6534. {
  6535. mtrace();
  6536. int result = FAIL;
  6537. char message[4096]={0};
  6538. char guid[37]={0};
  6539. char tempdata[128]={0};
  6540. json_object *ReportChargingProfiles = json_object_new_object();
  6541. json_object *chargingProfiles = json_object_new_array();
  6542. DEBUG_INFO("sendReportChargingProfilesRequest...\n");
  6543. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  6544. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  6545. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  6546. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  6547. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  6548. {
  6549. json_object *chargingProfile = json_object_new_object();
  6550. json_object *chargingSchedules = json_object_new_array();
  6551. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  6552. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  6553. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  6554. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  6555. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  6556. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  6557. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  6558. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  6559. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  6560. {
  6561. json_object *chargingSchedule = json_object_new_object();
  6562. json_object *chargingSchedulePeriods = json_object_new_array();
  6563. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  6564. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  6565. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  6566. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  6567. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  6568. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  6569. {
  6570. json_object *chargingSchedulePeriod = json_object_new_object();
  6571. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  6572. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  6573. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  6574. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  6575. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  6576. }
  6577. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  6578. json_object_array_add(chargingSchedules, chargingSchedule);
  6579. }
  6580. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  6581. json_object_array_add(chargingProfiles, chargingProfile);
  6582. }
  6583. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  6584. random_uuid(guid);
  6585. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6586. json_object_put(ReportChargingProfiles);
  6587. LWS_Send(message);
  6588. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  6589. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6590. {
  6591. result = PASS;
  6592. }
  6593. return result;
  6594. }
  6595. int sendReservationStatusUpdateRequest(int gun_index)
  6596. {
  6597. mtrace();
  6598. int result = FAIL;
  6599. char message[4096]={0};
  6600. char guid[37]={0};
  6601. char tempdata[128]={0};
  6602. json_object *ReservationStatusUpdate = json_object_new_object();
  6603. DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
  6604. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  6605. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  6606. random_uuid(guid);
  6607. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  6608. json_object_put(ReservationStatusUpdate);
  6609. LWS_Send(message);
  6610. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  6611. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6612. {
  6613. result = PASS;
  6614. }
  6615. return result;
  6616. }
  6617. int sendSecurityEventNotificationRequest()
  6618. {
  6619. mtrace();
  6620. int result = FAIL;
  6621. char message[4096]={0};
  6622. char guid[37]={0};
  6623. char tempdata[128]={0};
  6624. json_object *SecurityEventNotification = json_object_new_object();
  6625. DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
  6626. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  6627. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  6628. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techinfo));
  6629. random_uuid(guid);
  6630. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  6631. json_object_put(SecurityEventNotification);
  6632. LWS_Send(message);
  6633. sprintf(tempdata, "SecurityEventNotification,0");
  6634. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6635. {
  6636. result = PASS;
  6637. }
  6638. return result;
  6639. }
  6640. int sendSignCertificateRequest()
  6641. {
  6642. mtrace();
  6643. int result = FAIL;
  6644. char message[4096]={0};
  6645. char guid[37]={0};
  6646. char tempdata[128]={0};
  6647. json_object *SignCertificate = json_object_new_object();
  6648. DEBUG_INFO("sendSignCertificateRequest...\n");
  6649. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  6650. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  6651. random_uuid(guid);
  6652. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  6653. json_object_put(SignCertificate);
  6654. LWS_Send(message);
  6655. sprintf(tempdata, "SignCertificate,0");
  6656. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6657. {
  6658. result = PASS;
  6659. }
  6660. return result;
  6661. }
  6662. int sendStatusNotificationRequest(int gun_index)
  6663. {
  6664. mtrace();
  6665. int result = FAIL;
  6666. char message[600]={0};
  6667. char guid[37];
  6668. int currentStatus = 0;
  6669. struct timeval tmnow;
  6670. struct tm *tm;
  6671. char buf[28];//, usec_buf[6];
  6672. char tempdata[65]={0};
  6673. int tempIndex = 0;
  6674. DEBUG_INFO("sendStatusNotificationRequest...\n");
  6675. gettimeofday(&tmnow, NULL);
  6676. time_t t;
  6677. t = time(NULL);
  6678. /*UTC time and date*/
  6679. tm = gmtime(&t);
  6680. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6681. #if 0 // remove temporally
  6682. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  6683. strcat(buf,".");
  6684. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  6685. strcat(buf,usec_buf);
  6686. #endif
  6687. printf("%s",buf);
  6688. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  6689. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  6690. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  6691. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  6692. /*
  6693. enum _SYSTEM_STATUS
  6694. {
  6695. S_BOOTING = 0,
  6696. S_IDLE, = 1
  6697. S_AUTHORIZING, =2
  6698. S_REASSIGN_CHECK, =3
  6699. S_REASSIGN, =4
  6700. S_PRECHARGE, =5
  6701. S_PREPARING_FOR_EV, =6
  6702. S_PREPARING_FOR_EVSE, =7
  6703. S_CHARGING, =8
  6704. S_TERMINATING, =9
  6705. S_COMPLETE, =10
  6706. S_ALARM, =11
  6707. S_FAULT =12
  6708. }
  6709. */
  6710. //check Transaction active
  6711. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6712. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6713. {
  6714. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6715. {
  6716. tempIndex = ((gun_index==2) ? 1: 0);
  6717. }
  6718. else
  6719. {
  6720. tempIndex = gun_index;
  6721. }
  6722. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6723. {
  6724. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6725. {
  6726. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6727. {
  6728. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6729. {
  6730. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6731. }
  6732. else
  6733. {
  6734. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6735. }
  6736. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6737. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6738. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6739. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6740. }
  6741. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6742. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6743. ) //S_PRECHARGE
  6744. {
  6745. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6746. }
  6747. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6748. {
  6749. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6750. }
  6751. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6752. {
  6753. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6754. }
  6755. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6756. {
  6757. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6758. }
  6759. 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
  6760. {
  6761. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6762. }
  6763. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6764. {
  6765. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6766. }
  6767. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6768. {
  6769. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6770. }
  6771. } //end of the same index
  6772. }//end of for CHAdeMO_QUANTITY
  6773. }
  6774. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6775. {
  6776. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6777. {
  6778. tempIndex = ((gun_index==2) ? 1: 0);
  6779. }
  6780. else
  6781. {
  6782. tempIndex = gun_index;
  6783. }
  6784. for (int index = 0; index < CCS_QUANTITY; index++)
  6785. {
  6786. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6787. {
  6788. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6789. {
  6790. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6791. {
  6792. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6793. }
  6794. else
  6795. {
  6796. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6797. }
  6798. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6799. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6800. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6801. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6802. }
  6803. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6804. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6805. ) //S_PRECHARGE
  6806. {
  6807. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6808. }
  6809. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6810. {
  6811. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6812. }
  6813. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6814. {
  6815. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6816. }
  6817. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  6818. {
  6819. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6820. }
  6821. 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
  6822. {
  6823. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  6824. }
  6825. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6826. {
  6827. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6828. }
  6829. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6830. {
  6831. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6832. }
  6833. } //end of the same index
  6834. } // end of for CCS_QUANTITY
  6835. }
  6836. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6837. {
  6838. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6839. {
  6840. tempIndex = ((gun_index==2) ? 1: 0);
  6841. }
  6842. else
  6843. {
  6844. tempIndex = gun_index;
  6845. }
  6846. for (int index = 0; index < GB_QUANTITY; index++)
  6847. {
  6848. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6849. {
  6850. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6851. {
  6852. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6853. {
  6854. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6855. }
  6856. else
  6857. {
  6858. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6859. }
  6860. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6861. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6862. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6863. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6864. }
  6865. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6866. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6867. ) //S_PRECHARGE
  6868. {
  6869. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6870. }
  6871. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6872. {
  6873. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6874. }
  6875. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6876. {
  6877. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6878. }
  6879. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6880. {
  6881. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6882. }
  6883. 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
  6884. {
  6885. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6886. }
  6887. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6888. {
  6889. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6890. }
  6891. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6892. {
  6893. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6894. }
  6895. } //end of the same index
  6896. } // end of for GB_QUANTITY
  6897. }
  6898. else if(gunType[gun_index] == GUN_TYPE_DO)
  6899. {
  6900. tempIndex = gun_index;
  6901. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6902. {
  6903. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6904. {
  6905. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6906. {
  6907. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6908. {
  6909. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6910. }
  6911. else
  6912. {
  6913. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6914. }
  6915. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6916. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6917. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6918. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6919. }
  6920. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6921. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6922. ) //S_PRECHARGE
  6923. {
  6924. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6925. }
  6926. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6927. {
  6928. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6929. }
  6930. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6931. {
  6932. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6933. }
  6934. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6935. {
  6936. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6937. }
  6938. 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
  6939. {
  6940. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6941. }
  6942. 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
  6943. {
  6944. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6945. }
  6946. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6947. {
  6948. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6949. }
  6950. } //end of the same index
  6951. }
  6952. }
  6953. else
  6954. {
  6955. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6956. {
  6957. tempIndex = 2;
  6958. }
  6959. else
  6960. {
  6961. tempIndex = gun_index;
  6962. }
  6963. for (int index = 0; index < AC_QUANTITY; index++)
  6964. {
  6965. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6966. {
  6967. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  6968. {
  6969. 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))
  6970. {
  6971. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6972. }
  6973. else
  6974. {
  6975. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6976. }
  6977. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6978. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6979. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6980. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6981. }
  6982. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  6983. {
  6984. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6985. }
  6986. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  6987. {
  6988. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6989. }
  6990. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  6991. {
  6992. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6993. }
  6994. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6995. {
  6996. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6997. }
  6998. 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
  6999. {
  7000. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  7001. }
  7002. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7003. {
  7004. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  7005. }
  7006. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7007. {
  7008. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  7009. }
  7010. }//end of the same index
  7011. }//end of for AC_QUANTITY
  7012. }
  7013. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  7014. random_uuid(guid);
  7015. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  7016. , MESSAGE_TYPE_CALL
  7017. , guid
  7018. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  7019. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  7020. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  7021. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  7022. if((server_sign == TRUE))
  7023. {
  7024. LWS_Send(message);
  7025. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  7026. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7027. {
  7028. result = PASS;
  7029. }
  7030. }
  7031. else
  7032. {
  7033. result = PASS;
  7034. }
  7035. return result;
  7036. }
  7037. int sendTransactionEventRequest(int gun_index)
  7038. {
  7039. mtrace();
  7040. int result = FAIL;
  7041. char message[1024*20]={0};
  7042. char guid[37]={0};
  7043. char tempdata[128]={0};
  7044. uint8_t tempIndex;
  7045. json_object *TransactionEvent = json_object_new_object();
  7046. json_object *transactionInfo = json_object_new_object();
  7047. json_object *idToken = json_object_new_object();
  7048. json_object *evse = json_object_new_object();
  7049. json_object *meterValues = json_object_new_array();
  7050. DEBUG_INFO("sendTransactionEventRequest...\n");
  7051. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7052. {
  7053. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7054. {
  7055. tempIndex = ((gun_index==2) ? 1: 0);
  7056. }
  7057. else
  7058. {
  7059. tempIndex = gun_index;
  7060. }
  7061. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7062. {
  7063. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  7064. {
  7065. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7066. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7067. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7068. else
  7069. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7070. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7071. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7072. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7073. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  7074. {
  7075. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7076. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7077. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7078. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7079. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7080. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7081. {
  7082. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7083. }
  7084. else
  7085. {
  7086. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7087. }
  7088. }
  7089. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7090. {
  7091. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7092. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7093. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7094. }
  7095. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7096. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7097. ) //S_PRECHARGE
  7098. {
  7099. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7100. {
  7101. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7102. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  7103. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7104. }
  7105. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7106. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7107. else
  7108. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7109. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7110. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7111. }
  7112. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7113. {
  7114. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7115. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7116. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7117. }
  7118. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7119. {
  7120. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7121. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7122. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7123. }
  7124. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7125. {
  7126. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7127. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7128. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7129. }
  7130. 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
  7131. {
  7132. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7133. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7134. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7135. }
  7136. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7137. {
  7138. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7139. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7140. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7141. }
  7142. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7143. {
  7144. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7145. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7146. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7147. }
  7148. } //end of the same index
  7149. }//end of for CHAdeMO_QUANTITY
  7150. }
  7151. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7152. {
  7153. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7154. {
  7155. tempIndex = ((gun_index==2) ? 1: 0);
  7156. }
  7157. else
  7158. {
  7159. tempIndex = gun_index;
  7160. }
  7161. for (int index = 0; index < CCS_QUANTITY; index++)
  7162. {
  7163. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7164. {
  7165. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7166. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7167. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7168. else
  7169. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7170. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7171. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7172. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7173. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7174. {
  7175. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7176. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7177. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7178. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7179. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7180. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7181. {
  7182. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7183. }
  7184. else
  7185. {
  7186. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7187. }
  7188. }
  7189. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7190. {
  7191. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7192. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7193. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7194. }
  7195. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7196. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7197. ) //S_PRECHARGE
  7198. {
  7199. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7200. {
  7201. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7202. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  7203. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7204. }
  7205. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7206. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7207. else
  7208. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7209. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7210. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7211. }
  7212. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7213. {
  7214. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7215. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7216. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7217. }
  7218. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7219. {
  7220. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7221. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7222. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7223. }
  7224. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7225. {
  7226. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7227. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7228. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7229. }
  7230. 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
  7231. {
  7232. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7233. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7234. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7235. }
  7236. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7237. {
  7238. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7239. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7240. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7241. }
  7242. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7243. {
  7244. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7245. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7246. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7247. }
  7248. } //end of the same index
  7249. } // end of for CCS_QUANTITY
  7250. }
  7251. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7252. {
  7253. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7254. {
  7255. tempIndex = ((gun_index==2) ? 1: 0);
  7256. }
  7257. else
  7258. {
  7259. tempIndex = gun_index;
  7260. }
  7261. for (int index = 0; index < GB_QUANTITY; index++)
  7262. {
  7263. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7264. {
  7265. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7266. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7267. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7268. else
  7269. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7270. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7271. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7272. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7273. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7274. {
  7275. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7276. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7277. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7278. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7279. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7280. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7281. {
  7282. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7283. }
  7284. else
  7285. {
  7286. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7287. }
  7288. }
  7289. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7290. {
  7291. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7292. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7293. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7294. }
  7295. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7296. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7297. ) //S_PRECHARGE
  7298. {
  7299. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7300. {
  7301. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7302. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  7303. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7304. }
  7305. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7306. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7307. else
  7308. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7309. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7310. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7311. }
  7312. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7313. {
  7314. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7315. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7316. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7317. }
  7318. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7319. {
  7320. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7321. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7322. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7323. }
  7324. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7325. {
  7326. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7327. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7328. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7329. }
  7330. 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
  7331. {
  7332. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7333. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7334. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7335. }
  7336. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7337. {
  7338. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7339. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7340. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7341. }
  7342. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7343. {
  7344. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7345. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7346. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7347. }
  7348. } //end of the same index
  7349. } // end of for GB_QUANTITY
  7350. }
  7351. else if(gunType[gun_index] == GUN_TYPE_DO)
  7352. {
  7353. tempIndex = gun_index;
  7354. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7355. {
  7356. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7357. {
  7358. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7359. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7360. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7361. else
  7362. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7363. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7364. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7365. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7366. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7367. {
  7368. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7369. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7370. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7371. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7372. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7373. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7374. {
  7375. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7376. }
  7377. else
  7378. {
  7379. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7380. }
  7381. }
  7382. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7383. {
  7384. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7385. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7386. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7387. }
  7388. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7389. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7390. ) //S_PRECHARGE
  7391. {
  7392. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7393. {
  7394. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7395. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  7396. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7397. }
  7398. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7399. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7400. else
  7401. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7402. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7403. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7404. }
  7405. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7406. {
  7407. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7408. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7409. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7410. }
  7411. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7412. {
  7413. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7414. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7415. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7416. }
  7417. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7418. {
  7419. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7420. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7421. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7422. }
  7423. 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
  7424. {
  7425. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7426. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7427. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7428. }
  7429. 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
  7430. {
  7431. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7432. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7433. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7434. }
  7435. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7436. {
  7437. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7438. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7439. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7440. }
  7441. } //end of the same index
  7442. }
  7443. }
  7444. else
  7445. {
  7446. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7447. {
  7448. tempIndex = 2;
  7449. }
  7450. else
  7451. {
  7452. tempIndex = gun_index;
  7453. }
  7454. for (int index = 0; index < AC_QUANTITY; index++)
  7455. {
  7456. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7457. {
  7458. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7459. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7460. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7461. else
  7462. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7463. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7464. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7465. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7466. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  7467. {
  7468. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7469. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7470. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7471. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7472. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7473. 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))
  7474. {
  7475. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7476. }
  7477. else
  7478. {
  7479. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7480. }
  7481. }
  7482. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7483. {
  7484. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7485. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7486. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7487. }
  7488. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7489. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7490. ) //S_PRECHARGE
  7491. {
  7492. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7493. {
  7494. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7495. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  7496. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7497. }
  7498. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7499. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7500. else
  7501. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7502. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7503. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7504. }
  7505. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7506. {
  7507. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7508. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7509. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7510. }
  7511. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7512. {
  7513. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7514. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7515. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7516. }
  7517. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7518. {
  7519. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7520. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7521. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7522. }
  7523. 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
  7524. {
  7525. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7526. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7527. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7528. }
  7529. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7530. {
  7531. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7532. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7533. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7534. }
  7535. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7536. {
  7537. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7538. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7539. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7540. }
  7541. }//end of the same index
  7542. }//end of for AC_QUANTITY
  7543. }
  7544. // Message
  7545. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7546. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  7547. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  7548. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  7549. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  7550. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  7551. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  7552. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  7553. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  7554. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  7555. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  7556. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  7557. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  7558. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  7559. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  7560. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  7561. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  7562. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  7563. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  7564. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  7565. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  7566. {
  7567. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  7568. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  7569. json_object_object_add(TransactionEvent, "idToken", idToken);
  7570. }
  7571. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  7572. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  7573. json_object_object_add(TransactionEvent, "evse", evse);
  7574. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  7575. {
  7576. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  7577. {
  7578. json_object *meterValue = json_object_new_object();
  7579. json_object *sampledValues = json_object_new_array();
  7580. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  7581. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7582. {
  7583. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  7584. ((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) == 0)))
  7585. {
  7586. json_object *sampledValue = json_object_new_object();
  7587. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7588. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7589. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7590. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  7591. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7592. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  7593. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7594. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  7595. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7596. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  7597. {
  7598. json_object *unitOfMeasure = json_object_new_object();
  7599. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7600. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7601. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7602. }
  7603. json_object_array_add(sampledValues, sampledValue);
  7604. }
  7605. }
  7606. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7607. json_object_array_add(meterValues, meterValue);
  7608. }
  7609. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  7610. }
  7611. random_uuid(guid);
  7612. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  7613. json_object_put(TransactionEvent);
  7614. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  7615. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7616. {
  7617. result = PASS;
  7618. }
  7619. queue_operation(QUEUE_OPERATION_ADD, guid, message);
  7620. return result;
  7621. }
  7622. //==========================================
  7623. // send confirm routine
  7624. //==========================================
  7625. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  7626. {
  7627. mtrace();
  7628. int result = FAIL;
  7629. char message[4096]={0};
  7630. json_object *CancelReservation = json_object_new_object();
  7631. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  7632. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  7633. sprintf(message,"[%d,\"%s\",%s]"
  7634. ,MESSAGE_TYPE_CALLRESULT
  7635. ,uuid
  7636. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  7637. json_object_put(CancelReservation);
  7638. ShmOCPP20Data->CsMsg.bits[0].CancelReservationConf = OFF;
  7639. LWS_Send(message);
  7640. result = TRUE;
  7641. return result;
  7642. }
  7643. int sendCertificateSignedConfirmation(char *uuid)
  7644. {
  7645. mtrace();
  7646. int result = FAIL;
  7647. char message[4096]={0};
  7648. json_object *CertificateSigned = json_object_new_object();
  7649. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  7650. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  7651. sprintf(message,"[%d,\"%s\",%s]"
  7652. ,MESSAGE_TYPE_CALLRESULT
  7653. ,uuid
  7654. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  7655. json_object_put(CertificateSigned);
  7656. LWS_Send(message);
  7657. result = TRUE;
  7658. return result;
  7659. }
  7660. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  7661. {
  7662. mtrace();
  7663. int result = FAIL;
  7664. char message[4096]={0};
  7665. json_object *ChangeAvailability = json_object_new_object();
  7666. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  7667. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  7668. sprintf(message,"[%d,\"%s\",%s]"
  7669. ,MESSAGE_TYPE_CALLRESULT
  7670. ,uuid
  7671. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  7672. json_object_put(ChangeAvailability);
  7673. LWS_Send(message);
  7674. result = TRUE;
  7675. return result;
  7676. }
  7677. int sendClearCacheConfirmation(char *uuid)
  7678. {
  7679. mtrace();
  7680. int result = FAIL;
  7681. char message[4096]={0};
  7682. json_object *ClearCache = json_object_new_object();
  7683. DEBUG_INFO("sendClearCacheConfirmation...\n");
  7684. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  7685. sprintf(message,"[%d,\"%s\",%s]"
  7686. ,MESSAGE_TYPE_CALLRESULT
  7687. ,uuid
  7688. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  7689. json_object_put(ClearCache);
  7690. LWS_Send(message);
  7691. result = TRUE;
  7692. return result;
  7693. }
  7694. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  7695. {
  7696. mtrace();
  7697. int result = FAIL;
  7698. char message[500]={0};
  7699. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  7700. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  7701. LWS_Send(message);
  7702. return result;
  7703. }
  7704. int sendClearDisplayMessageConfirmation(char *uuid)
  7705. {
  7706. mtrace();
  7707. int result = FAIL;
  7708. char message[4096]={0};
  7709. json_object *ClearDisplayMessage = json_object_new_object();
  7710. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  7711. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  7712. sprintf(message,"[%d,\"%s\",%s]"
  7713. ,MESSAGE_TYPE_CALLRESULT
  7714. ,uuid
  7715. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7716. json_object_put(ClearDisplayMessage);
  7717. LWS_Send(message);
  7718. result = TRUE;
  7719. return result;
  7720. }
  7721. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7722. {
  7723. mtrace();
  7724. int result = FAIL;
  7725. char message[4096]={0};
  7726. json_object *ClearVariableMonitoring = json_object_new_object();
  7727. json_object *clearMonitoringResults = json_object_new_array();
  7728. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  7729. for(int idx=0;idx<variableQuantity;idx++)
  7730. {
  7731. json_object *clearMonitoringResult = json_object_new_object();
  7732. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  7733. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  7734. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  7735. }
  7736. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  7737. sprintf(message,"[%d,\"%s\",%s]"
  7738. ,MESSAGE_TYPE_CALLRESULT
  7739. ,uuid
  7740. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7741. json_object_put(ClearVariableMonitoring);
  7742. LWS_Send(message);
  7743. result = TRUE;
  7744. return result;
  7745. }
  7746. int sendCostUpdatedConfirmation(char *uuid)
  7747. {
  7748. mtrace();
  7749. int result = FAIL;
  7750. char message[4096]={0};
  7751. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  7752. sprintf(message,"[%d,\"%s\",{}]"
  7753. ,MESSAGE_TYPE_CALLRESULT
  7754. ,uuid);
  7755. LWS_Send(message);
  7756. result = TRUE;
  7757. return result;
  7758. }
  7759. int sendCustomerInformationConfirmation(char *uuid)
  7760. {
  7761. mtrace();
  7762. int result = FAIL;
  7763. char message[4096]={0};
  7764. json_object *CustomerInformation = json_object_new_object();
  7765. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  7766. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  7767. sprintf(message,"[%d,\"%s\",%s]"
  7768. ,MESSAGE_TYPE_CALLRESULT
  7769. ,uuid
  7770. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  7771. json_object_put(CustomerInformation);
  7772. LWS_Send(message);
  7773. result = TRUE;
  7774. return result;
  7775. }
  7776. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  7777. {
  7778. mtrace();
  7779. int result = FAIL;
  7780. char message[4096]={0};
  7781. json_object *DataTransfer = json_object_new_object();
  7782. DEBUG_INFO("sendDataTransferConfirmation...\n");
  7783. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  7784. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  7785. sprintf(message,"[%d,\"%s\",%s]"
  7786. ,MESSAGE_TYPE_CALLRESULT
  7787. ,uuid
  7788. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  7789. json_object_put(DataTransfer);
  7790. LWS_Send(message);
  7791. result = TRUE;
  7792. return result;
  7793. }
  7794. int sendDeleteCertificateConfirmation(char *uuid)
  7795. {
  7796. mtrace();
  7797. int result = FAIL;
  7798. char message[4096]={0};
  7799. json_object *DeleteCertificate = json_object_new_object();
  7800. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  7801. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  7802. sprintf(message,"[%d,\"%s\",%s]"
  7803. ,MESSAGE_TYPE_CALLRESULT
  7804. ,uuid
  7805. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  7806. json_object_put(DeleteCertificate);
  7807. LWS_Send(message);
  7808. result = TRUE;
  7809. return result;
  7810. }
  7811. int sendGetBaseReportConfirmation(char *uuid)
  7812. {
  7813. mtrace();
  7814. int result = FAIL;
  7815. char message[4096]={0};
  7816. json_object *GetBaseReport = json_object_new_object();
  7817. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  7818. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  7819. sprintf(message,"[%d,\"%s\",%s]"
  7820. ,MESSAGE_TYPE_CALLRESULT
  7821. ,uuid
  7822. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  7823. json_object_put(GetBaseReport);
  7824. LWS_Send(message);
  7825. result = TRUE;
  7826. return result;
  7827. }
  7828. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  7829. {
  7830. mtrace();
  7831. int result = FAIL;
  7832. char message[4096]={0};
  7833. json_object *GetChargingProfiles = json_object_new_object();
  7834. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  7835. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  7836. sprintf(message,"[%d,\"%s\",%s]"
  7837. ,MESSAGE_TYPE_CALLRESULT
  7838. ,uuid
  7839. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  7840. json_object_put(GetChargingProfiles);
  7841. LWS_Send(message);
  7842. result = TRUE;
  7843. return result;
  7844. }
  7845. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  7846. {
  7847. mtrace();
  7848. int result = FAIL;
  7849. char message[4096]={0};
  7850. int CompositeScheduleIndex = 0;
  7851. json_object *GetCompositeSchedule = json_object_new_object();
  7852. json_object *schedule = json_object_new_object();
  7853. json_object *chargingSchedule = json_object_new_object();
  7854. json_object *chargingSchedulePeriod = json_object_new_array();
  7855. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  7856. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  7857. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  7858. if(nPeriod == 0)
  7859. {
  7860. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  7861. {
  7862. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7863. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7864. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7865. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7866. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7867. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7868. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7869. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7870. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7871. {
  7872. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7873. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7874. {
  7875. json_object *Period = json_object_new_object();
  7876. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7877. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7878. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7879. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7880. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7881. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7882. json_object_array_add(chargingSchedulePeriod, Period);
  7883. }
  7884. }
  7885. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7886. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7887. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7888. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7889. }
  7890. }
  7891. else
  7892. {
  7893. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7894. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7895. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7896. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7897. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7898. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7899. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7900. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7901. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7902. {
  7903. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7904. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7905. {
  7906. json_object *Period = json_object_new_object();
  7907. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7908. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7909. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7910. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7911. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7912. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7913. json_object_array_add(chargingSchedulePeriod, Period);
  7914. }
  7915. }
  7916. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7917. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7918. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7919. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7920. }
  7921. sprintf(message,"[%d,\"%s\",%s]"
  7922. ,MESSAGE_TYPE_CALLRESULT
  7923. ,uuid
  7924. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  7925. json_object_put(GetCompositeSchedule);
  7926. LWS_Send(message);
  7927. result = TRUE;
  7928. return result;
  7929. }
  7930. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  7931. {
  7932. mtrace();
  7933. int result = FAIL;
  7934. char message[4096]={0};
  7935. json_object *GetGetDisplayMessages = json_object_new_object();
  7936. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  7937. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  7938. sprintf(message,"[%d,\"%s\",%s]"
  7939. ,MESSAGE_TYPE_CALLRESULT
  7940. ,uuid
  7941. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7942. json_object_put(GetGetDisplayMessages);
  7943. LWS_Send(message);
  7944. result = TRUE;
  7945. return result;
  7946. }
  7947. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  7948. {
  7949. mtrace();
  7950. int result = FAIL;
  7951. char message[4096]={0};
  7952. json_object *GetInstalledCertificateIds = json_object_new_object();
  7953. json_object *certificateHashDataChains = json_object_new_array();
  7954. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  7955. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  7956. for(int idx=0;idx<certQuantity;idx++)
  7957. {
  7958. json_object *cert = json_object_new_object();
  7959. json_object *certificateHashData = json_object_new_object();
  7960. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  7961. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  7962. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  7963. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  7964. json_object_object_add(cert, "certificateHashData", certificateHashData);
  7965. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  7966. json_object_array_add(certificateHashDataChains, cert);
  7967. }
  7968. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  7969. sprintf(message,"[%d,\"%s\",%s]"
  7970. ,MESSAGE_TYPE_CALLRESULT
  7971. ,uuid
  7972. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  7973. json_object_put(GetInstalledCertificateIds);
  7974. LWS_Send(message);
  7975. result = TRUE;
  7976. return result;
  7977. }
  7978. int sendGetLocalListVersionConfirmation(char *uuid)
  7979. {
  7980. mtrace();
  7981. int result = FAIL;
  7982. char message[4096]={0};
  7983. json_object *GetLocalListVersion = json_object_new_object();
  7984. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  7985. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  7986. sprintf(message,"[%d,\"%s\",%s]"
  7987. ,MESSAGE_TYPE_CALLRESULT
  7988. ,uuid
  7989. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  7990. json_object_put(GetLocalListVersion);
  7991. LWS_Send(message);
  7992. result = TRUE;
  7993. return result;
  7994. }
  7995. int sendGetLogConfirmation(char *uuid)
  7996. {
  7997. mtrace();
  7998. int result = FAIL;
  7999. char message[4096]={0};
  8000. json_object *GetLog = json_object_new_object();
  8001. DEBUG_INFO("sendGetLogConfirmation...\n");
  8002. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  8003. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  8004. sprintf(message,"[%d,\"%s\",%s]"
  8005. ,MESSAGE_TYPE_CALLRESULT
  8006. ,uuid
  8007. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  8008. json_object_put(GetLog);
  8009. LWS_Send(message);
  8010. result = TRUE;
  8011. return result;
  8012. }
  8013. int sendGetMonitoringReportConfirmation(char *uuid)
  8014. {
  8015. mtrace();
  8016. int result = FAIL;
  8017. char message[4096]={0};
  8018. json_object *GetMonitoringReport = json_object_new_object();
  8019. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  8020. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  8021. sprintf(message,"[%d,\"%s\",%s]"
  8022. ,MESSAGE_TYPE_CALLRESULT
  8023. ,uuid
  8024. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  8025. json_object_put(GetMonitoringReport);
  8026. LWS_Send(message);
  8027. result = TRUE;
  8028. return result;
  8029. }
  8030. int sendGetReportConfirmation(char *uuid)
  8031. {
  8032. mtrace();
  8033. int result = FAIL;
  8034. char message[4096]={0};
  8035. json_object *GetReport = json_object_new_object();
  8036. DEBUG_INFO("sendGetReportConfirmation...\n");
  8037. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  8038. sprintf(message,"[%d,\"%s\",%s]"
  8039. ,MESSAGE_TYPE_CALLRESULT
  8040. ,uuid
  8041. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  8042. json_object_put(GetReport);
  8043. LWS_Send(message);
  8044. result = TRUE;
  8045. return result;
  8046. }
  8047. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  8048. {
  8049. mtrace();
  8050. int result = FAIL;
  8051. char message[4096]={0};
  8052. json_object *GetTransactionStatus = json_object_new_object();
  8053. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  8054. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  8055. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  8056. sprintf(message,"[%d,\"%s\",%s]"
  8057. ,MESSAGE_TYPE_CALLRESULT
  8058. ,uuid
  8059. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  8060. json_object_put(GetTransactionStatus);
  8061. LWS_Send(message);
  8062. result = TRUE;
  8063. return result;
  8064. }
  8065. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  8066. {
  8067. mtrace();
  8068. int result = FAIL;
  8069. char message[4096]={0};
  8070. json_object *GetVariables = json_object_new_object();
  8071. json_object *getVariableResults = json_object_new_array();
  8072. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  8073. for(int idx=0;idx<variableQuantity;idx++)
  8074. {
  8075. json_object *variableResult = json_object_new_object();
  8076. json_object *component = json_object_new_object();
  8077. json_object *variable = json_object_new_object();
  8078. json_object *evse = json_object_new_object();
  8079. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  8080. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  8081. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  8082. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  8083. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  8084. json_object_object_add(component, "evse", evse);
  8085. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  8086. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  8087. json_object_object_add(variableResult, "component", component);
  8088. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  8089. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  8090. json_object_object_add(variableResult, "variable", variable);
  8091. json_object_array_add(getVariableResults, variableResult);
  8092. }
  8093. json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
  8094. sprintf(message,"[%d,\"%s\",%s]"
  8095. ,MESSAGE_TYPE_CALLRESULT
  8096. ,uuid
  8097. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  8098. json_object_put(GetVariables);
  8099. LWS_Send(message);
  8100. result = TRUE;
  8101. return result;
  8102. }
  8103. int sendInstallCertificateConfirmation(char *uuid)
  8104. {
  8105. mtrace();
  8106. int result = FAIL;
  8107. char message[4096]={0};
  8108. json_object *InstallCertificate = json_object_new_object();
  8109. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  8110. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  8111. sprintf(message,"[%d,\"%s\",%s]"
  8112. ,MESSAGE_TYPE_CALLRESULT
  8113. ,uuid
  8114. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  8115. json_object_put(InstallCertificate);
  8116. LWS_Send(message);
  8117. result = TRUE;
  8118. return result;
  8119. }
  8120. int sendPublishFirmwareConfirmation(char *uuid)
  8121. {
  8122. mtrace();
  8123. int result = FAIL;
  8124. char message[4096]={0};
  8125. json_object *PublishFirmware = json_object_new_object();
  8126. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  8127. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  8128. sprintf(message,"[%d,\"%s\",%s]"
  8129. ,MESSAGE_TYPE_CALLRESULT
  8130. ,uuid
  8131. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  8132. json_object_put(PublishFirmware);
  8133. LWS_Send(message);
  8134. result = TRUE;
  8135. return result;
  8136. }
  8137. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  8138. {
  8139. mtrace();
  8140. int result = FAIL;
  8141. char message[4096]={0};
  8142. json_object *RemoteStartTransaction = json_object_new_object();
  8143. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  8144. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  8145. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  8146. sprintf(message,"[%d,\"%s\",%s]"
  8147. ,MESSAGE_TYPE_CALLRESULT
  8148. ,uuid
  8149. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  8150. json_object_put(RemoteStartTransaction);
  8151. LWS_Send(message);
  8152. result = TRUE;
  8153. return result;
  8154. }
  8155. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  8156. {
  8157. mtrace();
  8158. int result = FAIL;
  8159. char message[4096]={0};
  8160. json_object *RemoteStopTransaction = json_object_new_object();
  8161. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  8162. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  8163. sprintf(message,"[%d,\"%s\",%s]"
  8164. ,MESSAGE_TYPE_CALLRESULT
  8165. ,uuid
  8166. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  8167. json_object_put(RemoteStopTransaction);
  8168. LWS_Send(message);
  8169. result = TRUE;
  8170. return result;
  8171. }
  8172. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  8173. {
  8174. mtrace();
  8175. int result = FAIL;
  8176. char message[4096]={0};
  8177. json_object *ReserveNow = json_object_new_object();
  8178. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  8179. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  8180. sprintf(message,"[%d,\"%s\",%s]"
  8181. ,MESSAGE_TYPE_CALLRESULT
  8182. ,uuid
  8183. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  8184. json_object_put(ReserveNow);
  8185. LWS_Send(message);
  8186. result = TRUE;
  8187. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  8188. return result;
  8189. }
  8190. int sendResetConfirmation(char *uuid)
  8191. {
  8192. mtrace();
  8193. int result = FAIL;
  8194. char message[4096]={0};
  8195. json_object *Reset = json_object_new_object();
  8196. DEBUG_INFO("sendResetConfirmation...\n");
  8197. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  8198. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  8199. sprintf(message,"[%d,\"%s\",%s]"
  8200. ,MESSAGE_TYPE_CALLRESULT
  8201. ,uuid
  8202. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  8203. json_object_put(Reset);
  8204. LWS_Send(message);
  8205. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  8206. {
  8207. DB_updateBootType(BootReasonEnumType_RemoteReset);
  8208. }
  8209. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  8210. {
  8211. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  8212. }
  8213. result = TRUE;
  8214. return result;
  8215. }
  8216. int sendSendLocalListConfirmation(char *uuid)
  8217. {
  8218. mtrace();
  8219. int result = FAIL;
  8220. char message[4096]={0};
  8221. json_object *SendLocalList = json_object_new_object();
  8222. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  8223. sprintf(message,"[%d,\"%s\",%s]"
  8224. ,MESSAGE_TYPE_CALLRESULT
  8225. ,uuid
  8226. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  8227. json_object_put(SendLocalList);
  8228. LWS_Send(message);
  8229. result = TRUE;
  8230. return result;
  8231. }
  8232. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  8233. {
  8234. mtrace();
  8235. int result = FAIL;
  8236. char message[4096]={0};
  8237. json_object *SetChargingProfile = json_object_new_object();
  8238. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  8239. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  8240. sprintf(message,"[%d,\"%s\",%s]"
  8241. ,MESSAGE_TYPE_CALLRESULT
  8242. ,uuid
  8243. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  8244. json_object_put(SetChargingProfile);
  8245. LWS_Send(message);
  8246. result = TRUE;
  8247. return result;
  8248. }
  8249. int sendSetDisplayMessageConfirmation(char *uuid)
  8250. {
  8251. mtrace();
  8252. int result = FAIL;
  8253. char message[4096]={0};
  8254. json_object *SetDisplayMessage = json_object_new_object();
  8255. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  8256. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  8257. sprintf(message,"[%d,\"%s\",%s]"
  8258. ,MESSAGE_TYPE_CALLRESULT
  8259. ,uuid
  8260. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  8261. json_object_put(SetDisplayMessage);
  8262. LWS_Send(message);
  8263. result = TRUE;
  8264. return result;
  8265. }
  8266. int sendSetMonitoringBaseConfirmation(char *uuid)
  8267. {
  8268. mtrace();
  8269. int result = FAIL;
  8270. char message[4096]={0};
  8271. json_object *SetMonitoringBase = json_object_new_object();
  8272. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  8273. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  8274. sprintf(message,"[%d,\"%s\",%s]"
  8275. ,MESSAGE_TYPE_CALLRESULT
  8276. ,uuid
  8277. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  8278. json_object_put(SetMonitoringBase);
  8279. LWS_Send(message);
  8280. result = TRUE;
  8281. return result;
  8282. }
  8283. int sendSetMonitoringLevelConfirmation(char *uuid)
  8284. {
  8285. mtrace();
  8286. int result = FAIL;
  8287. char message[4096]={0};
  8288. json_object *SetMonitoringLevel = json_object_new_object();
  8289. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  8290. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  8291. sprintf(message,"[%d,\"%s\",%s]"
  8292. ,MESSAGE_TYPE_CALLRESULT
  8293. ,uuid
  8294. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  8295. json_object_put(SetMonitoringLevel);
  8296. LWS_Send(message);
  8297. result = TRUE;
  8298. return result;
  8299. }
  8300. int sendSetNetworkProfileConfirmation(char *uuid)
  8301. {
  8302. mtrace();
  8303. int result = FAIL;
  8304. char message[4096]={0};
  8305. json_object *SetNetworkProfile = json_object_new_object();
  8306. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  8307. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  8308. sprintf(message,"[%d,\"%s\",%s]"
  8309. ,MESSAGE_TYPE_CALLRESULT
  8310. ,uuid
  8311. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  8312. json_object_put(SetNetworkProfile);
  8313. LWS_Send(message);
  8314. result = TRUE;
  8315. return result;
  8316. }
  8317. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  8318. {
  8319. mtrace();
  8320. int result = FAIL;
  8321. char message[4096]={0};
  8322. json_object *SetVariableMonitoring = json_object_new_object();
  8323. json_object *setMonitoringResults = json_object_new_array();
  8324. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  8325. for(int idx=0;idx<variableQuantity;idx++)
  8326. {
  8327. json_object *variableMonitorResult = json_object_new_object();
  8328. json_object *component = json_object_new_object();
  8329. json_object *variable = json_object_new_object();
  8330. json_object *evse = json_object_new_object();
  8331. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  8332. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  8333. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  8334. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  8335. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  8336. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  8337. json_object_object_add(component, "component", evse);
  8338. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  8339. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  8340. json_object_object_add(variableMonitorResult, "component", component);
  8341. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  8342. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  8343. json_object_object_add(variableMonitorResult, "variable", variable);
  8344. json_object_array_add(setMonitoringResults, variableMonitorResult);
  8345. }
  8346. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  8347. sprintf(message,"[%d,\"%s\",%s]"
  8348. ,MESSAGE_TYPE_CALLRESULT
  8349. ,uuid
  8350. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  8351. json_object_put(SetVariableMonitoring);
  8352. LWS_Send(message);
  8353. result = TRUE;
  8354. return result;
  8355. }
  8356. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  8357. {
  8358. mtrace();
  8359. int result = FAIL;
  8360. char message[4096]={0};
  8361. json_object *SetVariable = json_object_new_object();
  8362. json_object *setVariableResults = json_object_new_array();
  8363. DEBUG_INFO("sendSetVariableConfirmation...\n");
  8364. for(int idx=0;idx<variableQuantity;idx++)
  8365. {
  8366. json_object *variableResult = json_object_new_object();
  8367. json_object *component = json_object_new_object();
  8368. json_object *variable = json_object_new_object();
  8369. json_object *evse = json_object_new_object();
  8370. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  8371. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  8372. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  8373. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  8374. json_object_object_add(component, "component", evse);
  8375. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  8376. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  8377. json_object_object_add(variableResult, "component", component);
  8378. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  8379. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  8380. json_object_object_add(variableResult, "variable", variable);
  8381. json_object_array_add(setVariableResults, variableResult);
  8382. }
  8383. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  8384. sprintf(message,"[%d,\"%s\",%s]"
  8385. ,MESSAGE_TYPE_CALLRESULT
  8386. ,uuid
  8387. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  8388. json_object_put(SetVariable);
  8389. LWS_Send(message);
  8390. result = TRUE;
  8391. return result;
  8392. }
  8393. int sendTriggerMessageConfirmation(char *uuid)
  8394. {
  8395. mtrace();
  8396. int result = FAIL;
  8397. char message[4096]={0};
  8398. json_object *TriggerMessage = json_object_new_object();
  8399. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  8400. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  8401. sprintf(message,"[%d,\"%s\",%s]",
  8402. MESSAGE_TYPE_CALLRESULT,
  8403. uuid,
  8404. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  8405. json_object_put(TriggerMessage);
  8406. LWS_Send(message);
  8407. result = TRUE;
  8408. return result;
  8409. }
  8410. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  8411. {
  8412. mtrace();
  8413. int result = FAIL;
  8414. char message[4096]={0};
  8415. json_object *UnlockConnector = json_object_new_object();
  8416. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  8417. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  8418. sprintf(message,"[%d,\"%s\",%s]",
  8419. MESSAGE_TYPE_CALLRESULT,
  8420. uuid,
  8421. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  8422. json_object_put(UnlockConnector);
  8423. LWS_Send(message);
  8424. result = TRUE;
  8425. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  8426. return result;
  8427. }
  8428. int sendUnpublishFirmwareConfirmation(char *uuid)
  8429. {
  8430. mtrace();
  8431. int result = FAIL;
  8432. char message[4096]={0};
  8433. json_object *UnpublishFirmware = json_object_new_object();
  8434. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  8435. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  8436. sprintf(message,"[%d,\"%s\",%s]"
  8437. ,MESSAGE_TYPE_CALLRESULT
  8438. ,uuid
  8439. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  8440. json_object_put(UnpublishFirmware);
  8441. LWS_Send(message);
  8442. result = TRUE;
  8443. return result;
  8444. }
  8445. int sendUpdateFirmwareConfirmation(char *uuid)
  8446. {
  8447. mtrace();
  8448. int result = FAIL;
  8449. char message[4096]={0};
  8450. json_object *UpdateFirmware = json_object_new_object();
  8451. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  8452. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  8453. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  8454. sprintf(message,"[%d,\"%s\",%s]"
  8455. ,MESSAGE_TYPE_CALLRESULT
  8456. ,uuid
  8457. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  8458. json_object_put(UpdateFirmware);
  8459. LWS_Send(message);
  8460. result = TRUE;
  8461. return result;
  8462. }
  8463. //==========================================
  8464. // send CallError routine
  8465. //==========================================
  8466. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  8467. {
  8468. mtrace();
  8469. char message[220]={0};
  8470. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  8471. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  8472. LWS_Send(message);
  8473. }
  8474. //==========================================
  8475. // Handle server request routine Start
  8476. //==========================================
  8477. int handleCancelReservationRequest(char *uuid, char *payload)
  8478. {
  8479. mtrace();
  8480. int result = FAIL;
  8481. int gunNO = 0;
  8482. int reservationIdInt = -1;
  8483. DEBUG_INFO("handleCancelReservationRequest...\n");
  8484. json_object *CancelReservation;
  8485. CancelReservation = json_tokener_parse(payload);
  8486. if(!is_error(CancelReservation))
  8487. {
  8488. // Required data
  8489. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  8490. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  8491. }
  8492. json_object_put(CancelReservation);
  8493. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  8494. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  8495. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  8496. if(reservationIdInt != -1)
  8497. {
  8498. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  8499. //check Transaction active
  8500. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8501. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8502. {
  8503. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  8504. {
  8505. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8506. if(gunType[2] == GUN_TYPE_CHAdeMO)
  8507. {
  8508. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  8509. }
  8510. else
  8511. {
  8512. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  8513. }
  8514. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8515. goto end;
  8516. }
  8517. }
  8518. for (int index = 0; index < CCS_QUANTITY; index++)
  8519. {
  8520. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  8521. {
  8522. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8523. if(gunType[2] == GUN_TYPE_CCS)
  8524. {
  8525. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  8526. }
  8527. else
  8528. {
  8529. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  8530. }
  8531. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8532. goto end;
  8533. }
  8534. }
  8535. for (int index = 0; index < GB_QUANTITY; index++)
  8536. {
  8537. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  8538. {
  8539. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8540. if(gunType[2] == GUN_TYPE_GBT)
  8541. {
  8542. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  8543. }
  8544. else
  8545. {
  8546. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8547. }
  8548. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8549. goto end;
  8550. }
  8551. }
  8552. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8553. {
  8554. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId == reservationIdInt)
  8555. {
  8556. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8557. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8558. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8559. goto end;
  8560. }
  8561. }
  8562. for (int index = 0; index < AC_QUANTITY; index++)
  8563. {
  8564. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  8565. {
  8566. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8567. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8568. {
  8569. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  8570. }
  8571. else
  8572. {
  8573. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  8574. }
  8575. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8576. goto end;
  8577. }
  8578. }
  8579. }
  8580. //The reservationId does NOT match the reservationId
  8581. sendCancelReservationConfirmation(uuid, gunNO);
  8582. end:
  8583. // Fill in ocpp packet uuid
  8584. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  8585. return result;
  8586. }
  8587. int handleCertificateSignedRequest(char *uuid, char *payload)
  8588. {
  8589. mtrace();
  8590. int result = FAIL;
  8591. json_object *CertificateSigned;
  8592. DEBUG_INFO("handleCertificateSignedRequest...\n");
  8593. CertificateSigned = json_tokener_parse(payload);
  8594. if(!is_error(CertificateSigned))
  8595. {
  8596. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  8597. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  8598. // Required data
  8599. if(json_object_array_length(json_object_object_get(CertificateSigned, "certificate")) <= ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.certificate))
  8600. {
  8601. for(int idx=0;idx<json_object_array_length(json_object_object_get(CertificateSigned, "certificate"));idx++)
  8602. {
  8603. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificate[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateType"), idx)));
  8604. /*
  8605. * TODO:
  8606. * 1. Certificate install response
  8607. */
  8608. }
  8609. }
  8610. // Optional data
  8611. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  8612. {
  8613. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  8614. if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]) == 0)
  8615. {
  8616. }
  8617. else if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0)
  8618. {
  8619. }
  8620. else
  8621. {
  8622. }
  8623. }
  8624. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  8625. }
  8626. else
  8627. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  8628. json_object_put(CertificateSigned);
  8629. sendCertificateSignedConfirmation(uuid);
  8630. return result;
  8631. }
  8632. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  8633. {
  8634. mtrace();
  8635. int result = FAIL;
  8636. int evseId = 0, gunIndex = 0;
  8637. char operationalStatus[16]={0};
  8638. char comfirmstr[20];
  8639. int specificId = FALSE;
  8640. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  8641. json_object *ChangeAvailability;
  8642. ChangeAvailability = json_tokener_parse(payload);
  8643. if(!is_error(ChangeAvailability))
  8644. {
  8645. // Required data
  8646. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  8647. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  8648. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  8649. {
  8650. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  8651. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  8652. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  8653. }
  8654. }
  8655. json_object_put(ChangeAvailability);
  8656. if((evseId != 0) && (evseId <= gunTotalNumber))
  8657. {
  8658. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  8659. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  8660. }
  8661. else if(evseId == 0)
  8662. {
  8663. for(int i=0; i < gunTotalNumber; i++)
  8664. {
  8665. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  8666. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8667. }
  8668. }
  8669. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8670. {
  8671. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  8672. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  8673. }
  8674. else if(gunIndex == 0)
  8675. {
  8676. for(int i=0; i < gunTotalNumber; i++)
  8677. {
  8678. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  8679. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8680. }
  8681. }
  8682. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  8683. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8684. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  8685. {
  8686. specificId = TRUE;
  8687. }
  8688. if(specificId == FALSE)
  8689. goto end;
  8690. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  8691. {
  8692. //----------------------gunIndex is 0 ------------------------------------------------//
  8693. if(gunIndex == 0)
  8694. {
  8695. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8696. {
  8697. for(int i=0; i < gunTotalNumber; i++)
  8698. {
  8699. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8700. {
  8701. if ((gunType[i] == GUN_TYPE_CHAdeMO)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  8702. {
  8703. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8704. {
  8705. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8706. goto end;
  8707. }
  8708. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8709. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8710. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8711. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8712. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8713. {
  8714. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8715. goto end;
  8716. }
  8717. }
  8718. }//END FOR CHAdeMO_QUANTITY
  8719. for (int index = 0; index < CCS_QUANTITY; index++)
  8720. {
  8721. if ((gunType[i] == GUN_TYPE_CCS)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  8722. {
  8723. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  8724. {
  8725. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8726. goto end;
  8727. }
  8728. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8729. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8730. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8731. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8732. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8733. {
  8734. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8735. goto end;
  8736. }
  8737. }
  8738. }//END FOR CCS_QUANTITY
  8739. for (int index = 0; index < GB_QUANTITY; index++)
  8740. {
  8741. if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  8742. {
  8743. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8744. {
  8745. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8746. goto end;
  8747. }
  8748. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8749. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8750. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8751. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8752. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8753. {
  8754. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8755. goto end;
  8756. }
  8757. }
  8758. }// END FOR GB_QUANTITY
  8759. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8760. {
  8761. if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i))
  8762. {
  8763. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8764. {
  8765. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8766. goto end;
  8767. }
  8768. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  8769. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  8770. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  8771. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  8772. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8773. {
  8774. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8775. goto end;
  8776. }
  8777. }
  8778. }// END FOR DO_QUANTITY
  8779. for (int index = 0; index < AC_QUANTITY; index++)
  8780. {
  8781. if ((gunType[i] == GUN_TYPE_AC)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  8782. {
  8783. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8784. {
  8785. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8786. goto end;
  8787. }
  8788. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8789. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8790. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8791. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8792. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8793. {
  8794. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8795. goto end;
  8796. }
  8797. }
  8798. }//END FOR AC_QUANTITY
  8799. }// END FOR gunTotalNumber
  8800. }
  8801. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8802. {
  8803. for(int i=0; i < gunTotalNumber; i++)
  8804. {
  8805. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8806. {
  8807. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8808. goto end;
  8809. }
  8810. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8811. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  8812. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  8813. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  8814. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8815. {
  8816. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8817. goto end;
  8818. }
  8819. }
  8820. }
  8821. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8822. goto end;
  8823. }
  8824. //----------------------gunIndex is not 0 ------------------------------------------------//
  8825. //check Transaction active
  8826. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8827. {
  8828. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO))
  8829. {
  8830. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  8831. {
  8832. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8833. goto end;
  8834. }
  8835. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8836. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8837. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8838. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8839. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8840. {
  8841. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8842. goto end;
  8843. }
  8844. else
  8845. {
  8846. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  8847. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8848. goto end;
  8849. }
  8850. }
  8851. }//END FOR CHAdeMO_QUANTITY
  8852. for (int index = 0; index < CCS_QUANTITY; index++)
  8853. {
  8854. if ((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS))
  8855. {
  8856. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  8857. {
  8858. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8859. goto end;
  8860. }
  8861. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8862. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8863. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8864. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8865. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8866. {
  8867. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8868. goto end;
  8869. }
  8870. else
  8871. {
  8872. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  8873. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8874. goto end;
  8875. }
  8876. }
  8877. }//END FOR CCS_QUANTITY
  8878. for (int index = 0; index < GB_QUANTITY; index++)
  8879. {
  8880. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))
  8881. {
  8882. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8883. {
  8884. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8885. goto end;
  8886. }
  8887. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8888. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8889. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8890. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8891. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8892. {
  8893. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8894. goto end;
  8895. }
  8896. else
  8897. {
  8898. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  8899. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8900. goto end;
  8901. }
  8902. }
  8903. }// END FOR GB_QUANTITY
  8904. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8905. {
  8906. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))
  8907. {
  8908. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8909. {
  8910. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8911. goto end;
  8912. }
  8913. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  8914. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  8915. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  8916. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  8917. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8918. {
  8919. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8920. goto end;
  8921. }
  8922. else
  8923. {
  8924. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  8925. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8926. goto end;
  8927. }
  8928. }
  8929. }// END FOR DO_QUANTITY
  8930. for (int index = 0; index < AC_QUANTITY; index++)
  8931. {
  8932. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC))
  8933. {
  8934. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8935. {
  8936. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8937. goto end;
  8938. }
  8939. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8940. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8941. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8942. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8943. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8944. {
  8945. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8946. goto end;
  8947. }
  8948. else
  8949. {
  8950. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  8951. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8952. goto end;
  8953. }
  8954. }
  8955. }//END FOR AC_QUANTITY
  8956. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  8957. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  8958. {
  8959. //----------------------gunIndex is 0 ------------------------------------------------//
  8960. if(gunIndex == 0)
  8961. {
  8962. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8963. {
  8964. for(int i=0; i < gunTotalNumber; i++)
  8965. {
  8966. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8967. {
  8968. if ((gunType[i] == GUN_TYPE_CHAdeMO )&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO)) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8969. {
  8970. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8971. goto end;
  8972. }
  8973. }//END FOR CHAdeMO_QUANTITY
  8974. for (int index = 0; index < CCS_QUANTITY; index++)
  8975. {
  8976. if ((gunType[i] == GUN_TYPE_CCS)&&(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
  8977. {
  8978. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8979. goto end;
  8980. }
  8981. }//END FOR CCS_QUANTITY
  8982. for (int index = 0; index < GB_QUANTITY; index++)
  8983. {
  8984. if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT)))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8985. {
  8986. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8987. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8988. goto end;
  8989. }
  8990. }// END FOR GB_QUANTITY
  8991. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8992. {
  8993. if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT)))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8994. {
  8995. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8996. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8997. goto end;
  8998. }
  8999. }// END FOR DO_QUANTITY
  9000. for (int index = 0; index < AC_QUANTITY; index++)
  9001. {
  9002. if ((gunType[i] == GUN_TYPE_AC) &&(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
  9003. {
  9004. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9005. goto end;
  9006. }
  9007. }//END FOR CHAdeMO_QUANTITY
  9008. }// END FOR gunTotalNumber
  9009. }
  9010. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  9011. {
  9012. for(int i=0; i < gunTotalNumber; i++)
  9013. {
  9014. for (int index = 0; index < AC_QUANTITY; index++)
  9015. {
  9016. if ((gunType[i] == GUN_TYPE_AC) &&(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
  9017. {
  9018. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9019. goto end;
  9020. }
  9021. }//END FOR CHAdeMO_QUANTITY
  9022. } // END FOR gunTotalNumber
  9023. }
  9024. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9025. goto end;
  9026. }
  9027. //----------------------gunIndex is not 0 ------------------------------------------------//
  9028. //check Transaction active
  9029. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  9030. {
  9031. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9032. {
  9033. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9034. goto end;
  9035. }
  9036. }//END FOR CHAdeMO_QUANTITY
  9037. for (int index = 0; index < CCS_QUANTITY; index++)
  9038. {
  9039. if ((((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS)) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9040. {
  9041. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9042. goto end;
  9043. }
  9044. }//END FOR CCS_QUANTITY
  9045. for (int index = 0; index < GB_QUANTITY; index++)
  9046. {
  9047. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9048. {
  9049. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9050. goto end;
  9051. }
  9052. }// END FOR GB_QUANTITY
  9053. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9054. {
  9055. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9056. {
  9057. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9058. goto end;
  9059. }
  9060. }// END FOR DO_QUANTITY
  9061. for (int index = 0; index < AC_QUANTITY; index++)
  9062. {
  9063. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC)) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9064. {
  9065. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9066. goto end;
  9067. }
  9068. }//END FOR AC_QUANTITY
  9069. }//END FOR AvailabilityEnumTypeStr[Operative]
  9070. end:
  9071. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  9072. {
  9073. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  9074. }
  9075. else
  9076. {
  9077. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  9078. }
  9079. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  9080. {
  9081. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  9082. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  9083. }
  9084. else if(gunIndex == 0)
  9085. {
  9086. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  9087. {
  9088. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  9089. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  9090. }
  9091. }
  9092. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  9093. return result;
  9094. }
  9095. int handleClearCacheRequest(char *uuid, char *payload)
  9096. {
  9097. mtrace();
  9098. int result = FAIL;
  9099. char rmFileCmd[100]={0};
  9100. struct stat stats;
  9101. DEBUG_INFO("handleClearCacheRequest...\n");
  9102. stat("/Storage/OCPP", &stats);
  9103. // Check for directory existence
  9104. if (S_ISDIR(stats.st_mode) == 1)
  9105. {}
  9106. else
  9107. {
  9108. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  9109. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  9110. system(rmFileCmd);
  9111. }
  9112. /*
  9113. * TODO:
  9114. * 1. Clear cache from sqlite db
  9115. */
  9116. if(1)
  9117. {
  9118. DEBUG_INFO("open AuthorizationCache file failed\n");
  9119. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  9120. }
  9121. else
  9122. {
  9123. DEBUG_INFO("open AuthorizationCache file successful\n");
  9124. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  9125. }
  9126. sendClearCacheConfirmation(uuid);
  9127. return result;
  9128. }
  9129. int handleClearChargingProfileRequest(char *uuid, char *payload)
  9130. {
  9131. mtrace();
  9132. int result = FAIL;
  9133. int resultRename;
  9134. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  9135. char chargingProfilePurposeStr[26]={0};
  9136. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  9137. char tempchargingProfilePurposeStr[26]={0};
  9138. char sstr[160]={0};
  9139. char str[100]={0};
  9140. int c = 0;
  9141. char *loc;
  9142. char fname[200]={0};
  9143. char comfirmstr[20]={0};
  9144. char word[1600]={0};
  9145. int clearflag = FALSE;
  9146. int chargingProfileIdIsNULL = FALSE;
  9147. int connectorIsNULL = FALSE;
  9148. int chargingProfilePurposeIsNULL = FALSE;
  9149. int stackLevelIsNULL = FALSE;
  9150. //int GotoEnd = FALSE;
  9151. FILE *fptr1, *fptr2;
  9152. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  9153. int n_chargingProfile=0;
  9154. int isEmptyFile = FALSE;
  9155. char sLineWord[1600]={0};
  9156. char chargingProfiles[10][100]={0};
  9157. int ChargeProfileCount = 0;
  9158. int ch;
  9159. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  9160. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  9161. json_object *ClearChargingProfile;
  9162. ClearChargingProfile = json_tokener_parse(payload);
  9163. if(!is_error(ClearChargingProfile))
  9164. {
  9165. // Optional data
  9166. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  9167. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  9168. else
  9169. chargingProfileIdIsNULL = TRUE;
  9170. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  9171. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  9172. else
  9173. connectorIsNULL = TRUE;
  9174. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  9175. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  9176. else
  9177. chargingProfilePurposeIsNULL = TRUE;
  9178. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  9179. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  9180. else
  9181. stackLevelIsNULL = TRUE;
  9182. }
  9183. json_object_put(ClearChargingProfile);
  9184. if(connectorIsNULL == FALSE)
  9185. {
  9186. switch(connectorIdInt)
  9187. {
  9188. case 0:
  9189. if(chargingProfilePurposeIsNULL == TRUE)
  9190. {
  9191. int l = 0;
  9192. strcpy(fname, ChargePointMaxProfile_JSON);
  9193. if((access(fname,F_OK))!=-1)
  9194. {
  9195. strcpy(chargingProfiles[l], fname);
  9196. l = l + 1;
  9197. }
  9198. strcpy(fname, TxDefaultProfile_0_JSON);
  9199. if((access(fname,F_OK))!=-1)
  9200. {
  9201. strcpy(chargingProfiles[l], fname);
  9202. l = l + 1;
  9203. }
  9204. ChargeProfileCount = l;
  9205. }
  9206. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  9207. {
  9208. strcpy(fname, ChargePointMaxProfile_JSON);
  9209. if((access(fname,F_OK))!=-1)
  9210. {
  9211. strcpy(chargingProfiles[0], fname);
  9212. ChargeProfileCount = 1;
  9213. }
  9214. }
  9215. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  9216. {
  9217. strcpy(fname, TxDefaultProfile_0_JSON);
  9218. if((access(fname,F_OK))!=-1)
  9219. {
  9220. strcpy(chargingProfiles[0], fname);
  9221. ChargeProfileCount = 1;
  9222. }
  9223. }
  9224. break;
  9225. default:
  9226. if(chargingProfilePurposeIsNULL == TRUE)
  9227. {
  9228. int m = 0;
  9229. memset(fname, 0, ARRAY_SIZE(fname));
  9230. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  9231. if((access(fname,F_OK))!=-1)
  9232. {
  9233. strcpy(chargingProfiles[m], fname);
  9234. m = m + 1;
  9235. }
  9236. memset(fname, 0, ARRAY_SIZE(fname));
  9237. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  9238. if((access(fname,F_OK))!=-1)
  9239. {
  9240. strcpy(chargingProfiles[m], fname);
  9241. m = m + 1;
  9242. }
  9243. ChargeProfileCount = m;
  9244. }
  9245. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  9246. {
  9247. //strcpy(fname, TxDefaultProfile_1_JSON);
  9248. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  9249. if((access(fname,F_OK))!=-1)
  9250. {
  9251. strcpy(chargingProfiles[0], fname);
  9252. ChargeProfileCount = 1;
  9253. }
  9254. }
  9255. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  9256. {
  9257. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  9258. if((access(fname,F_OK))!=-1)
  9259. {
  9260. strcpy(chargingProfiles[0], fname);
  9261. ChargeProfileCount = 1;
  9262. }
  9263. }
  9264. //strcpy(fname, ChargePointMaxProfile_JSON );
  9265. break;
  9266. }
  9267. }
  9268. else // Check all Charging Profiles
  9269. {
  9270. int i = 0;
  9271. char fnametemp[200]={0};
  9272. ChargeProfileCount = 0;
  9273. //Check ChargePointMaxProfile.json exit
  9274. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  9275. {
  9276. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  9277. i = i + 1;
  9278. }
  9279. //Check TxDefaultProfile_0.json exit
  9280. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  9281. {
  9282. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  9283. i = i + 1;
  9284. }
  9285. //Check TxDefaultProfile_%d.json
  9286. for(int j=1; j <= gunTotalNumber; j++)
  9287. {
  9288. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9289. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  9290. if((access(fnametemp,F_OK))!=-1)
  9291. {
  9292. strcpy(chargingProfiles[i], fnametemp);
  9293. i = i + 1;
  9294. }
  9295. }
  9296. //Check TxProfile_%d.json
  9297. for(int j=1; j <= gunTotalNumber; j++)
  9298. {
  9299. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9300. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  9301. if((access(fnametemp,F_OK))!=-1)
  9302. {
  9303. strcpy(chargingProfiles[i], fnametemp);
  9304. i = i + 1;
  9305. }
  9306. }
  9307. ChargeProfileCount = i;
  9308. }// End connectorIsNULL is TRUE
  9309. if(ChargeProfileCount == 0)
  9310. {
  9311. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9312. goto end;
  9313. }
  9314. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  9315. {
  9316. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9317. goto end;
  9318. }
  9319. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  9320. {
  9321. memset(str, 0, ARRAY_SIZE(str));
  9322. // clear temp file
  9323. sprintf(str,"rm -f %s",temp);
  9324. system(str);
  9325. for(int k=0; k < ChargeProfileCount; k++)
  9326. {
  9327. memset(str, 0, ARRAY_SIZE(str));
  9328. //clear file in C
  9329. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9330. system(str);
  9331. }
  9332. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9333. goto end;
  9334. }
  9335. else if(connectorIsNULL == TRUE)
  9336. {
  9337. for(int k=0; k < ChargeProfileCount; k++)
  9338. {
  9339. fptr1 = fopen(chargingProfiles[k], "r");
  9340. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  9341. //Check Charging Profile Count
  9342. while(fscanf(fptr1, "%s", word) != EOF)
  9343. {
  9344. //DEBUG_INFO("word=%s\n",word);
  9345. if(strstr(word, "chargingProfileId")!= NULL)
  9346. {
  9347. //DEBUG_INFO("test chargingProfileId \n");
  9348. n_chargingProfile = n_chargingProfile + 1;
  9349. //DEBUG_INFO("chargingProfileId Found\n");
  9350. }
  9351. }
  9352. rewind(fptr1);
  9353. //search Charging Profile Element
  9354. //int i= 0;
  9355. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9356. {
  9357. //------------------------tempconnectorIdInt------------------------//
  9358. loc = strstr(sLineWord, "connectorId");
  9359. c = 0;
  9360. memset(sstr ,0, sizeof(sstr) );
  9361. while (loc[strlen("connectorId")+2+c] != ',')
  9362. {
  9363. sstr[c] = loc[strlen("connectorId")+2+c];
  9364. c++;
  9365. }
  9366. sstr[c] = '\0';
  9367. tempconnectorIdInt = atoi(sstr);
  9368. printf("file's gun number is %d\n", tempconnectorIdInt);
  9369. //--------------------------chargingProfileId--------------------//
  9370. c = 0;
  9371. loc = strstr(sLineWord, "chargingProfileId");
  9372. memset(sstr ,0, ARRAY_SIZE(sstr));
  9373. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9374. {
  9375. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9376. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9377. c++;
  9378. }
  9379. sstr[c] = '\0';
  9380. tempchargingProfileIdInt = atoi(sstr);
  9381. //stackLevel
  9382. c = 0;
  9383. loc = strstr(sLineWord, "stackLevel");
  9384. memset(sstr ,0, ARRAY_SIZE(sstr));
  9385. while (loc[strlen("stackLevel")+2+c] != ',')
  9386. {
  9387. sstr[c] = loc[strlen("stackLevel")+2+c];
  9388. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9389. c++;
  9390. }
  9391. sstr[c] = '\0';
  9392. tempstackLevelInt = atoi(sstr);
  9393. c = 0;
  9394. loc = strstr(sLineWord, "chargingProfilePurpose");
  9395. memset(sstr ,0, ARRAY_SIZE(sstr));
  9396. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9397. {
  9398. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9399. c++;
  9400. }
  9401. sstr[c] = '\0';
  9402. strcpy(tempchargingProfilePurposeStr, sstr);
  9403. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9404. {
  9405. //------- not write to fptr2-------//
  9406. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9407. //clearflag = TRUE;
  9408. }
  9409. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  9410. {
  9411. //------- not write to fptr2-------//
  9412. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9413. }
  9414. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9415. {
  9416. //------- not write to fptr2-------//
  9417. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9418. }
  9419. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  9420. {
  9421. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9422. }
  9423. else
  9424. {
  9425. fprintf(fptr2, sLineWord);//writing data into file
  9426. }
  9427. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9428. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9429. if(clearflag == TRUE)
  9430. {
  9431. fclose(fptr1);
  9432. fclose(fptr2);
  9433. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9434. system(str);
  9435. // clear temp file
  9436. sprintf(str,"rm -f %s",temp);
  9437. system(str);
  9438. }
  9439. else
  9440. {
  9441. fclose(fptr1);
  9442. fclose(fptr2);
  9443. memset(str, 0, ARRAY_SIZE(str));
  9444. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9445. system(str);
  9446. resultRename = rename(temp, chargingProfiles[k]);
  9447. if(resultRename == 0)
  9448. {
  9449. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  9450. }
  9451. else
  9452. {
  9453. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  9454. }
  9455. if(comfirmstr[0]== 0)
  9456. {
  9457. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9458. }
  9459. //Check chargingProfile is empty file
  9460. /*------ Read the file ----------------*/
  9461. fptr1=fopen(chargingProfiles[k],"r");
  9462. ch=fgetc(fptr1);
  9463. rewind(fptr1);
  9464. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9465. if(ch!=EOF)
  9466. {
  9467. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9468. {
  9469. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9470. if(sLineWord[0]=='\0')
  9471. {
  9472. isEmptyFile = TRUE;
  9473. break;
  9474. }
  9475. else
  9476. {
  9477. isEmptyFile = FALSE;
  9478. break;
  9479. }
  9480. }
  9481. }
  9482. else
  9483. isEmptyFile = TRUE;
  9484. fclose(fptr1);
  9485. if(isEmptyFile == TRUE)
  9486. {
  9487. memset(str, 0, ARRAY_SIZE(str));
  9488. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9489. system(str);
  9490. }
  9491. }
  9492. }// End of while(int k=0; k < ChargePointCount; k++)
  9493. }
  9494. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  9495. {
  9496. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  9497. for(int k=0; k < ChargeProfileCount; k++)
  9498. {
  9499. fptr1 = fopen(chargingProfiles[k], "r");
  9500. fptr2 = fopen(temp, "w+");
  9501. //Check Charging Profile Count
  9502. while(fscanf(fptr1, "%s", word) != EOF)
  9503. {
  9504. //DEBUG_INFO("word=%s\n",word);
  9505. if(strstr(word, "chargingProfileId")!= NULL)
  9506. {
  9507. n_chargingProfile = n_chargingProfile + 1;
  9508. }
  9509. }
  9510. rewind(fptr1);
  9511. //search Charging Profile Element
  9512. //int i= 0;
  9513. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9514. {
  9515. //*************************tempconnectorIdInt*********************************/
  9516. loc = strstr(sLineWord, "connectorId");
  9517. c = 0;
  9518. memset(sstr ,0, ARRAY_SIZE(sstr));
  9519. while (loc[strlen("connectorId")+2+c] != ',')
  9520. {
  9521. sstr[c] = loc[strlen("connectorId")+2+c];
  9522. c++;
  9523. }
  9524. sstr[c] = '\0';
  9525. tempconnectorIdInt = atoi(sstr);
  9526. //chargingProfileId
  9527. c = 0;
  9528. loc = strstr(sLineWord, "chargingProfileId");
  9529. memset(sstr ,0, ARRAY_SIZE(sstr));
  9530. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9531. {
  9532. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9533. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9534. c++;
  9535. }
  9536. sstr[c] = '\0';
  9537. tempchargingProfileIdInt = atoi(sstr);
  9538. //stackLevel
  9539. c = 0;
  9540. loc = strstr(sLineWord, "stackLevel");
  9541. memset(sstr ,0, ARRAY_SIZE(sstr));
  9542. while (loc[strlen("stackLevel")+2+c] != ',')
  9543. {
  9544. sstr[c] = loc[strlen("stackLevel")+2+c];
  9545. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9546. c++;
  9547. }
  9548. sstr[c] = '\0';
  9549. tempstackLevelInt = atoi(sstr);
  9550. c = 0;
  9551. loc = strstr(sLineWord, "chargingProfilePurpose");
  9552. memset(sstr ,0, ARRAY_SIZE(sstr));
  9553. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9554. {
  9555. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9556. c++;
  9557. }
  9558. sstr[c] = '\0';
  9559. strcpy(tempchargingProfilePurposeStr, sstr);
  9560. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9561. {
  9562. //------- not write to fptr2-------//
  9563. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9564. //clearflag = TRUE;
  9565. }
  9566. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9567. {
  9568. //------- not write to fptr2-------//
  9569. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9570. }
  9571. else if(stackLevelIsNULL == TRUE)
  9572. {
  9573. //Clear Whole File
  9574. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9575. clearflag = TRUE;
  9576. break;
  9577. }
  9578. else
  9579. {
  9580. fprintf(fptr2, sLineWord);//writing data into file
  9581. }
  9582. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9583. }
  9584. if(clearflag == TRUE)
  9585. {
  9586. fclose(fptr1);
  9587. fclose(fptr2);
  9588. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9589. system(str);
  9590. // clear temp file
  9591. sprintf(str,"rm -f %s",temp);
  9592. system(str);
  9593. }
  9594. else
  9595. {
  9596. fclose(fptr1);
  9597. fclose(fptr2);
  9598. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9599. system(str);
  9600. resultRename = rename(temp, chargingProfiles[k]);
  9601. if(resultRename == 0)
  9602. {
  9603. DEBUG_INFO("File ChargingProfile renamed successfully");
  9604. }
  9605. else
  9606. {
  9607. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  9608. }
  9609. if(comfirmstr[0]== 0)
  9610. {
  9611. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9612. }
  9613. //Check chargingProfile is empty file
  9614. /*------ Read the file ----------------*/
  9615. fptr1=fopen(chargingProfiles[k],"r");
  9616. ch=fgetc(fptr1);
  9617. rewind(fptr1);
  9618. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9619. if(ch!=EOF)
  9620. {
  9621. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9622. {
  9623. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9624. if(sLineWord[0]=='\0')
  9625. {
  9626. isEmptyFile = TRUE;
  9627. break;
  9628. }
  9629. else
  9630. {
  9631. isEmptyFile = FALSE;
  9632. break;
  9633. }
  9634. }
  9635. }
  9636. else
  9637. isEmptyFile = TRUE;
  9638. fclose(fptr1);
  9639. if(isEmptyFile == TRUE)
  9640. {
  9641. memset(str, 0, ARRAY_SIZE(str));
  9642. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9643. system(str);
  9644. }
  9645. /*------- End of reading ---------------*/
  9646. }
  9647. } // while(int k=0; k < ChargeProfileCount; k++)
  9648. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  9649. end:
  9650. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  9651. {
  9652. if(connectorIdInt == 0)
  9653. {
  9654. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  9655. {
  9656. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  9657. }
  9658. }
  9659. else
  9660. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1]);
  9661. }
  9662. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  9663. return result;
  9664. }
  9665. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  9666. {
  9667. mtrace();
  9668. int result = FAIL;
  9669. json_object *ClearDisplayMessage;
  9670. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  9671. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  9672. ClearDisplayMessage = json_tokener_parse(payload);
  9673. if(!is_error(ClearDisplayMessage))
  9674. {
  9675. // Required data
  9676. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  9677. {
  9678. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  9679. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  9680. }
  9681. }
  9682. json_object_put(ClearDisplayMessage);
  9683. sendCostUpdatedConfirmation(uuid);
  9684. return result;
  9685. }
  9686. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  9687. {
  9688. mtrace();
  9689. int result = FAIL;
  9690. json_object *ClearVariableMonitorin;
  9691. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  9692. ClearVariableMonitorin = json_tokener_parse(payload);
  9693. if(!is_error(ClearVariableMonitorin))
  9694. {
  9695. // Required data
  9696. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  9697. {
  9698. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  9699. {
  9700. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  9701. /*
  9702. * TODO:
  9703. * 1. Check response
  9704. */
  9705. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  9706. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  9707. }
  9708. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  9709. }
  9710. }
  9711. json_object_put(ClearVariableMonitorin);
  9712. return result;
  9713. }
  9714. int handleCostUpdatedRequest(char *uuid, char *payload)
  9715. {
  9716. mtrace();
  9717. int result = FAIL;
  9718. json_object *CostUpdate;
  9719. DEBUG_INFO("handleCostUpdatedRequest...\n");
  9720. CostUpdate = json_tokener_parse(payload);
  9721. if(!is_error(CostUpdate))
  9722. {
  9723. // Required data
  9724. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  9725. {
  9726. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  9727. }
  9728. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  9729. {
  9730. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  9731. }
  9732. }
  9733. json_object_put(CostUpdate);
  9734. sendCostUpdatedConfirmation(uuid);
  9735. return result;
  9736. }
  9737. int handleCustomerInformationRequest(char *uuid, char *payload)
  9738. {
  9739. mtrace();
  9740. int result = FAIL;
  9741. json_object *CustomerInformation;
  9742. DEBUG_INFO("handleCustomerInformationRequest...\n");
  9743. CustomerInformation = json_tokener_parse(payload);
  9744. if(!is_error(CustomerInformation))
  9745. {
  9746. // Required data
  9747. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  9748. {
  9749. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  9750. }
  9751. if(json_object_object_get(CustomerInformation, "report") != NULL)
  9752. {
  9753. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  9754. }
  9755. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  9756. {
  9757. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  9758. }
  9759. // Optional data
  9760. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  9761. {
  9762. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  9763. {
  9764. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  9765. }
  9766. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  9767. {
  9768. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  9769. }
  9770. }
  9771. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  9772. {
  9773. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  9774. {
  9775. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  9776. }
  9777. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  9778. {
  9779. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  9780. }
  9781. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  9782. {
  9783. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  9784. }
  9785. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  9786. {
  9787. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  9788. }
  9789. }
  9790. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  9791. }
  9792. else
  9793. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  9794. json_object_put(CustomerInformation);
  9795. sendCustomerInformationConfirmation(uuid);
  9796. return result;
  9797. }
  9798. void createFirmwareVersionByDataTransfer(void)
  9799. {
  9800. json_object *FirmwareDataTransfer = json_object_new_object();
  9801. // AC & DC model
  9802. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  9803. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  9804. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  9805. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  9806. // DC model
  9807. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O')
  9808. {
  9809. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  9810. {
  9811. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9812. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9813. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  9814. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  9815. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9816. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9817. }
  9818. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  9819. ((gunType[1] != GUN_TYPE_UNKNOWN) || (gunType[2] != GUN_TYPE_UNKNOWN) || (gunType[3] != GUN_TYPE_UNKNOWN)))
  9820. {
  9821. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  9822. }
  9823. }
  9824. else
  9825. {
  9826. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9827. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9828. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9829. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9830. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  9831. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  9832. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  9833. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  9834. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  9835. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  9836. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  9837. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  9838. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  9839. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  9840. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  9841. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  9842. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  9843. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  9844. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  9845. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  9846. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  9847. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  9848. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  9849. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  9850. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  9851. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  9852. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  9853. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  9854. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  9855. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  9856. json_object_object_add(FirmwareDataTransfer, "DD1_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  9857. }
  9858. // 4G model
  9859. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  9860. {
  9861. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  9862. }
  9863. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "Phihong Technology");
  9864. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  9865. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
  9866. }
  9867. int handleDataTransferRequest(char *uuid, char *payload)
  9868. {
  9869. mtrace();
  9870. int result = PASS;
  9871. DEBUG_INFO("handleDataTransferRequest...\n");
  9872. if((uuid != NULL) && (payload != NULL))
  9873. {
  9874. json_object *DataTransfer;
  9875. DataTransfer = json_tokener_parse(payload);
  9876. if(!is_error(DataTransfer))
  9877. {
  9878. // Required data
  9879. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  9880. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  9881. // Optional data
  9882. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  9883. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  9884. if(json_object_object_get(DataTransfer, "data") != NULL)
  9885. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  9886. result = PASS;
  9887. }
  9888. json_object_put(DataTransfer);
  9889. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  9890. {
  9891. // Send all moudle firmware version on EVSE
  9892. createFirmwareVersionByDataTransfer();
  9893. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9894. }
  9895. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  9896. {
  9897. system("/usr/bin/run_tmate_restart.sh &");
  9898. }
  9899. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  9900. {
  9901. json_object *data;
  9902. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  9903. if(!is_error(data))
  9904. {
  9905. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  9906. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  9907. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  9908. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  9909. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  9910. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  9911. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  9912. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  9913. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  9914. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  9915. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9916. }
  9917. else
  9918. {
  9919. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  9920. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  9921. }
  9922. json_object_put(data);
  9923. }
  9924. else
  9925. {
  9926. // Can not find valid message id
  9927. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9928. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  9929. ,ShmOCPP20Data->DataTransfer[0].vendorId
  9930. ,ShmOCPP20Data->DataTransfer[0].messageId
  9931. ,ShmOCPP20Data->DataTransfer[0].data);
  9932. }
  9933. }
  9934. else
  9935. {
  9936. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9937. result = FAIL;
  9938. }
  9939. sendDataTransferConfirmation(uuid, 0);
  9940. return result;
  9941. }
  9942. int handleDeleteCertificateRequest(char *uuid, char *payload)
  9943. {
  9944. mtrace();
  9945. int result = FAIL;
  9946. json_object *DeleteCertificate;
  9947. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  9948. DeleteCertificate = json_tokener_parse(payload);
  9949. if(!is_error(DeleteCertificate))
  9950. {
  9951. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  9952. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  9953. // Required data
  9954. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  9955. {
  9956. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  9957. {
  9958. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  9959. }
  9960. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  9961. {
  9962. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  9963. }
  9964. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  9965. {
  9966. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  9967. }
  9968. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  9969. {
  9970. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  9971. }
  9972. /*
  9973. * TODO:
  9974. * 1. Delete certification and response
  9975. */
  9976. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  9977. }
  9978. }
  9979. else
  9980. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  9981. json_object_put(DeleteCertificate);
  9982. sendDeleteCertificateConfirmation(uuid);
  9983. return result;
  9984. }
  9985. int handleGetBaseReportRequest(char *uuid, char *payload)
  9986. {
  9987. mtrace();
  9988. int result = FAIL;
  9989. json_object *GetBaseRepor;
  9990. DEBUG_INFO("handleGetBaseReportRequest...\n");
  9991. GetBaseRepor = json_tokener_parse(payload);
  9992. if(!is_error(GetBaseRepor))
  9993. {
  9994. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  9995. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  9996. // Required data
  9997. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  9998. {
  9999. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  10000. }
  10001. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  10002. {
  10003. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  10004. }
  10005. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_SummaryInventory]) == 0)
  10006. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  10007. else
  10008. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10009. }
  10010. else
  10011. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  10012. json_object_put(GetBaseRepor);
  10013. sendGetBaseReportConfirmation(uuid);
  10014. return result;
  10015. }
  10016. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  10017. {
  10018. mtrace();
  10019. int result = FAIL;
  10020. int gun_index = -1;
  10021. json_object *GetChargingProfiles;
  10022. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  10023. GetChargingProfiles = json_tokener_parse(payload);
  10024. if(!is_error(GetChargingProfiles))
  10025. {
  10026. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  10027. {
  10028. 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;
  10029. }
  10030. if(gun_index >-1)
  10031. {
  10032. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  10033. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  10034. // Required data
  10035. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  10036. {
  10037. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  10038. }
  10039. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  10040. {
  10041. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  10042. {
  10043. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  10044. }
  10045. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  10046. {
  10047. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  10048. }
  10049. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  10050. {
  10051. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  10052. {
  10053. 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)));
  10054. }
  10055. }
  10056. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  10057. {
  10058. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  10059. {
  10060. 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));
  10061. }
  10062. }
  10063. }
  10064. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  10065. }
  10066. else
  10067. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  10068. }
  10069. json_object_put(GetChargingProfiles);
  10070. sendGetChargingProfilesConfirmation(uuid, gun_index);
  10071. return result;
  10072. }
  10073. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  10074. {
  10075. mtrace();
  10076. int result = FAIL;
  10077. int connectorIdInt, durationInt;
  10078. char chargingRateUnitStr[4]={0};
  10079. char comfirmstr[20];
  10080. int confirmPeriods = 0;
  10081. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  10082. json_object *GetCompositeSchedule;
  10083. GetCompositeSchedule = json_tokener_parse(payload);
  10084. if(!is_error(GetCompositeSchedule))
  10085. {
  10086. // Required data
  10087. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  10088. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  10089. else
  10090. connectorIdInt = -1;
  10091. if(json_object_object_get(GetCompositeSchedule, "duration"))
  10092. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  10093. else
  10094. durationInt = 86400;
  10095. // Optional data
  10096. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  10097. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  10098. }
  10099. json_object_put(GetCompositeSchedule);
  10100. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  10101. if((connectorIdInt == 0) ||
  10102. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  10103. {
  10104. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  10105. struct ChargingProfileType tmpProfile[1];
  10106. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  10107. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  10108. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0]);
  10109. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  10110. {
  10111. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  10112. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  10113. }
  10114. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  10115. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  10116. {
  10117. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  10118. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  10119. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  10120. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0))
  10121. {
  10122. confirmPeriods = idx;
  10123. break;
  10124. }
  10125. }
  10126. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10127. }
  10128. else
  10129. {
  10130. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  10131. }
  10132. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  10133. return result;
  10134. }
  10135. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  10136. {
  10137. mtrace();
  10138. int result = FAIL;
  10139. json_object *GetDisplayMessages;
  10140. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  10141. GetDisplayMessages = json_tokener_parse(payload);
  10142. if(!is_error(GetDisplayMessages))
  10143. {
  10144. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  10145. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  10146. // Required data
  10147. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  10148. {
  10149. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  10150. }
  10151. // Optional data
  10152. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  10153. {
  10154. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  10155. }
  10156. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  10157. {
  10158. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  10159. }
  10160. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  10161. {
  10162. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  10163. {
  10164. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  10165. }
  10166. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  10167. }
  10168. else
  10169. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  10170. }
  10171. json_object_put(GetDisplayMessages);
  10172. return result;
  10173. }
  10174. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  10175. {
  10176. mtrace();
  10177. int result = FAIL;
  10178. json_object *GetInstalledCertificateIds;
  10179. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  10180. GetInstalledCertificateIds = json_tokener_parse(payload);
  10181. if(!is_error(GetInstalledCertificateIds))
  10182. {
  10183. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  10184. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  10185. // Optional data
  10186. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  10187. {
  10188. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  10189. {
  10190. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  10191. /*
  10192. * TODO:
  10193. * 1. Get installed certificate info for response
  10194. */
  10195. }
  10196. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  10197. }
  10198. else
  10199. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  10200. }
  10201. json_object_put(GetInstalledCertificateIds);
  10202. sendInstallCertificateConfirmation(uuid);
  10203. return result;
  10204. }
  10205. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  10206. {
  10207. mtrace();
  10208. int result = FAIL;
  10209. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  10210. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  10211. {
  10212. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  10213. localversion = -1;
  10214. }
  10215. else
  10216. {
  10217. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  10218. DB_getListVerion();
  10219. }
  10220. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  10221. sendGetLocalListVersionConfirmation(uuid);
  10222. return result;
  10223. }
  10224. static char fnamePlusPath[100]={0};
  10225. static char fnamePWithNoPath[60]={0};
  10226. void checkUploadLog(void)
  10227. {
  10228. FILE *fp;
  10229. /* Open the command for reading. */
  10230. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  10231. if (fp == NULL) {
  10232. printf("Failed to run command\n" );
  10233. exit(1);
  10234. }
  10235. int ftppathlen = 0;
  10236. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  10237. int i = 0;
  10238. /* Read the output a line at a time - output it. */
  10239. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  10240. if(i==0)
  10241. {
  10242. ftppathlen = strlen(fnamePlusPath);
  10243. printf("%s\n", fnamePlusPath);
  10244. fnamePlusPath[ftppathlen]='\0';
  10245. break;
  10246. }
  10247. i= i+1;
  10248. }
  10249. /* close */
  10250. pclose(fp);
  10251. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  10252. {
  10253. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  10254. {
  10255. fnamePlusPath[k]='\0';
  10256. }
  10257. }
  10258. i=1;
  10259. //char fname[60]={0};
  10260. while(i < ftppathlen)
  10261. {
  10262. int len=ftppathlen-i;
  10263. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  10264. {
  10265. printf("compare '/' all right\n");
  10266. break;
  10267. }
  10268. i=i+1;
  10269. }
  10270. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  10271. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  10272. fnamePWithNoPath[i+1] = '\0';
  10273. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  10274. {
  10275. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  10276. {
  10277. fnamePWithNoPath[j]='\0';
  10278. }
  10279. }
  10280. FILE* fp1 = fopen(fnamePlusPath, "r");
  10281. if (fp1)
  10282. {
  10283. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  10284. // file exists
  10285. fclose(fp1);
  10286. }
  10287. else
  10288. {
  10289. // file doesn't exist
  10290. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  10291. }
  10292. }
  10293. void* GetLogProcess(void* data)
  10294. {
  10295. pthread_detach(pthread_self());
  10296. mtrace();
  10297. int requestId, retriesInt=0, retryIntervalInt=0;
  10298. char logType[32], remoteLocation[512]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  10299. 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};
  10300. int port=0;
  10301. int isSuccess = FALSE;
  10302. char ftpbuf[200]={0};
  10303. json_object *GetLog;
  10304. DEBUG_INFO("GetGetProcess...\n");
  10305. GetLog = json_tokener_parse(data);
  10306. if(!is_error(GetLog))
  10307. {
  10308. // Required data
  10309. if(json_object_object_get(GetLog, "requestId") != NULL)
  10310. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  10311. if(json_object_object_get(GetLog, "logType") != NULL)
  10312. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  10313. if(json_object_object_get(GetLog, "log") != NULL)
  10314. {
  10315. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  10316. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  10317. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  10318. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  10319. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  10320. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  10321. }
  10322. // Optional data
  10323. if(json_object_object_get(GetLog, "retries") != NULL)
  10324. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  10325. else
  10326. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  10327. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  10328. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  10329. else
  10330. retryIntervalInt = 30;
  10331. }
  10332. json_object_put(GetLog);
  10333. ShmOCPP20Data->GetLog.requestId = requestId;
  10334. //****************location*******************/
  10335. if(strcmp(remoteLocation,"")==0)
  10336. {
  10337. DEBUG_INFO("remoteLocation is <Empty>!\n");
  10338. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10339. goto end;
  10340. }
  10341. memset(protocol, 0, ARRAY_SIZE(protocol));
  10342. memset(user, 0, ARRAY_SIZE(user) );
  10343. memset(password, 0, ARRAY_SIZE(password));
  10344. memset(host, 0, ARRAY_SIZE(host));
  10345. memset(path, 0, ARRAY_SIZE(path));
  10346. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  10347. memset(host1, 0, ARRAY_SIZE(host1));
  10348. memset(path1, 0, ARRAY_SIZE(path1));
  10349. /*location: ftp://user:password@host:port/path*/
  10350. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  10351. if((access(fnamePlusPath,F_OK))!=-1)
  10352. {
  10353. DEBUG_INFO("fnamePlusPath exist.\n");
  10354. }
  10355. else
  10356. {
  10357. DEBUG_INFO("fnamePlusPath not exist!\n");
  10358. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10359. goto end;
  10360. }
  10361. if(strchr(remoteLocation,'@')==NULL)
  10362. {
  10363. sscanf(remoteLocation,
  10364. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  10365. protocol, host, &port, path);
  10366. strcpy(user,"anonymous");
  10367. strcpy(password,"");
  10368. }
  10369. else
  10370. {
  10371. //DEBUG_INFO("pch=%s\n", pch);
  10372. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  10373. protocol, user, password, host, &port, path);
  10374. }
  10375. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
  10376. {
  10377. DEBUG_INFO("protocol is not ftp/http ! \n");
  10378. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10379. goto end;
  10380. }
  10381. if(strncmp(remoteLocation,"http", 4) == 0)
  10382. {
  10383. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  10384. sprintf(ftppath,"/%s", path);
  10385. do
  10386. {
  10387. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10388. sleep(3);
  10389. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  10390. if(!isSuccess)
  10391. {
  10392. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10393. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10394. sleep(retryIntervalInt);
  10395. }
  10396. else
  10397. {
  10398. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10399. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10400. }
  10401. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt--));
  10402. }
  10403. else
  10404. {
  10405. sscanf(host,"%[^/]%s",host1, path1);
  10406. sprintf(ftppath,"%s", path1);
  10407. int ftppathlen=strlen(ftppath);
  10408. int i=1;
  10409. char filenametemp[50];
  10410. while(i < ftppathlen)
  10411. {
  10412. int len=ftppathlen-i;
  10413. if(ftppath[len]== 47) // '/' ascll code: 47
  10414. {
  10415. DEBUG_INFO("find '/' all right\n");
  10416. break;
  10417. }
  10418. i=i+1;
  10419. }
  10420. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  10421. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  10422. filenametemp[i+1] = 0;
  10423. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  10424. if(port == 0)
  10425. port = 21;
  10426. do
  10427. {
  10428. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10429. sleep(3);
  10430. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  10431. if(!isSuccess)
  10432. {
  10433. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10434. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10435. sleep(retryIntervalInt);
  10436. }
  10437. else
  10438. {
  10439. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10440. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10441. }
  10442. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  10443. }
  10444. end:
  10445. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  10446. pthread_exit(NULL);
  10447. }
  10448. int handleGetLogRequest(char *uuid, char *payload)
  10449. {
  10450. mtrace();
  10451. int result = FAIL;
  10452. char cmdBuf[512];
  10453. char fName[258];
  10454. time_t CurrentTime;
  10455. struct tm *tm;
  10456. pthread_t th_Status;
  10457. CurrentTime = time(NULL);
  10458. tm = localtime(&CurrentTime);
  10459. 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);
  10460. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  10461. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  10462. sendGetLogConfirmation(uuid);
  10463. system("exec /root/logPackTools 'log' 6");
  10464. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", fName);
  10465. system(cmdBuf);
  10466. checkUploadLog();
  10467. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  10468. return result;
  10469. }
  10470. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  10471. {
  10472. mtrace();
  10473. int result = FAIL;
  10474. json_object *GetMonitoringReport;
  10475. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  10476. GetMonitoringReport = json_tokener_parse(payload);
  10477. if(!is_error(GetMonitoringReport))
  10478. {
  10479. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  10480. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  10481. // Required data
  10482. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  10483. {
  10484. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  10485. }
  10486. // Optional data
  10487. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  10488. {
  10489. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  10490. }
  10491. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  10492. {
  10493. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  10494. {
  10495. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  10496. {
  10497. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  10498. {
  10499. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  10500. {
  10501. 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")));
  10502. }
  10503. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10504. {
  10505. 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")));
  10506. }
  10507. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10508. {
  10509. 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)
  10510. {
  10511. 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"));
  10512. }
  10513. 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)
  10514. {
  10515. 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"));
  10516. }
  10517. }
  10518. }
  10519. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  10520. {
  10521. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10522. {
  10523. 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")));
  10524. }
  10525. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10526. {
  10527. 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")));
  10528. }
  10529. }
  10530. }
  10531. }
  10532. }
  10533. }
  10534. json_object_put(GetMonitoringReport);
  10535. /*
  10536. * TODO:
  10537. * 1. Response result
  10538. */
  10539. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10540. sendGetMonitoringReportConfirmation(uuid);
  10541. return result;
  10542. }
  10543. int handleGetReportRequest(char *uuid, char *payload)
  10544. {
  10545. mtrace();
  10546. int result = FAIL;
  10547. json_object *GetReport;
  10548. DEBUG_INFO("handleGetReportRequest...\n");
  10549. GetReport = json_tokener_parse(payload);
  10550. if(!is_error(GetReport))
  10551. {
  10552. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  10553. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  10554. // Required data
  10555. if(json_object_object_get(GetReport, "requestId") != NULL)
  10556. {
  10557. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  10558. }
  10559. // Optional data
  10560. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  10561. {
  10562. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  10563. }
  10564. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  10565. {
  10566. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  10567. {
  10568. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  10569. {
  10570. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  10571. {
  10572. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  10573. {
  10574. 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")));
  10575. }
  10576. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10577. {
  10578. 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")));
  10579. }
  10580. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10581. {
  10582. 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)
  10583. {
  10584. 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"));
  10585. }
  10586. 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)
  10587. {
  10588. 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"));
  10589. }
  10590. }
  10591. }
  10592. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  10593. {
  10594. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10595. {
  10596. 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")));
  10597. }
  10598. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10599. {
  10600. 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")));
  10601. }
  10602. }
  10603. }
  10604. }
  10605. }
  10606. }
  10607. json_object_put(GetReport);
  10608. /*
  10609. * TODO:
  10610. * 1. Response result
  10611. */
  10612. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10613. sendGetReportConfirmation(uuid);
  10614. return result;
  10615. }
  10616. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  10617. {
  10618. mtrace();
  10619. int result = FAIL;
  10620. int8_t gun_index = -1;
  10621. json_object *GetTransactionStatus;
  10622. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  10623. GetTransactionStatus = json_tokener_parse(payload);
  10624. if(!is_error(GetTransactionStatus))
  10625. {
  10626. /*
  10627. * TODO:
  10628. * 1. Check transaction locate which connector
  10629. */
  10630. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  10631. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  10632. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  10633. {
  10634. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  10635. }
  10636. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  10637. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  10638. }
  10639. json_object_put(GetTransactionStatus);
  10640. sendGetTransactionStatusConfirmation(uuid, gun_index);
  10641. return result;
  10642. }
  10643. int handleGetVariablesRequest(char *uuid, char *payload)
  10644. {
  10645. mtrace();
  10646. int result = FAIL;
  10647. json_object *GetVariables;
  10648. DEBUG_INFO("handleGetVariablesRequest...\n");
  10649. GetVariables = json_tokener_parse(payload);
  10650. if(!is_error(GetVariables))
  10651. {
  10652. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  10653. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  10654. // Required data
  10655. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  10656. {
  10657. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  10658. {
  10659. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  10660. {
  10661. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  10662. {
  10663. 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")));
  10664. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  10665. }
  10666. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  10667. {
  10668. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  10669. {
  10670. 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")));
  10671. }
  10672. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  10673. {
  10674. 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")));
  10675. }
  10676. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  10677. {
  10678. 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)
  10679. {
  10680. 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"));
  10681. }
  10682. 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)
  10683. {
  10684. 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"));
  10685. }
  10686. }
  10687. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  10688. }
  10689. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  10690. {
  10691. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  10692. {
  10693. 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")));
  10694. }
  10695. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  10696. {
  10697. 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")));
  10698. }
  10699. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  10700. }
  10701. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  10702. {
  10703. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
  10704. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance) == 0) &&
  10705. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
  10706. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance) == 0))
  10707. {
  10708. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  10709. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  10710. break;
  10711. }
  10712. else
  10713. {
  10714. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  10715. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  10716. }
  10717. }
  10718. }
  10719. }
  10720. }
  10721. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  10722. }
  10723. json_object_put(GetVariables);
  10724. return result;
  10725. }
  10726. int handleInstallCertificateRequest(char *uuid, char *payload)
  10727. {
  10728. mtrace();
  10729. int result = FAIL;
  10730. json_object *InstallCertificate;
  10731. DEBUG_INFO("handleInstallCertificateRequest...\n");
  10732. InstallCertificate = json_tokener_parse(payload);
  10733. if(!is_error(InstallCertificate))
  10734. {
  10735. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  10736. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  10737. // Required data
  10738. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  10739. {
  10740. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  10741. }
  10742. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  10743. {
  10744. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  10745. }
  10746. }
  10747. json_object_put(InstallCertificate);
  10748. /*
  10749. * TODO:
  10750. * 1. Install certification preocess and response
  10751. */
  10752. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10753. sendInstallCertificateConfirmation(uuid);
  10754. return result;
  10755. }
  10756. int handlePublishFirmwareRequest(char *uuid, char *payload)
  10757. {
  10758. mtrace();
  10759. int result = FAIL;
  10760. json_object *PublishFirmware;
  10761. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  10762. PublishFirmware = json_tokener_parse(payload);
  10763. if(!is_error(PublishFirmware))
  10764. {
  10765. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  10766. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  10767. // Required data
  10768. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  10769. {
  10770. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  10771. }
  10772. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  10773. {
  10774. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  10775. }
  10776. // Optional data
  10777. if(json_object_object_get(PublishFirmware, "location") != NULL)
  10778. {
  10779. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  10780. }
  10781. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  10782. {
  10783. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  10784. }
  10785. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  10786. {
  10787. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  10788. }
  10789. }
  10790. json_object_put(PublishFirmware);
  10791. /*
  10792. * TODO:
  10793. * 1. Publish firmware preocess and response
  10794. */
  10795. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10796. sendPublishFirmwareConfirmation(uuid);
  10797. return result;
  10798. }
  10799. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  10800. {
  10801. mtrace();
  10802. int result = FAIL;
  10803. int8_t gun_index = -1;
  10804. uint8_t isPeriodOverMax = FALSE;
  10805. uint8_t isProfileOverMax = FALSE;
  10806. uint8_t isConnectorMismatch = FALSE;
  10807. uint8_t isTxProfile = FALSE;
  10808. uint8_t existProfileQuantity = 0;
  10809. uint8_t filename[128]={0};
  10810. uint8_t word[2048]={0};
  10811. FILE *filePtr;
  10812. json_object *RemoteStartTransaction;
  10813. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  10814. RemoteStartTransaction = json_tokener_parse(payload);
  10815. if(!is_error(RemoteStartTransaction))
  10816. {
  10817. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  10818. {
  10819. gun_index = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  10820. }
  10821. else
  10822. {
  10823. /*
  10824. * TODO:
  10825. * 1. Selected connector process
  10826. */
  10827. gun_index = 0;
  10828. }
  10829. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  10830. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  10831. // Required data
  10832. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  10833. {
  10834. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  10835. }
  10836. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  10837. {
  10838. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  10839. {
  10840. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  10841. }
  10842. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  10843. {
  10844. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  10845. }
  10846. }
  10847. // Optional data
  10848. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  10849. {
  10850. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  10851. {
  10852. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  10853. }
  10854. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  10855. {
  10856. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  10857. }
  10858. }
  10859. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  10860. {
  10861. // Check periods is over max configuration
  10862. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  10863. {
  10864. isPeriodOverMax = TRUE;
  10865. }
  10866. // Check periods is over max configuration
  10867. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  10868. {
  10869. if(gun_index > 0)
  10870. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  10871. else
  10872. isConnectorMismatch = TRUE;
  10873. if(!isConnectorMismatch)
  10874. {
  10875. filePtr = fopen((char*)filename, "r");
  10876. if (!filePtr)
  10877. {
  10878. DEBUG_INFO("%s not exist, create it.\n", filename);
  10879. filePtr = fopen((char*)filename, "w+");
  10880. }
  10881. else
  10882. {
  10883. //Check Charging Profile Count
  10884. while(fscanf(filePtr, "%s", word) != EOF)
  10885. {
  10886. //DEBUG_INFO("word=%s\n",word);
  10887. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10888. {
  10889. existProfileQuantity += 1;
  10890. }
  10891. }
  10892. }
  10893. fclose(filePtr);
  10894. }
  10895. }
  10896. else
  10897. {
  10898. }
  10899. if(existProfileQuantity > 3)
  10900. isProfileOverMax = TRUE;
  10901. }
  10902. // Profile replace or add info
  10903. if((gun_index > 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTxProfile)
  10904. {
  10905. FILE *infile;
  10906. FILE *outfile;
  10907. char tmpProfileName[32];
  10908. char rmFileCmd[128];
  10909. char tempchargingProfilePurposeStr[30]={0};
  10910. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  10911. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  10912. infile = fopen ((char*)filename, "r");
  10913. outfile = fopen ((char*)tmpProfileName, "w");
  10914. int d = fgetc(infile);
  10915. rewind(infile);
  10916. if(d == EOF)
  10917. {
  10918. // Profile is empty
  10919. fprintf(outfile,"%s\n", payload);
  10920. fclose(infile);
  10921. fclose(outfile);
  10922. sprintf(rmFileCmd,"rm -f %s",filename);
  10923. system(rmFileCmd);
  10924. rename((char*)tmpProfileName, (char*)filename);
  10925. }
  10926. else
  10927. {
  10928. // Profile is not empty
  10929. char buf[2048]={0};
  10930. int ChargingProfileAdded = FALSE;
  10931. while (fgets(buf, sizeof(buf), infile) != NULL)
  10932. {
  10933. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  10934. json_object *tmpChargingProfile;
  10935. tmpChargingProfile = json_tokener_parse(buf);
  10936. if(!is_error(tmpChargingProfile))
  10937. {
  10938. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  10939. {
  10940. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  10941. }
  10942. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  10943. {
  10944. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  10945. {
  10946. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  10947. }
  10948. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  10949. {
  10950. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  10951. }
  10952. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  10953. {
  10954. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  10955. }
  10956. }
  10957. }
  10958. json_object_put(tmpChargingProfile);
  10959. if((tempconnectorIdInt == gun_index) &&
  10960. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  10961. {
  10962. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  10963. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  10964. {
  10965. if(ChargingProfileAdded == FALSE)
  10966. {
  10967. fprintf(outfile,"%s\n",payload);
  10968. ChargingProfileAdded = TRUE;
  10969. }
  10970. }
  10971. else
  10972. {
  10973. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10974. {
  10975. if(ChargingProfileAdded == FALSE)
  10976. {
  10977. fprintf(outfile,"%s\n",buf);
  10978. fprintf(outfile,"%s\n",payload);
  10979. ChargingProfileAdded = TRUE;
  10980. }
  10981. else
  10982. {
  10983. fprintf(outfile,"%s\n",buf);
  10984. }
  10985. }
  10986. else
  10987. {
  10988. if(ChargingProfileAdded == FALSE)
  10989. {
  10990. fprintf(outfile,"%s\n",buf);
  10991. fprintf(outfile,"%s\n",payload);
  10992. ChargingProfileAdded = TRUE;
  10993. }
  10994. else
  10995. {
  10996. fprintf(outfile,"%s\n",buf);
  10997. }
  10998. }
  10999. }
  11000. }
  11001. else
  11002. {
  11003. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  11004. {
  11005. if(ChargingProfileAdded == FALSE)
  11006. {
  11007. fprintf(outfile,"%s\n",buf);
  11008. fprintf(outfile,"%s\n",payload);
  11009. ChargingProfileAdded = TRUE;
  11010. }
  11011. else
  11012. {
  11013. fprintf(outfile,"%s\n",buf);
  11014. }
  11015. }
  11016. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  11017. {
  11018. if(ChargingProfileAdded == FALSE)
  11019. {
  11020. fprintf(outfile,"%s\n",buf);
  11021. fprintf(outfile,"%s\n",payload);
  11022. ChargingProfileAdded = TRUE;
  11023. }
  11024. else
  11025. {
  11026. fprintf(outfile,"%s\n",buf);
  11027. }
  11028. }
  11029. else
  11030. {
  11031. if(ChargingProfileAdded == FALSE)
  11032. {
  11033. fprintf(outfile,"%s\n",buf);
  11034. fprintf(outfile,"%s\n",payload);
  11035. ChargingProfileAdded = TRUE;
  11036. }
  11037. else
  11038. {
  11039. fprintf(outfile,"%s\n",buf);
  11040. }
  11041. }
  11042. }
  11043. } // end of while loop
  11044. fclose(infile);
  11045. fclose(outfile);
  11046. sprintf(rmFileCmd,"rm -f %s",filename);
  11047. system(rmFileCmd);
  11048. rename((char*)tmpProfileName, (char*)filename);
  11049. }
  11050. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  11051. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_transactionId);
  11052. result = PASS;
  11053. }
  11054. else
  11055. {
  11056. if(gun_index <= 0)
  11057. DEBUG_WARN("Connector id is wrong.\n");
  11058. if(isConnectorMismatch)
  11059. DEBUG_WARN("Connector id is mismatch.\n");
  11060. if(isPeriodOverMax)
  11061. DEBUG_WARN("Profile periods quantity is over spec.\n");
  11062. if(isProfileOverMax)
  11063. DEBUG_WARN("Profile quantity is over spec.\n");
  11064. if(!isTxProfile)
  11065. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  11066. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  11067. }
  11068. }
  11069. json_object_put(RemoteStartTransaction);
  11070. sendRemoteStartTransactionConfirmation(uuid, gun_index);
  11071. return result;
  11072. }
  11073. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  11074. {
  11075. mtrace();
  11076. int result = FAIL;
  11077. int match = FALSE;
  11078. int GunNO = 0;
  11079. int tempIndex = 0;
  11080. char transactionIdStr[37];
  11081. int transactionIdIsNULL= TRUE;
  11082. json_object *RemoteStopTransaction;
  11083. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  11084. if(server_pending == TRUE)
  11085. {
  11086. return 0;
  11087. }
  11088. RemoteStopTransaction = json_tokener_parse(payload);
  11089. if(!is_error(RemoteStopTransaction))
  11090. {
  11091. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  11092. {
  11093. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  11094. transactionIdIsNULL = FALSE;
  11095. }
  11096. }
  11097. json_object_put(RemoteStopTransaction);
  11098. if(transactionIdIsNULL == FALSE)
  11099. {
  11100. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  11101. {
  11102. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  11103. {
  11104. //check Transaction active
  11105. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  11106. {
  11107. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11108. {
  11109. tempIndex = ((gun_index==2) ? 1: 0);
  11110. }
  11111. else
  11112. {
  11113. tempIndex = gun_index;
  11114. }
  11115. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11116. {
  11117. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  11118. {
  11119. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11120. {
  11121. match = TRUE;
  11122. GunNO = gun_index;
  11123. }
  11124. }
  11125. }// END FOR CHAdeMO_QUANTITY
  11126. }
  11127. else if(gunType[gun_index] == GUN_TYPE_CCS)
  11128. {
  11129. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11130. {
  11131. tempIndex = ((gun_index==2) ? 1: 0);
  11132. }
  11133. else
  11134. {
  11135. tempIndex = gun_index;
  11136. }
  11137. for (int index = 0; index < CCS_QUANTITY; index++)
  11138. {
  11139. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  11140. {
  11141. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11142. {
  11143. match = TRUE;
  11144. GunNO = gun_index;
  11145. }
  11146. }
  11147. }// END FOR CCS_QUANTITY
  11148. }
  11149. else if(gunType[gun_index] == GUN_TYPE_GBT)
  11150. {
  11151. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11152. {
  11153. tempIndex = ((gun_index==2) ? 1: 0);
  11154. }
  11155. else
  11156. {
  11157. tempIndex = gun_index;
  11158. }
  11159. for (int index = 0; index < GB_QUANTITY; index++)
  11160. {
  11161. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  11162. {
  11163. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11164. {
  11165. match = TRUE;
  11166. GunNO = gun_index;
  11167. }
  11168. }
  11169. }// END FOR GB_QUANTITY
  11170. }
  11171. else if(gunType[gun_index] == GUN_TYPE_DO)
  11172. {
  11173. tempIndex = gun_index;
  11174. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11175. {
  11176. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  11177. {
  11178. 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
  11179. {
  11180. match = TRUE;
  11181. GunNO = gun_index;
  11182. }
  11183. }
  11184. }// END FOR GB_QUANTITY
  11185. }
  11186. else
  11187. {
  11188. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11189. {
  11190. tempIndex = 2;
  11191. }
  11192. else
  11193. {
  11194. tempIndex = gun_index;
  11195. }
  11196. for (int index = 0; index < AC_QUANTITY; index++)
  11197. {
  11198. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11199. {
  11200. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11201. {
  11202. match = TRUE;
  11203. GunNO = gun_index;
  11204. }
  11205. }
  11206. }// END FOR CHAdeMO_QUANTITY
  11207. } // END FOR AC ELSE
  11208. }// CHECK IF ResponseTransactionId == transactionIdInt
  11209. }//END FOR
  11210. if( match == TRUE)
  11211. {
  11212. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  11213. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  11214. }
  11215. else
  11216. {
  11217. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  11218. }
  11219. }
  11220. else
  11221. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  11222. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  11223. return result;
  11224. }
  11225. int handleReserveNowRequest(char *uuid, char *payload)
  11226. {
  11227. mtrace();
  11228. int result = FAIL;
  11229. int connectorIdInt=0, reservationIdInt=0;
  11230. int tempIndex = 0;
  11231. json_object *ReserveNow;
  11232. DEBUG_INFO("handleReserveNowRequest ...\n");
  11233. ReserveNow = json_tokener_parse(payload);
  11234. if(!is_error(ReserveNow))
  11235. {
  11236. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  11237. {
  11238. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  11239. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  11240. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  11241. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  11242. }
  11243. // Required data
  11244. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  11245. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  11246. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  11247. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  11248. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  11249. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  11250. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  11251. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  11252. // Optional data
  11253. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  11254. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  11255. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  11256. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  11257. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  11258. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  11259. result = PASS;
  11260. }
  11261. json_object_put(ReserveNow);
  11262. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11263. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  11264. {
  11265. //check Transaction active
  11266. if(gunType[connectorIdInt -1] == GUN_TYPE_CHAdeMO)
  11267. {
  11268. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11269. {
  11270. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11271. }
  11272. else
  11273. {
  11274. tempIndex = connectorIdInt -1;
  11275. }
  11276. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11277. {
  11278. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  11279. {
  11280. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11281. {
  11282. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11283. {
  11284. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11285. {
  11286. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11287. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11288. }
  11289. 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'))
  11290. {
  11291. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11292. }
  11293. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11294. {
  11295. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11296. }
  11297. else
  11298. {
  11299. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11300. }
  11301. }
  11302. 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
  11303. {
  11304. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11305. }
  11306. }
  11307. else
  11308. {
  11309. //replace reservation
  11310. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11311. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11312. }
  11313. }
  11314. } // END FOR CHAdeMO_QUANTITY
  11315. }
  11316. else if(gunType[connectorIdInt -1] == GUN_TYPE_CCS)
  11317. {
  11318. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11319. {
  11320. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11321. }
  11322. else
  11323. {
  11324. tempIndex = connectorIdInt -1;
  11325. }
  11326. for (int index = 0; index < CCS_QUANTITY; index++)
  11327. {
  11328. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  11329. {
  11330. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11331. {
  11332. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11333. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11334. {
  11335. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11336. {
  11337. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11338. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11339. }
  11340. 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'))
  11341. {
  11342. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11343. }
  11344. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  11345. {
  11346. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11347. }
  11348. else
  11349. {
  11350. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11351. }
  11352. }
  11353. 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
  11354. {
  11355. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11356. }
  11357. }
  11358. else
  11359. {
  11360. //replace reservation
  11361. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11362. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11363. }
  11364. }
  11365. } // END FOR CCS_QUANTITY
  11366. }
  11367. else if(gunType[connectorIdInt -1] == GUN_TYPE_GBT)
  11368. {
  11369. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11370. {
  11371. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11372. }
  11373. else
  11374. {
  11375. tempIndex = connectorIdInt -1;
  11376. }
  11377. for (int index = 0; index < GB_QUANTITY; index++)
  11378. {
  11379. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  11380. {
  11381. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11382. {
  11383. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11384. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11385. {
  11386. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11387. {
  11388. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11389. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11390. }
  11391. 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'))
  11392. {
  11393. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11394. }
  11395. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11396. {
  11397. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11398. }
  11399. else
  11400. {
  11401. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11402. }
  11403. }
  11404. 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
  11405. {
  11406. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11407. }
  11408. }
  11409. else
  11410. {
  11411. //replace reservation
  11412. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11413. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11414. }
  11415. }
  11416. }// END FOR GB_QUANTITY
  11417. }
  11418. else if(gunType[connectorIdInt -1] == GUN_TYPE_DO)
  11419. {
  11420. tempIndex = connectorIdInt -1;
  11421. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11422. {
  11423. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  11424. {
  11425. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId)
  11426. {
  11427. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11428. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11429. {
  11430. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11431. {
  11432. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11433. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11434. }
  11435. 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)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '9'))
  11436. {
  11437. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11438. }
  11439. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11440. {
  11441. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11442. }
  11443. else
  11444. {
  11445. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11446. }
  11447. }
  11448. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus ==SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus ==SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_TERMINATING)) //SYS_MODE_FAULT, SYS_MODE_ALARM ,SYS_MODE_TERMINATING ---> SuspendedEV
  11449. {
  11450. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11451. }
  11452. }
  11453. else
  11454. {
  11455. //replace reservation
  11456. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11457. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11458. }
  11459. }
  11460. }// END FOR DO_QUANTITY
  11461. }
  11462. else
  11463. {
  11464. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11465. {
  11466. tempIndex = 2;
  11467. }
  11468. else
  11469. {
  11470. tempIndex = (connectorIdInt -1);
  11471. }
  11472. for (int index = 0; index < AC_QUANTITY; index++)
  11473. {
  11474. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11475. {
  11476. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11477. {
  11478. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11479. {
  11480. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11481. {
  11482. 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))
  11483. {
  11484. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11485. }
  11486. else
  11487. {
  11488. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11489. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11490. }
  11491. }
  11492. 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'))
  11493. {
  11494. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11495. }
  11496. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11497. {
  11498. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11499. }
  11500. else
  11501. {
  11502. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11503. }
  11504. }
  11505. 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
  11506. {
  11507. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11508. }
  11509. }
  11510. else
  11511. {
  11512. //replace reservation
  11513. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11514. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11515. }
  11516. }
  11517. } // END FOR AC_QUANTITY
  11518. }
  11519. }
  11520. else if(connectorIdInt == 0)
  11521. {
  11522. //check Transaction active
  11523. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11524. {
  11525. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11526. {
  11527. 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'))
  11528. {
  11529. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11530. goto end;
  11531. }
  11532. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11533. {
  11534. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11535. goto end;
  11536. }
  11537. 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
  11538. {
  11539. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11540. goto end;
  11541. }
  11542. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11543. {
  11544. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11545. goto end;
  11546. }
  11547. }
  11548. }// END FOR CHAdeMO_QUANTITY
  11549. for (int index = 0; index < CCS_QUANTITY; index++)
  11550. {
  11551. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11552. {
  11553. 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'))
  11554. {
  11555. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11556. goto end;
  11557. }
  11558. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  11559. {
  11560. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11561. goto end;
  11562. }
  11563. 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
  11564. {
  11565. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11566. goto end;
  11567. }
  11568. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11569. {
  11570. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11571. goto end;
  11572. }
  11573. }
  11574. } // END FOR CCS_QUANTITY
  11575. for (int index = 0; index < GB_QUANTITY; index++)
  11576. {
  11577. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11578. {
  11579. 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'))
  11580. {
  11581. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11582. goto end;
  11583. }
  11584. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11585. {
  11586. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11587. goto end;
  11588. }
  11589. 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
  11590. {
  11591. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11592. goto end;
  11593. }
  11594. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11595. {
  11596. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11597. goto end;
  11598. }
  11599. }
  11600. } // END FOR GB_QUANTITY
  11601. for (int index = 0; index < AC_QUANTITY; index++)
  11602. {
  11603. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11604. {
  11605. 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'))
  11606. {
  11607. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11608. goto end;
  11609. }
  11610. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11611. {
  11612. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11613. goto end;
  11614. }
  11615. 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
  11616. {
  11617. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11618. goto end;
  11619. }
  11620. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11621. {
  11622. 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))
  11623. {
  11624. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11625. goto end;
  11626. }
  11627. }
  11628. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11629. {
  11630. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11631. goto end;
  11632. }
  11633. }
  11634. }// END FOR AC_QUANTITY
  11635. //The connectorId is 0
  11636. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  11637. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11638. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  11639. result = TRUE;
  11640. return result;
  11641. }
  11642. else
  11643. {
  11644. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11645. }
  11646. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  11647. {
  11648. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  11649. result = TRUE;
  11650. return result;
  11651. }
  11652. end:
  11653. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  11654. return result;
  11655. }
  11656. int handleResetRequest(char *uuid, char *payload)
  11657. {
  11658. mtrace();
  11659. int result = FAIL;
  11660. json_object *Reset = json_object_new_object();
  11661. DEBUG_INFO("handleResetRequest...\n");
  11662. Reset = json_tokener_parse(payload);
  11663. if(!is_error(Reset))
  11664. {
  11665. // Required data
  11666. if(json_object_object_get(Reset, "type") != NULL)
  11667. {
  11668. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  11669. }
  11670. if(json_object_object_get(Reset, "evseId") != NULL)
  11671. {
  11672. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  11673. }
  11674. }
  11675. json_object_put(Reset);
  11676. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  11677. {
  11678. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  11679. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  11680. if(!GetServerSign())
  11681. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]);
  11682. result = TRUE;
  11683. }
  11684. else
  11685. {
  11686. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  11687. }
  11688. if(strlen((char*)ShmOCPP20Data->Reset.Response_status) > 0)
  11689. sendResetConfirmation(uuid);
  11690. return result;
  11691. }
  11692. int handleSendLocalListRequest(char *uuid, char *payload)
  11693. {
  11694. mtrace();
  11695. int result = FAIL;
  11696. char updateTypestr[15]={0};
  11697. int checkState_Faulted = FALSE;
  11698. json_object *SendLocalList;
  11699. DEBUG_INFO("handleSendLocalListRequest...\n");
  11700. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  11701. {
  11702. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11703. goto end;
  11704. }
  11705. SendLocalList = json_tokener_parse(payload);
  11706. if(!is_error(SendLocalList))
  11707. {
  11708. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  11709. // Required data
  11710. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  11711. {
  11712. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  11713. }
  11714. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  11715. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  11716. // Optional data
  11717. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  11718. {
  11719. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  11720. {
  11721. // Required data
  11722. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  11723. {
  11724. 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")));
  11725. 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")));
  11726. }
  11727. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  11728. {
  11729. 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")));
  11730. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  11731. 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")));
  11732. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  11733. 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"));
  11734. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  11735. {
  11736. 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")));
  11737. 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")));
  11738. }
  11739. }
  11740. }
  11741. }
  11742. }
  11743. json_object_put(SendLocalList);
  11744. //check Charge Point state
  11745. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11746. {
  11747. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11748. {
  11749. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11750. }
  11751. }
  11752. for (int index = 0; index < CCS_QUANTITY; index++)
  11753. {
  11754. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11755. {
  11756. checkState_Faulted = TRUE; //OCPP Status
  11757. }
  11758. }
  11759. for (int index = 0; index < GB_QUANTITY; index++)
  11760. {
  11761. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11762. {
  11763. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11764. }
  11765. }
  11766. for (int index = 0; index < AC_QUANTITY; index++)
  11767. {
  11768. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11769. {
  11770. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11771. }
  11772. }
  11773. if(checkState_Faulted == TRUE)
  11774. {
  11775. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11776. goto end;
  11777. }
  11778. // Check update type
  11779. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  11780. {
  11781. //Local list full update
  11782. DEBUG_INFO("Local list full update.\n");
  11783. DB_getListVerion();
  11784. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11785. {
  11786. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11787. goto end;
  11788. }
  11789. DB_cleanLocalList();
  11790. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11791. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11792. }
  11793. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  11794. {
  11795. //Local list different update
  11796. DEBUG_INFO("Local list different update.\n");
  11797. DB_getListVerion();
  11798. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11799. {
  11800. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  11801. goto end;
  11802. }
  11803. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11804. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11805. }
  11806. else
  11807. {
  11808. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11809. goto end;
  11810. }
  11811. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  11812. end:
  11813. sendSendLocalListConfirmation(uuid);
  11814. return result;
  11815. }
  11816. int handleSetChargingProfileRequest(char *uuid, char *payload)
  11817. {
  11818. mtrace();
  11819. int result = FAIL;
  11820. int8_t gun_index = -1;
  11821. uint8_t isPeriodOverMax = FALSE;
  11822. uint8_t isProfileOverMax = FALSE;
  11823. uint8_t isConnectorMismatch = FALSE;
  11824. uint8_t existProfileQuantity = 0;
  11825. uint8_t filename[128]={0};
  11826. uint8_t word[2048]={0};
  11827. FILE *filePtr;
  11828. json_object *SetChargingProfile;
  11829. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  11830. SetChargingProfile = json_tokener_parse(payload);
  11831. if(!is_error(SetChargingProfile))
  11832. {
  11833. // Required data
  11834. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  11835. {
  11836. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  11837. }
  11838. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  11839. {
  11840. // Check periods is over max configuration
  11841. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  11842. {
  11843. isPeriodOverMax = TRUE;
  11844. }
  11845. // Check periods is over max configuration
  11846. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  11847. {
  11848. if(gun_index == 0)
  11849. {
  11850. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  11851. filePtr = fopen((char*)filename, "r");
  11852. if (!filePtr)
  11853. {
  11854. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  11855. filePtr = fopen((char*)filename, "w+");
  11856. }
  11857. else
  11858. {
  11859. //Check Charging Profile Count
  11860. while(fscanf(filePtr, "%s", word) != EOF)
  11861. {
  11862. //DEBUG_INFO("word=%s\n",word);
  11863. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11864. {
  11865. existProfileQuantity += 1;
  11866. }
  11867. }
  11868. }
  11869. fclose(filePtr);
  11870. }
  11871. else
  11872. isConnectorMismatch = TRUE;
  11873. }
  11874. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  11875. {
  11876. if(gun_index < 5)
  11877. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  11878. else
  11879. isConnectorMismatch = TRUE;
  11880. if(!isConnectorMismatch)
  11881. {
  11882. filePtr = fopen((char*)filename, "r");
  11883. if (!filePtr)
  11884. {
  11885. DEBUG_INFO("%s not exist, create it.\n", filename);
  11886. filePtr = fopen((char*)filename, "w+");
  11887. }
  11888. else
  11889. {
  11890. //Check Charging Profile Count
  11891. while(fscanf(filePtr, "%s", word) != EOF)
  11892. {
  11893. //DEBUG_INFO("word=%s\n",word);
  11894. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11895. {
  11896. existProfileQuantity += 1;
  11897. }
  11898. }
  11899. }
  11900. fclose(filePtr);
  11901. }
  11902. }
  11903. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  11904. {
  11905. if(gun_index>0)
  11906. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  11907. else
  11908. isConnectorMismatch = TRUE;
  11909. if(!isConnectorMismatch)
  11910. {
  11911. filePtr = fopen((char*)filename, "r");
  11912. if (!filePtr)
  11913. {
  11914. DEBUG_INFO("%s not exist, create it.\n", filename);
  11915. filePtr = fopen((char*)filename, "w+");
  11916. }
  11917. else
  11918. {
  11919. //Check Charging Profile Count
  11920. while(fscanf(filePtr, "%s", word) != EOF)
  11921. {
  11922. //DEBUG_INFO("word=%s\n",word);
  11923. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11924. {
  11925. existProfileQuantity += 1;
  11926. }
  11927. }
  11928. }
  11929. fclose(filePtr);
  11930. }
  11931. }
  11932. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  11933. {
  11934. }
  11935. else
  11936. {
  11937. }
  11938. if(existProfileQuantity > 3)
  11939. isProfileOverMax = TRUE;
  11940. }
  11941. // Profile replace or add info
  11942. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  11943. {
  11944. FILE *infile;
  11945. FILE *outfile;
  11946. char tmpProfileName[32];
  11947. char rmFileCmd[128];
  11948. char tempchargingProfilePurposeStr[30]={0};
  11949. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  11950. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  11951. infile = fopen ((char*)filename, "r");
  11952. outfile = fopen ((char*)tmpProfileName, "w");
  11953. int d = fgetc(infile);
  11954. rewind(infile);
  11955. if(d == EOF)
  11956. {
  11957. // Profile is empty
  11958. fprintf(outfile,"%s\n", payload);
  11959. fclose(infile);
  11960. fclose(outfile);
  11961. sprintf(rmFileCmd,"rm -f %s",filename);
  11962. system(rmFileCmd);
  11963. rename((char*)tmpProfileName, (char*)filename);
  11964. }
  11965. else
  11966. {
  11967. // Profile is not empty
  11968. char buf[2048]={0};
  11969. int ChargingProfileAdded = FALSE;
  11970. while (fgets(buf, sizeof(buf), infile) != NULL)
  11971. {
  11972. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  11973. json_object *tmpChargingProfile;
  11974. tmpChargingProfile = json_tokener_parse(buf);
  11975. if(!is_error(tmpChargingProfile))
  11976. {
  11977. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  11978. {
  11979. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  11980. }
  11981. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  11982. {
  11983. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  11984. {
  11985. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  11986. }
  11987. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  11988. {
  11989. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  11990. }
  11991. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  11992. {
  11993. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  11994. }
  11995. }
  11996. }
  11997. json_object_put(tmpChargingProfile);
  11998. if((tempconnectorIdInt == gun_index) &&
  11999. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  12000. {
  12001. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  12002. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  12003. {
  12004. //DEBUG_INFO("update set chargingProfile to file -0\n");
  12005. if(ChargingProfileAdded == FALSE)
  12006. {
  12007. fprintf(outfile,"%s\n",payload);
  12008. ChargingProfileAdded = TRUE;
  12009. }
  12010. }
  12011. else
  12012. {
  12013. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  12014. {
  12015. if(ChargingProfileAdded == FALSE)
  12016. {
  12017. fprintf(outfile,"%s\n",buf);
  12018. fprintf(outfile,"%s\n",payload);
  12019. ChargingProfileAdded = TRUE;
  12020. }
  12021. else
  12022. {
  12023. fprintf(outfile,"%s\n",buf);
  12024. }
  12025. }
  12026. else
  12027. {
  12028. if(ChargingProfileAdded == FALSE)
  12029. {
  12030. fprintf(outfile,"%s\n",buf);
  12031. fprintf(outfile,"%s\n",payload);
  12032. ChargingProfileAdded = TRUE;
  12033. }
  12034. else
  12035. {
  12036. fprintf(outfile,"%s\n",buf);
  12037. }
  12038. }
  12039. }
  12040. }
  12041. else
  12042. {
  12043. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
  12044. {
  12045. if(ChargingProfileAdded == FALSE)
  12046. {
  12047. fprintf(outfile,"%s\n",buf);
  12048. fprintf(outfile,"%s\n",payload);
  12049. ChargingProfileAdded = TRUE;
  12050. }
  12051. else
  12052. {
  12053. fprintf(outfile,"%s\n",buf);
  12054. }
  12055. }
  12056. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  12057. {
  12058. if(ChargingProfileAdded == FALSE)
  12059. {
  12060. fprintf(outfile,"%s\n",buf);
  12061. fprintf(outfile,"%s\n",payload);
  12062. ChargingProfileAdded = TRUE;
  12063. }
  12064. else
  12065. {
  12066. fprintf(outfile,"%s\n",buf);
  12067. }
  12068. }
  12069. else
  12070. {
  12071. if(ChargingProfileAdded == FALSE)
  12072. {
  12073. fprintf(outfile,"%s\n",buf);
  12074. fprintf(outfile,"%s\n",payload);
  12075. ChargingProfileAdded = TRUE;
  12076. }
  12077. else
  12078. {
  12079. fprintf(outfile,"%s\n",buf);
  12080. }
  12081. }
  12082. }
  12083. } // end of while loop
  12084. fclose(infile);
  12085. fclose(outfile);
  12086. sprintf(rmFileCmd,"rm -f %s",filename);
  12087. system(rmFileCmd);
  12088. rename((char*)tmpProfileName, (char*)filename);
  12089. }
  12090. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  12091. result = PASS;
  12092. }
  12093. else
  12094. {
  12095. if(gun_index == -1)
  12096. DEBUG_WARN("Connector id is wrong.\n");
  12097. if(isConnectorMismatch)
  12098. DEBUG_WARN("Connector id is mismatch.\n");
  12099. if(isPeriodOverMax)
  12100. DEBUG_WARN("Profile periods quantity is over spec.\n");
  12101. if(isProfileOverMax)
  12102. DEBUG_WARN("Profile quantity is over spec.\n");
  12103. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  12104. }
  12105. }
  12106. json_object_put(SetChargingProfile);
  12107. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  12108. {
  12109. if(gun_index == 0)
  12110. {
  12111. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  12112. {
  12113. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  12114. }
  12115. }
  12116. else
  12117. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1]);
  12118. }
  12119. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  12120. return result;
  12121. }
  12122. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  12123. {
  12124. mtrace();
  12125. int result = FAIL;
  12126. json_object *SetDisplayMessage;
  12127. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  12128. SetDisplayMessage = json_tokener_parse(payload);
  12129. if(!is_error(SetDisplayMessage))
  12130. {
  12131. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  12132. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  12133. // Required data
  12134. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  12135. {
  12136. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  12137. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  12138. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  12139. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  12140. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  12141. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  12142. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  12143. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  12144. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  12145. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  12146. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  12147. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  12148. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  12149. {
  12150. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  12151. 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")));
  12152. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  12153. 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")));
  12154. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  12155. 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")));
  12156. }
  12157. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  12158. {
  12159. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  12160. 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")));
  12161. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  12162. 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")));
  12163. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  12164. {
  12165. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  12166. 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"));
  12167. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  12168. 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"));
  12169. }
  12170. }
  12171. }
  12172. }
  12173. json_object_put(SetDisplayMessage);
  12174. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  12175. sendSetMonitoringBaseConfirmation(uuid);
  12176. // Anouce CSU there is display request come from server
  12177. ShmOCPP20Data->MsMsg.bits.SetDisplayMessageReq = ON;
  12178. return result;
  12179. }
  12180. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  12181. {
  12182. mtrace();
  12183. int result = FAIL;
  12184. json_object *SetMonitoringBase;
  12185. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  12186. SetMonitoringBase = json_tokener_parse(payload);
  12187. if(!is_error(SetMonitoringBase))
  12188. {
  12189. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  12190. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  12191. // Required data
  12192. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  12193. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  12194. }
  12195. json_object_put(SetMonitoringBase);
  12196. /*
  12197. * TODO:
  12198. * 1. Configure monitor base and response
  12199. */
  12200. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12201. sendSetMonitoringBaseConfirmation(uuid);
  12202. return result;
  12203. }
  12204. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  12205. {
  12206. mtrace();
  12207. int result = FAIL;
  12208. json_object *SetMonitoringLevel;
  12209. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  12210. SetMonitoringLevel = json_tokener_parse(payload);
  12211. if(!is_error(SetMonitoringLevel))
  12212. {
  12213. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  12214. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  12215. // Required data
  12216. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  12217. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  12218. }
  12219. json_object_put(SetMonitoringLevel);
  12220. /*
  12221. * TODO:
  12222. * Configure monitor status and response
  12223. */
  12224. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12225. sendSetMonitoringLevelConfirmation(uuid);
  12226. return result;
  12227. }
  12228. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  12229. {
  12230. mtrace();
  12231. int result = FAIL;
  12232. json_object *SetNetworkProfile;
  12233. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  12234. SetNetworkProfile = json_tokener_parse(payload);
  12235. if(!is_error(SetNetworkProfile))
  12236. {
  12237. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  12238. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  12239. // Required data
  12240. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  12241. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  12242. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  12243. {
  12244. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  12245. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  12246. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  12247. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  12248. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  12249. {
  12250. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  12251. memcpy((char*)ShmOCPP20Data->OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  12252. }
  12253. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  12254. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  12255. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  12256. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  12257. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  12258. {
  12259. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  12260. 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")));
  12261. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  12262. 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")));
  12263. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  12264. 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")));
  12265. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  12266. 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")));
  12267. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  12268. 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")));
  12269. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  12270. 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")));
  12271. }
  12272. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  12273. {
  12274. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  12275. {
  12276. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  12277. 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")));
  12278. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  12279. }
  12280. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  12281. {
  12282. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  12283. 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")));
  12284. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  12285. }
  12286. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  12287. {
  12288. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  12289. 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")));
  12290. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  12291. }
  12292. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  12293. 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"));
  12294. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  12295. 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")));
  12296. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  12297. 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"));
  12298. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  12299. 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")));
  12300. }
  12301. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  12302. }
  12303. }
  12304. json_object_put(SetNetworkProfile);
  12305. /*
  12306. * TODO:
  12307. * 1. Process network configuration and response
  12308. */
  12309. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  12310. {
  12311. }
  12312. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  12313. {
  12314. }
  12315. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  12316. {
  12317. }
  12318. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  12319. {
  12320. }
  12321. else
  12322. {
  12323. }
  12324. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  12325. {
  12326. }
  12327. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  12328. {
  12329. }
  12330. else
  12331. {
  12332. }
  12333. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  12334. {
  12335. }
  12336. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  12337. {
  12338. }
  12339. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  12340. {
  12341. }
  12342. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  12343. {
  12344. }
  12345. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  12346. {
  12347. }
  12348. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  12349. {
  12350. }
  12351. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  12352. {
  12353. }
  12354. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  12355. {
  12356. }
  12357. else
  12358. {
  12359. }
  12360. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  12361. {
  12362. }
  12363. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  12364. {
  12365. }
  12366. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  12367. {
  12368. }
  12369. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  12370. {
  12371. }
  12372. else
  12373. {
  12374. }
  12375. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  12376. {
  12377. }
  12378. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  12379. {
  12380. }
  12381. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  12382. {
  12383. }
  12384. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  12385. {
  12386. }
  12387. else
  12388. {
  12389. }
  12390. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  12391. sendSetNetworkProfileConfirmation(uuid);
  12392. return result;
  12393. }
  12394. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  12395. {
  12396. mtrace();
  12397. int result = FAIL;
  12398. json_object *SetVariableMonitoring;
  12399. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  12400. SetVariableMonitoring = json_tokener_parse(payload);
  12401. if(!is_error(SetVariableMonitoring))
  12402. {
  12403. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  12404. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  12405. // Required data
  12406. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  12407. {
  12408. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  12409. {
  12410. 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"));
  12411. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  12412. }
  12413. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  12414. {
  12415. 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"));
  12416. /*
  12417. * TODO:
  12418. * 1. Check monitor value status
  12419. */
  12420. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, MonitorEnumTypeStr[MonitorEnumType_Delta]);
  12421. }
  12422. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  12423. {
  12424. 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")));
  12425. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  12426. }
  12427. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  12428. {
  12429. 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"));
  12430. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  12431. }
  12432. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  12433. {
  12434. 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"));
  12435. }
  12436. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  12437. {
  12438. 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)
  12439. {
  12440. 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")));
  12441. }
  12442. 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)
  12443. {
  12444. 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")));
  12445. }
  12446. 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)
  12447. {
  12448. 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)
  12449. {
  12450. 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"));
  12451. }
  12452. 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)
  12453. {
  12454. 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"));
  12455. }
  12456. }
  12457. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  12458. }
  12459. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  12460. {
  12461. 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)
  12462. {
  12463. 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")));
  12464. }
  12465. 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)
  12466. {
  12467. 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")));
  12468. }
  12469. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  12470. }
  12471. }
  12472. }
  12473. json_object_put(SetVariableMonitoring);
  12474. return result;
  12475. }
  12476. int handleSetVariablesRequest(char *uuid, char *payload)
  12477. {
  12478. mtrace();
  12479. int result = FAIL;
  12480. json_object *SetVariables;
  12481. DEBUG_INFO("handleSetVariablesRequest...\n");
  12482. SetVariables = json_tokener_parse(payload);
  12483. if(!is_error(SetVariables))
  12484. {
  12485. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  12486. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  12487. // Required data
  12488. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  12489. {
  12490. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  12491. {
  12492. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  12493. {
  12494. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  12495. {
  12496. 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")));
  12497. }
  12498. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  12499. {
  12500. 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")));
  12501. }
  12502. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  12503. {
  12504. 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)
  12505. {
  12506. 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"));
  12507. }
  12508. 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)
  12509. {
  12510. 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"));
  12511. }
  12512. }
  12513. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  12514. }
  12515. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  12516. {
  12517. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  12518. {
  12519. 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")));
  12520. }
  12521. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  12522. {
  12523. 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")));
  12524. }
  12525. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  12526. }
  12527. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  12528. {
  12529. 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")));
  12530. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  12531. }
  12532. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  12533. {
  12534. 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")));
  12535. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  12536. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  12537. {
  12538. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  12539. (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) &&
  12540. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  12541. (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))
  12542. {
  12543. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  12544. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  12545. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  12546. {
  12547. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  12548. }
  12549. else
  12550. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  12551. }
  12552. }
  12553. }
  12554. }
  12555. }
  12556. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  12557. }
  12558. json_object_put(SetVariables);
  12559. return result;
  12560. }
  12561. int handleTriggerMessageRequest(char *uuid, char *payload)
  12562. {
  12563. mtrace();
  12564. int result = FAIL;
  12565. int connectorIdIsNULL = FALSE;
  12566. int connectorIdInt =0;
  12567. char requestedMessagestr[40]={0};
  12568. json_object *TriggerMessage;
  12569. DEBUG_INFO("handleTriggerMessageRequest\n");
  12570. TriggerMessage = json_tokener_parse(payload);
  12571. if(!is_error(TriggerMessage))
  12572. {
  12573. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  12574. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  12575. // Required data
  12576. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  12577. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  12578. // Optional data
  12579. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  12580. {
  12581. // Required data
  12582. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  12583. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  12584. // Optional data
  12585. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  12586. {
  12587. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  12588. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  12589. }
  12590. else
  12591. connectorIdIsNULL = TRUE;
  12592. }
  12593. }
  12594. json_object_put(TriggerMessage);
  12595. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  12596. {
  12597. if((strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  12598. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  12599. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  12600. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  12601. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  12602. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  12603. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  12604. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  12605. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  12606. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  12607. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  12608. {
  12609. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  12610. sendTriggerMessageConfirmation(uuid);
  12611. return TRUE;
  12612. }
  12613. else
  12614. {
  12615. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  12616. sendTriggerMessageConfirmation(uuid);
  12617. }
  12618. }
  12619. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  12620. {
  12621. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  12622. sendTriggerMessageConfirmation(uuid);
  12623. return TRUE;
  12624. }
  12625. //==========================
  12626. // Trigger message
  12627. //==========================
  12628. if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  12629. {
  12630. if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
  12631. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
  12632. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
  12633. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
  12634. {
  12635. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  12636. }
  12637. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
  12638. }
  12639. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  12640. {
  12641. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
  12642. }
  12643. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  12644. {
  12645. if(DB_updateBootType(BootReasonEnumType_Triggered))
  12646. server_sign = FALSE;
  12647. }
  12648. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  12649. {
  12650. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  12651. }
  12652. else if (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  12653. {
  12654. if(connectorIdIsNULL == FALSE)
  12655. {
  12656. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12657. {
  12658. //sendMeterValuesRequest((connectorIdInt -1), ReadingContext_Trigger);
  12659. cpinitateMsg.bits[connectorIdInt -1].TriggerMeterValueReq = ON;
  12660. }
  12661. }
  12662. else
  12663. {
  12664. for(int idx=0;idx< gunTotalNumber;idx++)
  12665. {
  12666. //sendMeterValuesRequest(idx, ReadingContext_Trigger);
  12667. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  12668. }
  12669. }
  12670. }
  12671. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  12672. {
  12673. if(connectorIdIsNULL == FALSE)
  12674. {
  12675. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12676. {
  12677. cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = ON;
  12678. }
  12679. }
  12680. else
  12681. {
  12682. for(int idx=0;idx< gunTotalNumber;idx++)
  12683. cpinitateMsg.bits[idx].StatusNotificationReq = ON;
  12684. }
  12685. }
  12686. return result;
  12687. }
  12688. int handleUnlockConnectorRequest(char *uuid, char *payload)
  12689. {
  12690. mtrace();
  12691. int result = FAIL;
  12692. int connectorIdInt =0;
  12693. int tempIndex = 0;
  12694. json_object *UnlockConnector;
  12695. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  12696. UnlockConnector = json_tokener_parse(payload);
  12697. if(!is_error(UnlockConnector))
  12698. {
  12699. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  12700. {
  12701. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  12702. }
  12703. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  12704. {
  12705. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  12706. }
  12707. }
  12708. json_object_put(UnlockConnector);
  12709. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  12710. if(gunTotalNumber == 0)
  12711. {
  12712. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12713. goto end;
  12714. }
  12715. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  12716. {
  12717. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12718. goto end;
  12719. }
  12720. else
  12721. {
  12722. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  12723. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  12724. //check Transaction active
  12725. if(gunType[connectorIdInt-1] == GUN_TYPE_CHAdeMO)
  12726. {
  12727. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12728. {
  12729. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12730. }
  12731. else
  12732. {
  12733. tempIndex = connectorIdInt -1;
  12734. }
  12735. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12736. {
  12737. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12738. {
  12739. //stop Transaction
  12740. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12741. }
  12742. }
  12743. }
  12744. else if(gunType[connectorIdInt-1] == GUN_TYPE_CCS)
  12745. {
  12746. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12747. {
  12748. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12749. }
  12750. else
  12751. {
  12752. tempIndex = connectorIdInt -1;
  12753. }
  12754. for (int index = 0; index < CCS_QUANTITY; index++)
  12755. {
  12756. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12757. {
  12758. //stop Transaction
  12759. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12760. }
  12761. }
  12762. }
  12763. else if(gunType[connectorIdInt-1] == GUN_TYPE_GBT)
  12764. {
  12765. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12766. {
  12767. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12768. }
  12769. else
  12770. {
  12771. tempIndex = connectorIdInt -1;
  12772. }
  12773. for (int index = 0; index < GB_QUANTITY; index++)
  12774. {
  12775. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  12776. {
  12777. //stop Transaction
  12778. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12779. }
  12780. }
  12781. }
  12782. else if(gunType[connectorIdInt-1] == GUN_TYPE_DO)
  12783. {
  12784. tempIndex = connectorIdInt -1;
  12785. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  12786. {
  12787. if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)))
  12788. {
  12789. //stop Transaction
  12790. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12791. }
  12792. }
  12793. }
  12794. else
  12795. {
  12796. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  12797. {
  12798. tempIndex = 2;
  12799. }
  12800. else
  12801. {
  12802. tempIndex = connectorIdInt-1;
  12803. }
  12804. for (int index = 0; index < AC_QUANTITY; index++)
  12805. {
  12806. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12807. {
  12808. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12809. }
  12810. }
  12811. }
  12812. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  12813. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  12814. result = TRUE;
  12815. return result;
  12816. }
  12817. end:
  12818. //json_object_put(obj); --- remove temporally
  12819. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  12820. return result;
  12821. }
  12822. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  12823. {
  12824. mtrace();
  12825. int result = FAIL;
  12826. json_object *UnpublishFirmware;
  12827. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  12828. UnpublishFirmware = json_tokener_parse(payload);
  12829. if(!is_error(UnpublishFirmware))
  12830. {
  12831. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  12832. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  12833. // Required data
  12834. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  12835. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  12836. }
  12837. json_object_put(UnpublishFirmware);
  12838. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  12839. /*
  12840. * TODO:
  12841. * 1. Check unpublished status
  12842. */
  12843. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  12844. sendUnpublishFirmwareConfirmation(uuid);
  12845. return result;
  12846. }
  12847. static char UpdateFirmwarepayloadData[512]={0};
  12848. void *UpdateFirmwareProcess(void *data)
  12849. {
  12850. pthread_detach(pthread_self());
  12851. mtrace();
  12852. int retriesInt =0, retryIntervalInt=0;
  12853. char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
  12854. int port=0;
  12855. char locationstr[160]={0}, retrieveDatestr[30]={0};
  12856. int isSuccess = 0;
  12857. char ftpbuf[200];
  12858. char temp[100];
  12859. char * pch;
  12860. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  12861. json_object *UpdateFirmware;
  12862. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  12863. if(!is_error(UpdateFirmware))
  12864. {
  12865. // Required data
  12866. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  12867. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  12868. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  12869. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  12870. // Optional data
  12871. if(json_object_object_get(UpdateFirmware, "retries"))
  12872. {
  12873. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  12874. }
  12875. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  12876. {
  12877. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  12878. }
  12879. }
  12880. json_object_put(UpdateFirmware);
  12881. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12882. memset(path, 0, ARRAY_SIZE(path));
  12883. system("rm -f /mnt/*");
  12884. if(strncmp(locationstr,"http", 4) == 0)
  12885. {
  12886. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12887. //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
  12888. // protocol, user, password, host, path);
  12889. sprintf(ftppath,"/%s", path);
  12890. DEBUG_INFO("locationstr: %s\n", locationstr);
  12891. DEBUG_INFO("protocol: %s\n",protocol);
  12892. DEBUG_INFO("host: %s\n",host);
  12893. DEBUG_INFO("path: %s\n",path);
  12894. DEBUG_INFO("ftppath: %s\n",ftppath);
  12895. int ftppathlen=strlen(ftppath);
  12896. int i=1;
  12897. char filenametemp[50];
  12898. while(i < ftppathlen)
  12899. {
  12900. int len=ftppathlen-i;
  12901. if(ftppath[len]== 47) // '/' ascll code: 47
  12902. {
  12903. DEBUG_INFO("compare '/' all right\n");
  12904. break;
  12905. }
  12906. i=i+1;
  12907. }
  12908. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12909. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  12910. filenametemp[i+1] = 0;
  12911. do
  12912. {
  12913. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12914. sleep(3);
  12915. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  12916. if(!isSuccess)
  12917. {
  12918. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12919. sleep(retryIntervalInt);
  12920. }
  12921. else
  12922. {
  12923. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12924. }
  12925. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
  12926. }
  12927. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  12928. {
  12929. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12930. memset(temp, 0, ARRAY_SIZE(temp));
  12931. //DEBUG_INFO("locationstr=%s\n",locationstr);
  12932. strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
  12933. int ftppathlen=strlen(ftpbuf);
  12934. int i=1;
  12935. char filenametemp[50];
  12936. while(i < ftppathlen)
  12937. {
  12938. int len=ftppathlen-i;
  12939. if(ftpbuf[len]== 47) // '/' ascll code: 47
  12940. {
  12941. DEBUG_INFO(" compare '/' all right\n");
  12942. break;
  12943. }
  12944. i=i+1;
  12945. }
  12946. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12947. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  12948. filenametemp[i+1] = 0;
  12949. strncpy(temp, ftpbuf, ftppathlen-i+1);
  12950. pch=strchr(temp,'@');
  12951. if(pch==NULL)
  12952. {
  12953. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12954. protocol, host, &port, path);
  12955. strcpy(user,"anonymous");
  12956. strcpy(password,"");
  12957. }
  12958. else
  12959. {
  12960. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12961. protocol, user, password, host, &port, path);
  12962. }
  12963. sscanf(host,"%[^/]%s",host1, path1);
  12964. sprintf(ftppath,"%s", path1);
  12965. //DEBUG_INFO("protocol =%s\n",protocol);
  12966. //DEBUG_INFO("user =%s\n",user);
  12967. //DEBUG_INFO("password =%s\n",password);
  12968. //DEBUG_INFO("host1 =%s\n",host1);
  12969. //DEBUG_INFO("port =%d\n",port);
  12970. //DEBUG_INFO("path1 =%s\n",path1);
  12971. //DEBUG_INFO("ftppath=%s\n",ftppath);
  12972. //ftpFile(host, user, password, port, ftppath, fname);
  12973. //download firmware pthred
  12974. if(port == 0)
  12975. {
  12976. port = 21;
  12977. }
  12978. do
  12979. {
  12980. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12981. sleep(3);
  12982. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  12983. if(!isSuccess)
  12984. {
  12985. //BulldogUtil.sleepMs(interval*1000);
  12986. DEBUG_INFO("Update firmware request and download file fail.\n");
  12987. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12988. sleep(retryIntervalInt);
  12989. }
  12990. else
  12991. {
  12992. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12993. }
  12994. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  12995. }
  12996. else
  12997. {
  12998. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12999. }
  13000. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  13001. pthread_exit(NULL);
  13002. }
  13003. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  13004. {
  13005. mtrace();
  13006. int result = FAIL;
  13007. pthread_t t;
  13008. sendUpdateFirmwareConfirmation(uuid);
  13009. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  13010. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  13011. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  13012. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  13013. ////pthread_join(t, NULL); //
  13014. //pthread_detach(t);
  13015. //sendUpdateFirmwareConfirmation(uuid);
  13016. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  13017. return result;
  13018. }
  13019. //==========================================
  13020. // Handle server response routine
  13021. //==========================================
  13022. void handleAuthorizeResponse(char *payload, int gun_index)
  13023. {
  13024. mtrace();
  13025. DEBUG_INFO("handleAuthorizeResponse...\n");
  13026. json_object *Authorize;
  13027. Authorize = json_tokener_parse(payload);
  13028. if(!is_error(Authorize))
  13029. {
  13030. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  13031. {
  13032. // Required data
  13033. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  13034. // Optional data
  13035. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  13036. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  13037. else
  13038. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  13039. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  13040. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  13041. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  13042. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  13043. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  13044. {
  13045. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  13046. {
  13047. 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));
  13048. }
  13049. }
  13050. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  13051. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  13052. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  13053. {
  13054. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  13055. 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")));
  13056. else
  13057. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  13058. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  13059. 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")));
  13060. }
  13061. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  13062. {
  13063. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  13064. 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")));
  13065. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  13066. 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")));
  13067. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  13068. 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")));
  13069. }
  13070. }
  13071. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  13072. {
  13073. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  13074. }
  13075. }
  13076. json_object_put(Authorize);
  13077. //Update idTag information to authorization cache if supported
  13078. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  13079. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  13080. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  13081. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  13082. {
  13083. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  13084. }
  13085. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  13086. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  13087. authorizeRetryTimes = 0;
  13088. }
  13089. void handleBootNotificationResponse(char *payload, int gun_index)
  13090. {
  13091. mtrace();
  13092. char statusStr[12]={0};
  13093. char currentTimeStr[30]={0};
  13094. int intervalInt = 0;
  13095. struct tm tp;
  13096. char buf[28]={0};
  13097. char timebuf[50]={0};
  13098. DEBUG_INFO("handleBootNotificationResponse...\n");
  13099. json_object *BootNotification;
  13100. BootNotification = json_tokener_parse(payload);
  13101. if(!is_error(BootNotification))
  13102. {
  13103. // Required data
  13104. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  13105. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  13106. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  13107. }
  13108. json_object_put(BootNotification);
  13109. DEBUG_INFO("statusStr: %s\n", statusStr);
  13110. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  13111. BootNotificationInterval = intervalInt;
  13112. HeartBeatWaitTime = intervalInt;
  13113. //write back to ShmOCPP20Data->BootNotification
  13114. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  13115. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  13116. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  13117. {
  13118. server_sign = TRUE;
  13119. server_pending =FALSE;
  13120. DB_updateBootType(BootReasonEnumType_PowerUp);
  13121. }
  13122. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  13123. {
  13124. server_pending = TRUE;
  13125. }
  13126. strptime((const char *)ShmOCPP20Data->BootNotification.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  13127. tp.tm_isdst = -1;
  13128. //time_t utc = mktime(&tp);
  13129. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  13130. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  13131. sprintf(timebuf,"date -s '%s'",buf);
  13132. system(timebuf);
  13133. srand(time(NULL));
  13134. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  13135. //==============================================
  13136. // RTC sync
  13137. //==============================================
  13138. system("/sbin/hwclock -w --systohc");
  13139. SetOcppConnStatus(TRUE);
  13140. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  13141. }
  13142. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  13143. {
  13144. mtrace();
  13145. json_object *ClearedChargingLimit;
  13146. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  13147. ClearedChargingLimit = json_tokener_parse(payload);
  13148. if(!is_error(ClearedChargingLimit))
  13149. {
  13150. // Required data
  13151. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  13152. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  13153. }
  13154. json_object_put(ClearedChargingLimit);
  13155. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  13156. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitConf = ON;
  13157. }
  13158. void handleDataTransferResponse(char *payload, int gun_index)
  13159. {
  13160. mtrace();
  13161. json_object *DataTrans;
  13162. DEBUG_INFO("handleDataTransferResponse...\n");
  13163. DataTrans = json_tokener_parse(payload);
  13164. if(!is_error(DataTrans))
  13165. {
  13166. // Required data
  13167. if(json_object_object_get(DataTrans,"status") != NULL)
  13168. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  13169. // Optional data
  13170. if(json_object_object_get(DataTrans,"data") != NULL)
  13171. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  13172. }
  13173. json_object_put(DataTrans);
  13174. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  13175. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  13176. }
  13177. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  13178. {
  13179. mtrace();
  13180. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  13181. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  13182. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  13183. }
  13184. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  13185. {
  13186. mtrace();
  13187. json_object *Get15118EVCertificate;
  13188. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  13189. Get15118EVCertificate = json_tokener_parse(payload);
  13190. if(!is_error(Get15118EVCertificate))
  13191. {
  13192. // Required data
  13193. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  13194. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  13195. // Optional data
  13196. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  13197. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  13198. }
  13199. json_object_put(Get15118EVCertificate);
  13200. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  13201. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  13202. }
  13203. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  13204. {
  13205. mtrace();
  13206. json_object *GetCertificateStatus;
  13207. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  13208. GetCertificateStatus = json_tokener_parse(payload);
  13209. if(!is_error(GetCertificateStatus))
  13210. {
  13211. // Required data
  13212. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  13213. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  13214. // Optional data
  13215. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  13216. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  13217. }
  13218. json_object_put(GetCertificateStatus);
  13219. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  13220. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  13221. }
  13222. void handleHeartbeatResponse(char *payload, int gun_index)
  13223. {
  13224. mtrace();
  13225. struct tm tp;
  13226. char buf[28]={0};
  13227. char timebuf[128]={0};
  13228. DEBUG_INFO("handleHeartbeatResponse...\n");
  13229. json_object *Heartbeat;
  13230. Heartbeat = json_tokener_parse(payload);
  13231. if(!is_error(Heartbeat))
  13232. {
  13233. // Required data
  13234. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  13235. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  13236. }
  13237. json_object_put(Heartbeat);
  13238. if(FirstHeartBeat == OFF)
  13239. {
  13240. FirstHeartBeat = ON;
  13241. DEBUG_INFO("FirstHeartBeat \n");
  13242. }
  13243. HeartBeatWithNOResponse = 0;
  13244. clientTime.Heartbeat=time((time_t*)NULL);
  13245. strptime((const char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  13246. tp.tm_isdst = -1;
  13247. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  13248. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  13249. sprintf(timebuf,"date -s '%s'",buf);
  13250. system(timebuf);
  13251. //==============================================
  13252. // RTC sync
  13253. //==============================================
  13254. system("/sbin/hwclock -w --systohc");
  13255. }
  13256. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  13257. {
  13258. mtrace();
  13259. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  13260. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  13261. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  13262. }
  13263. void handleMeterValuesResponse(char *payload, int gun_index)
  13264. {
  13265. mtrace();
  13266. DEBUG_INFO("handleMeterValuesResponse...\n");
  13267. }
  13268. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  13269. {
  13270. mtrace();
  13271. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  13272. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  13273. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  13274. }
  13275. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  13276. {
  13277. mtrace();
  13278. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  13279. }
  13280. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  13281. {
  13282. mtrace();
  13283. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  13284. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  13285. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  13286. }
  13287. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  13288. {
  13289. mtrace();
  13290. json_object *NotifyEVChargingNeeds;
  13291. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  13292. NotifyEVChargingNeeds = json_tokener_parse(payload);
  13293. if(!is_error(NotifyEVChargingNeeds))
  13294. {
  13295. // Required data
  13296. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  13297. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  13298. }
  13299. json_object_put(NotifyEVChargingNeeds);
  13300. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  13301. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  13302. }
  13303. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  13304. {
  13305. mtrace();
  13306. json_object *NotifyEVChargingSchedule;
  13307. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  13308. NotifyEVChargingSchedule = json_tokener_parse(payload);
  13309. if(!is_error(NotifyEVChargingSchedule))
  13310. {
  13311. // Required data
  13312. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  13313. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  13314. }
  13315. json_object_put(NotifyEVChargingSchedule);
  13316. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  13317. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  13318. }
  13319. void hanldeNotifyEventResponse(char *payload, int gun_index)
  13320. {
  13321. mtrace();
  13322. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  13323. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  13324. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  13325. }
  13326. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  13327. {
  13328. mtrace();
  13329. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  13330. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  13331. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  13332. }
  13333. void hanldeNotifyReportResponse(char *payload, int gun_index)
  13334. {
  13335. mtrace();
  13336. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  13337. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  13338. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  13339. }
  13340. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  13341. {
  13342. mtrace();
  13343. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  13344. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  13345. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  13346. }
  13347. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  13348. {
  13349. mtrace();
  13350. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  13351. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  13352. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  13353. }
  13354. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  13355. {
  13356. mtrace();
  13357. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  13358. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  13359. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  13360. }
  13361. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  13362. {
  13363. mtrace();
  13364. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  13365. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  13366. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  13367. }
  13368. void hanldeSignCertificateResponse(char *payload, int gun_index)
  13369. {
  13370. mtrace();
  13371. json_object *SignCertificate;
  13372. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  13373. SignCertificate = json_tokener_parse(payload);
  13374. if(!is_error(SignCertificate))
  13375. {
  13376. // Required data
  13377. if(json_object_object_get(SignCertificate,"status") != NULL)
  13378. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  13379. }
  13380. json_object_put(SignCertificate);
  13381. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  13382. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  13383. }
  13384. void handleStatusNotificationResponse(char *payload, int gun_index)
  13385. {
  13386. mtrace();
  13387. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  13388. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13389. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  13390. }
  13391. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  13392. {
  13393. mtrace();
  13394. json_object *TransactionEven;
  13395. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  13396. TransactionEven = json_tokener_parse(payload);
  13397. if(!is_error(TransactionEven))
  13398. {
  13399. // Required data
  13400. // Optional data
  13401. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  13402. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  13403. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  13404. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  13405. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  13406. {
  13407. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  13408. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  13409. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  13410. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  13411. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  13412. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  13413. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  13414. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  13415. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  13416. {
  13417. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  13418. 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")));
  13419. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  13420. 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")));
  13421. }
  13422. }
  13423. }
  13424. json_object_put(TransactionEven);
  13425. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  13426. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  13427. }
  13428. //==========================================
  13429. // Handle Error routine
  13430. //==========================================
  13431. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  13432. {
  13433. mtrace();
  13434. #ifdef SystemLogMessage
  13435. DEBUG_INFO("errorCode: %s\n", errorCode);
  13436. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  13437. DEBUG_INFO("errorDetails: %s\n", payload);
  13438. #endif
  13439. }
  13440. //===============================================
  13441. // Common routine
  13442. //===============================================
  13443. int initialConfigurationTable(void)
  13444. {
  13445. DEBUG_INFO("initialConfigurationTable...\n");
  13446. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  13447. DB_variableIsCreate();
  13448. DB_variableLoadFromDb();
  13449. DB_getNetworkProfileFromDb();
  13450. return 0;
  13451. }
  13452. int TransactionMessageAttemptsGet(void)
  13453. {
  13454. return TransactionMessageAttemptsValue;
  13455. }
  13456. int FirstHeartBeatResponse(void)
  13457. {
  13458. return FirstHeartBeat;
  13459. }
  13460. int TransactionMessageRetryIntervalGet(void)
  13461. {
  13462. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  13463. }
  13464. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  13465. {
  13466. char rmFileCmd[100]={0};
  13467. char FilePath[100]={0};
  13468. char ftpbuf[200];
  13469. int systemresult;
  13470. //DEBUG_INFO("filename=%s\n",filename);
  13471. //DEBUG_INFO("url=%s\n",url);
  13472. sprintf(FilePath,"/mnt/%s",filename);
  13473. system("ping 8.8.8.8 &");
  13474. if((access(FilePath,F_OK))!=-1)
  13475. {
  13476. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13477. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13478. system(rmFileCmd);
  13479. }
  13480. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13481. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13482. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13483. systemresult = system(ftpbuf);
  13484. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13485. if(systemresult != 0)
  13486. {
  13487. DEBUG_INFO("http DownLoad error!\n");
  13488. return FALSE;
  13489. }
  13490. system("pkill ping");
  13491. return TRUE;
  13492. }
  13493. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  13494. {
  13495. char rmFileCmd[100]={0};
  13496. char FilePath[100]={0};
  13497. char ftpbuf[200];
  13498. int systemresult;
  13499. //char temp[100];
  13500. sprintf(FilePath,"/mnt/%s",filename);
  13501. system("ping 8.8.8.8 &");
  13502. if((access(FilePath,F_OK))!=-1)
  13503. {
  13504. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13505. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13506. system(rmFileCmd);
  13507. }
  13508. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13509. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13510. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  13511. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13512. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13513. systemresult = system(ftpbuf);
  13514. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13515. if(systemresult != 0)
  13516. {
  13517. printf("wget error!\n");
  13518. return FALSE;
  13519. }
  13520. system("pkill ping");
  13521. return TRUE;
  13522. }
  13523. int httpUploadFile(char *location, char *path, char *filename,char *url)
  13524. {
  13525. char rmFileCmd[100]={0};
  13526. char FilePath[100]={0};
  13527. char ftpbuf[200];
  13528. int systemresult;
  13529. //DEBUG_INFO("filename=%s\n",filename);
  13530. //DEBUG_INFO("url=%s\n",url);
  13531. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  13532. if((access(FilePath,F_OK))!=-1)
  13533. {
  13534. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13535. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13536. system(rmFileCmd);
  13537. }
  13538. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  13539. if(fp == NULL)
  13540. {
  13541. DEBUG_INFO("log is NULL\n");
  13542. return FALSE;
  13543. }
  13544. else
  13545. {
  13546. fprintf(fp, "%s\n", url);
  13547. fprintf(fp, "%s\n", filename);
  13548. fclose(fp);
  13549. }
  13550. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13551. sprintf(ftpbuf, "%s","/bin/php-cgi /var/www/ocpp_upload.php");
  13552. systemresult = system(ftpbuf);
  13553. DEBUG_INFO("systemresult = %d\n",systemresult);
  13554. if(systemresult != 0)
  13555. {
  13556. DEBUG_INFO("http upload error!\n");
  13557. return FALSE;
  13558. }
  13559. return TRUE;
  13560. }
  13561. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  13562. {
  13563. struct hostent* server;
  13564. char *IPbuffer;
  13565. char ftpbuf[200];
  13566. int systemresult;
  13567. // To retrieve host information
  13568. server = gethostbyname(location);
  13569. // To convert an Internet network
  13570. // address into ASCII string
  13571. IPbuffer = inet_ntoa(*((struct in_addr*)
  13572. server->h_addr_list[0]));
  13573. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13574. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  13575. /* format : ftpput -u username -p passwd IP target source*/
  13576. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  13577. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13578. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13579. systemresult = system(ftpbuf);
  13580. DEBUG_INFO("systemresult=%d\n",systemresult);
  13581. if(systemresult != 0)
  13582. {
  13583. DEBUG_INFO("ftpput error!\n");
  13584. return FALSE;
  13585. }
  13586. return TRUE;
  13587. }
  13588. //=========================================
  13589. // Routine
  13590. //=========================================
  13591. int GetOcppServerURL()
  13592. {
  13593. int result = FALSE;
  13594. struct yuarel url;
  13595. char urlStr[512];
  13596. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  13597. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  13598. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  13599. if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  13600. {
  13601. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  13602. if(yuarel_parse(&url, urlStr) != -1)
  13603. {
  13604. sprintf(OcppProtocol, "%s", url.scheme);
  13605. sprintf(OcppHost, "%s", url.host);
  13606. if(url.path == NULL)
  13607. OcppTempPath[0] = '\0';
  13608. else
  13609. sprintf(OcppTempPath, "%s", url.path);
  13610. if(url.port == 0)
  13611. {
  13612. if(strcmp(OcppProtocol, "wss") == 0)
  13613. OcppPort = 443;
  13614. else
  13615. OcppPort = 80;
  13616. }
  13617. else
  13618. OcppPort = url.port;
  13619. result = TRUE;
  13620. }
  13621. }
  13622. else
  13623. {
  13624. strcpy(OcppHost,"");
  13625. }
  13626. return result;
  13627. }
  13628. int GetOcppPath()
  13629. {
  13630. int result = FALSE;
  13631. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  13632. {
  13633. if(OcppTempPath == NULL)
  13634. {
  13635. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13636. }
  13637. else
  13638. {
  13639. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13640. }
  13641. result = TRUE;
  13642. }
  13643. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  13644. {
  13645. if(OcppTempPath == NULL)
  13646. {
  13647. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  13648. }
  13649. else
  13650. {
  13651. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  13652. }
  13653. result = TRUE;
  13654. }
  13655. else
  13656. {
  13657. strcpy(OcppPath,"");
  13658. }
  13659. return result;
  13660. }
  13661. int GetOcppPort()
  13662. {
  13663. return OcppPort;
  13664. }
  13665. int GetOcppConnStatus(void)
  13666. {
  13667. return ShmOCPP20Data->OcppConnStatus;
  13668. }
  13669. void SetOcppConnStatus(uint8_t status)
  13670. {
  13671. ShmOCPP20Data->OcppConnStatus = status;
  13672. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  13673. }
  13674. int GetHeartBeatWithNOResponse(void)
  13675. {
  13676. return HeartBeatWithNOResponse;
  13677. }
  13678. void SetHeartBeatWithNOResponse(void)
  13679. {
  13680. HeartBeatWithNOResponse = 0;
  13681. }
  13682. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  13683. void storeTempStopTransaction(int gun_index)
  13684. {
  13685. }
  13686. void checkTempStopTransaction(int gun_index)
  13687. {
  13688. FILE *fptr1;
  13689. char ch;
  13690. char str[QUEUE_MESSAGE_LENGTH]={0};
  13691. char guid[37]={0};
  13692. char tempdata[65]={0};
  13693. char connectorStr[2]={0};
  13694. char TempStopTransaction[256];
  13695. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  13696. fptr1 = fopen(TempStopTransaction, "r");
  13697. if (!fptr1)
  13698. {
  13699. //DEBUG_INFO("TempStopTransaction_%d not found or unable to open the input file!\n", (gun_index+1));
  13700. return ;
  13701. }
  13702. ch=fgetc(fptr1);
  13703. rewind(fptr1);
  13704. if(ch!=EOF)
  13705. {
  13706. // copy all contents to the temporary file except the specific line
  13707. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  13708. {
  13709. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13710. if(str[0]=='\0')
  13711. {
  13712. break;
  13713. }
  13714. //TempStopTransaction格式: 槍號,StopTransaction封包
  13715. strncpy(connectorStr, str, 1);
  13716. if(atoi(connectorStr) != (gun_index+1))
  13717. {
  13718. DEBUG_INFO("atoi(connectorStr) = %d, gun_index = %d\n", atoi(connectorStr), gun_index);
  13719. fclose(fptr1);
  13720. return ;
  13721. }
  13722. //random_uuid(guid);
  13723. strncpy(guid, str+6, 36); //copy guid
  13724. sprintf(tempdata, "StopTransaction,%d", (gun_index));
  13725. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  13726. {
  13727. //DEBUG_INFO("StopTransaction mapitem pass\n");
  13728. }
  13729. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  13730. memset(str,0,ARRAY_SIZE(str));
  13731. }
  13732. }
  13733. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  13734. fclose(fptr1);
  13735. remove(TempStopTransaction); // remove the original file
  13736. }
  13737. int GetWebSocketPingInterval(void)
  13738. {
  13739. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  13740. }
  13741. int GetServerSign(void)
  13742. {
  13743. return server_sign;
  13744. }
  13745. uint8_t GetOcppSecurityProfile()
  13746. {
  13747. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  13748. }
  13749. void GetOcppChargerBoxId(uint8_t *data)
  13750. {
  13751. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  13752. }
  13753. void GetOcppSecurityPassword(uint8_t *data)
  13754. {
  13755. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  13756. }
  13757. void SetServerSign(int value)
  13758. {
  13759. server_sign = value;
  13760. }
  13761. int GetBootNotificationInterval(void)
  13762. {
  13763. return BootNotificationInterval;
  13764. }
  13765. int GetInternetConn(void)
  13766. {
  13767. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  13768. }
  13769. void InitialSystemValue(void)
  13770. {
  13771. int connectorIndex = 0;
  13772. gunTotalNumber=0;
  13773. SystemInitial = 0;
  13774. localversion=0;
  13775. BootNotificationInterval = 10;
  13776. authorizeRetryTimes = 0;
  13777. GunStatusInterval = 10;
  13778. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  13779. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  13780. //Hear Beat
  13781. HeartBeatWithNOResponse = 0;
  13782. HeartBeatCountPerHour = 0;
  13783. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  13784. FirstHeartBeat = 0;
  13785. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  13786. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  13787. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  13788. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  13789. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  13790. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  13791. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  13792. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  13793. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  13794. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  13795. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  13796. memset(gunType, 0, ARRAY_SIZE(gunType));
  13797. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13798. {
  13799. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  13800. {
  13801. // DO series
  13802. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  13803. {
  13804. SystemInitial = SystemInitial + 1;
  13805. gunTotalNumber = gunTotalNumber + 1;
  13806. gunType[connectorIndex] = GUN_TYPE_DO;
  13807. connectorIndex = connectorIndex + 1;
  13808. }
  13809. }
  13810. else
  13811. {
  13812. // DM, DW, DS series
  13813. //check connector / socket type (index: 8, 9, 10)
  13814. for(int index=7; index <10 ; index++)
  13815. {
  13816. if(index != 8)
  13817. {
  13818. // DC Connector
  13819. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'J'))
  13820. {
  13821. SystemInitial = SystemInitial + 1;
  13822. gunTotalNumber = gunTotalNumber + 1;
  13823. gunType[connectorIndex] = GUN_TYPE_CHAdeMO;
  13824. connectorIndex = connectorIndex + 1;
  13825. }
  13826. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'D') ||
  13827. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'E') ||
  13828. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'F') ||
  13829. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'U') ||
  13830. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'T') ||
  13831. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'V'))
  13832. {
  13833. SystemInitial = SystemInitial + 1;
  13834. gunTotalNumber = gunTotalNumber + 1;
  13835. gunType[connectorIndex] = GUN_TYPE_CCS;
  13836. connectorIndex = connectorIndex + 1;
  13837. }
  13838. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'G'))
  13839. {
  13840. SystemInitial = SystemInitial + 1;
  13841. gunTotalNumber = gunTotalNumber + 1;
  13842. gunType[connectorIndex] = GUN_TYPE_GBT;
  13843. connectorIndex = connectorIndex + 1;
  13844. }
  13845. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'O'))
  13846. {
  13847. SystemInitial = SystemInitial + 1;
  13848. gunTotalNumber = gunTotalNumber + 1;
  13849. gunType[connectorIndex] = GUN_TYPE_DO;
  13850. connectorIndex = connectorIndex + 1;
  13851. }
  13852. }
  13853. else
  13854. {
  13855. // AC Connector
  13856. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13857. {
  13858. SystemInitial = SystemInitial + 1;
  13859. gunTotalNumber = gunTotalNumber + 1;
  13860. gunType[connectorIndex] = GUN_TYPE_AC;
  13861. connectorIndex = connectorIndex + 1;
  13862. }
  13863. }
  13864. }
  13865. }
  13866. //DEBUG_INFO("DC ...\n");
  13867. }
  13868. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  13869. {
  13870. //check connector / socket type (index: 8, 9, 10)
  13871. for(int index=7; index <10 ; index++)
  13872. {
  13873. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13874. {
  13875. SystemInitial = SystemInitial + 1;
  13876. gunTotalNumber = gunTotalNumber + 1;
  13877. gunType[connectorIndex] = GUN_TYPE_AC;
  13878. connectorIndex = connectorIndex + 1;
  13879. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  13880. }
  13881. }
  13882. }
  13883. //Status && ConnectorPlugIn Setting
  13884. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13885. {
  13886. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  13887. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  13888. }
  13889. for (int index = 0; index < CCS_QUANTITY; index++)
  13890. {
  13891. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  13892. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  13893. }
  13894. for (int index = 0; index < GB_QUANTITY; index++)
  13895. {
  13896. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  13897. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  13898. }
  13899. for (int index = 0; index < AC_QUANTITY; index++)
  13900. {
  13901. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  13902. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  13903. }
  13904. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13905. {
  13906. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  13907. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  13908. }
  13909. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  13910. {
  13911. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13912. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  13913. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  13914. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  13915. }
  13916. clientTime.Heartbeat=time((time_t*)NULL);
  13917. sleep(1);
  13918. }
  13919. void LWS_Send(char * str)
  13920. {
  13921. //=====================================================
  13922. // Check InternetConn 0: disconnected, 1: connected
  13923. //====================================================
  13924. if(GetOcppConnStatus() == 0)
  13925. {
  13926. DEBUG_INFO("offline now !!!\n");
  13927. return;
  13928. }
  13929. pthread_mutex_lock(&lock_send);
  13930. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13931. sprintf((char *)SendBuffer, "%s", str);
  13932. SendBufLen = strlen(str);
  13933. pthread_mutex_unlock(&lock_send);
  13934. lws_callback_on_writable(wsi_client);
  13935. //lws_service(context, 0);
  13936. //sleep(1);
  13937. }
  13938. void LWS_SendNow(char * str)
  13939. {
  13940. //=====================================================
  13941. // Check InternetConn 0: disconnected, 1: connected
  13942. //====================================================
  13943. if(GetOcppConnStatus() == 0)
  13944. {
  13945. DEBUG_INFO("offline now !!!\n");
  13946. return;
  13947. }
  13948. pthread_mutex_lock(&lock_send);
  13949. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13950. sprintf((char *)SendBuffer, "%s", str);
  13951. SendBufLen = strlen(str);
  13952. pthread_mutex_unlock(&lock_send);
  13953. lws_callback_on_writable(wsi_client);
  13954. lws_service(context, 0);
  13955. //sleep(1);
  13956. }