MessageHandler.c 779 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670
  1. #include "Module_OcppBackend20.h"
  2. #include "define.h"
  3. static char *APNAuthenticationEnumTypeStr[] = {
  4. MACROSTR(CHAP),
  5. MACROSTR(NONE),
  6. MACROSTR(PAP),
  7. MACROSTR(AUTO)
  8. };
  9. static char *AttributeEnumTypeStr[] = {
  10. MACROSTR(Actual),
  11. MACROSTR(Target),
  12. MACROSTR(MinSet),
  13. MACROSTR(MaxSet)
  14. };
  15. static char *AuthorizationStatusEnumTypeStr[] = {
  16. MACROSTR(Accepted),
  17. MACROSTR(Blocked),
  18. MACROSTR(ConcurrentTx),
  19. MACROSTR(Expired),
  20. MACROSTR(Invalid),
  21. MACROSTR(NoCredit),
  22. MACROSTR(NotAllowedTypeEVSE),
  23. MACROSTR(NotAtThisLocation),
  24. MACROSTR(NotAtThisTime),
  25. MACROSTR(Unknown)
  26. };
  27. static char *AuthorizeCertificateStatusEnumTypeStr[] = {
  28. MACROSTR(Accepted),
  29. MACROSTR(SignatureError),
  30. MACROSTR(CertificateExpired),
  31. MACROSTR(CertificateRevoked),
  32. MACROSTR(NoCertificateAvailable),
  33. MACROSTR(CertChainError),
  34. MACROSTR(ContractCancelled)
  35. };
  36. static char *BootReasonEnumTypeStr[] = {
  37. MACROSTR(ApplicationReset),
  38. MACROSTR(FirmwareUpdate),
  39. MACROSTR(LocalReset),
  40. MACROSTR(PowerUp),
  41. MACROSTR(RemoteReset),
  42. MACROSTR(ScheduledReset),
  43. MACROSTR(Triggered),
  44. MACROSTR(Unknown),
  45. MACROSTR(Watchdog)
  46. };
  47. static char *CancelReservationStatusEnumTypeStr[] = {
  48. MACROSTR(Accepted),
  49. MACROSTR(Rejected)
  50. };
  51. static char *CertificateActionEnumTypeStr[] = {
  52. MACROSTR(Install),
  53. MACROSTR(Update)
  54. };
  55. static char *CertificateSignedStatusEnumTypeStr[] = {
  56. MACROSTR(Accepted),
  57. MACROSTR(Rejected)
  58. };
  59. static char *CertificateSigningUseEnumTypeStr[] = {
  60. MACROSTR(ChargingStationCertificate),
  61. MACROSTR(V2GCertificate)
  62. };
  63. static char *ChangeAvailabilityStatusEnumTypeStr[] = {
  64. MACROSTR(Accepted),
  65. MACROSTR(Rejected),
  66. MACROSTR(Scheduled)
  67. };
  68. static char *ChargingLimitSourceEnumTypeStr[] = {
  69. MACROSTR(EMS),
  70. MACROSTR(Other),
  71. MACROSTR(SO),
  72. MACROSTR(CSO)
  73. };
  74. static char *ChargingProfileKindEnumTypeStr[] = {
  75. MACROSTR(Absolute),
  76. MACROSTR(Recurring),
  77. MACROSTR(Relative)
  78. };
  79. static char *ChargingProfilePurposeEnumTypeStr[] = {
  80. MACROSTR(ChargingStationExternalConstraints),
  81. MACROSTR(ChargingStationMaxProfile),
  82. MACROSTR(TxDefaultProfile),
  83. MACROSTR(TxProfile)
  84. };
  85. static char *ChargingProfileStatusEnumTypeStr[] = {
  86. MACROSTR(Accepted),
  87. MACROSTR(Rejected)
  88. };
  89. static char *ChargingRateUnitEnumTypeStr[] = {
  90. MACROSTR(W),
  91. MACROSTR(A)
  92. };
  93. static char *ChargingStateEnumTypeStr[] = {
  94. MACROSTR(Charging),
  95. MACROSTR(EVConnected),
  96. MACROSTR(SuspendedEV),
  97. MACROSTR(SuspendedEVSE),
  98. MACROSTR(Idle)
  99. };
  100. static char *ClearCacheStatusEnumTypeStr[] = {
  101. MACROSTR(Accepted),
  102. MACROSTR(Rejected)
  103. };
  104. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  105. MACROSTR(Accepted),
  106. MACROSTR(Unknown)
  107. };
  108. static char *ClearMessageStatusEnumTypeStr[] = {
  109. MACROSTR(Accepted),
  110. MACROSTR(Unknown)
  111. };
  112. static char *ClearMonitoringStatusEnumTypeStr[] = {
  113. MACROSTR(Accepted),
  114. MACROSTR(Rejected),
  115. MACROSTR(NotFound)
  116. };
  117. static char *ComponentCriterionEnumTypeStr[] = {
  118. MACROSTR(Active),
  119. MACROSTR(Available),
  120. MACROSTR(Enabled),
  121. MACROSTR(Problem)
  122. };
  123. static char *ConnectorEnumTypeStr[] = {
  124. MACROSTR(cCCS1),
  125. MACROSTR(cCCS2),
  126. MACROSTR(cG105),
  127. MACROSTR(cTesla),
  128. MACROSTR(cType1),
  129. MACROSTR(cType2),
  130. MACROSTR(s309-1P-16A),
  131. MACROSTR(s309-1P-32A),
  132. MACROSTR(s309-3P-16A),
  133. MACROSTR(s309-3P-32A),
  134. MACROSTR(sBS1361),
  135. MACROSTR(sCEE-7-7),
  136. MACROSTR(sType2),
  137. MACROSTR(sType3),
  138. MACROSTR(Other1PhMax16A),
  139. MACROSTR(Other1PhOver16A),
  140. MACROSTR(Other3Ph),
  141. MACROSTR(Pan),
  142. MACROSTR(wInductive),
  143. MACROSTR(wResonant),
  144. MACROSTR(Undetermined),
  145. MACROSTR(Unknown)
  146. };
  147. static char *ConnectorStatusEnumTypeStr[] = {
  148. MACROSTR(Available),
  149. MACROSTR(Occupied),
  150. MACROSTR(Reserved),
  151. MACROSTR(Unavailable),
  152. MACROSTR(Faulted)
  153. };
  154. static char *CostKindEnumTypeStr[] = {
  155. MACROSTR(CarbonDioxideEmission),
  156. MACROSTR(RelativePricePercentage),
  157. MACROSTR(RenewableGenerationPercentage)
  158. };
  159. static char *CustomerInformationStatusEnumTypeStr[] = {
  160. MACROSTR(Accepted),
  161. MACROSTR(Rejected),
  162. MACROSTR(Invalid)
  163. };
  164. static char *DataEnumTypeStr[] = {
  165. MACROSTR(string),
  166. MACROSTR(decimal),
  167. MACROSTR(integer),
  168. MACROSTR(dateTime),
  169. MACROSTR(boolean),
  170. MACROSTR(OptionList),
  171. MACROSTR(SequenceList),
  172. MACROSTR(MemberList)
  173. };
  174. static char *DataTransferStatusEnumTypeStr[] = {
  175. MACROSTR(Accepted),
  176. MACROSTR(Rejected),
  177. MACROSTR(UnknownMessageId),
  178. MACROSTR(UnknownVendorId)
  179. };
  180. static char *DeleteCertificateStatusEnumTypeStr[] = {
  181. MACROSTR(Accepted),
  182. MACROSTR(Failed),
  183. MACROSTR(NotFound)
  184. };
  185. static char *DisplayMessageStatusEnumTypeStr[] = {
  186. MACROSTR(Accepted),
  187. MACROSTR(NotSupportedMessageFormat),
  188. MACROSTR(Rejected),
  189. MACROSTR(NotSupportedPriority),
  190. MACROSTR(NotSupportedState),
  191. MACROSTR(UnknownTransaction)
  192. };
  193. static char *EnergyTransferModeEnumTypeStr[] = {
  194. MACROSTR(DC),
  195. MACROSTR(AC_single_phase),
  196. MACROSTR(AC_two_phase),
  197. MACROSTR(AC_three_phase)
  198. };
  199. static char *EventNotificationEnumTypeStr[] = {
  200. MACROSTR(HardWiredNotification),
  201. MACROSTR(HardWiredMonitor),
  202. MACROSTR(PreconfiguredMonitor),
  203. MACROSTR(CustomMonitor)
  204. };
  205. static char *EventTriggerEnumTypeStr[] = {
  206. MACROSTR(Alerting),
  207. MACROSTR(Delta),
  208. MACROSTR(Periodic)
  209. };
  210. static char *FirmwareStatusEnumTypeStr[] = {
  211. MACROSTR(Downloaded),
  212. MACROSTR(DownloadFailed),
  213. MACROSTR(Downloading),
  214. MACROSTR(DownloadScheduled),
  215. MACROSTR(DownloadPaused),
  216. MACROSTR(Idle),
  217. MACROSTR(InstallationFailed),
  218. MACROSTR(Installing),
  219. MACROSTR(Installed),
  220. MACROSTR(InstallRebooting),
  221. MACROSTR(InstallScheduled),
  222. MACROSTR(InstallVerificationFailed),
  223. MACROSTR(InvalidSignature),
  224. MACROSTR(SignatureVerified)
  225. };
  226. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  227. MACROSTR(Accepted),
  228. MACROSTR(Rejected),
  229. MACROSTR(NotSupported),
  230. MACROSTR(EmptyResultSet)
  231. };
  232. static char *GenericStatusEnumTypeStr[] = {
  233. MACROSTR(Accepted),
  234. MACROSTR(Rejected)
  235. };
  236. static char *GetCertificateIdUseEnumTypeStr[] = {
  237. MACROSTR(V2GRootCertificate),
  238. MACROSTR(MORootCertificate),
  239. MACROSTR(CSMSRootCertificate),
  240. MACROSTR(V2GCertificateChain),
  241. MACROSTR(ManufacturerRootCertificate)
  242. };
  243. static char *GetCertificateStatusEnumTypeStr[] = {
  244. MACROSTR(Accepted),
  245. MACROSTR(Failed)
  246. };
  247. static char *GetChargingProfileStatusEnumTypeStr[] = {
  248. MACROSTR(Accepted),
  249. MACROSTR(NoProfiles)
  250. };
  251. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  252. MACROSTR(Accepted),
  253. MACROSTR(Unknown)
  254. };
  255. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  256. MACROSTR(Accepted),
  257. MACROSTR(NotFound)
  258. };
  259. static char *GetVariableStatusEnumTypeStr[] = {
  260. MACROSTR(Accepted),
  261. MACROSTR(Rejected),
  262. MACROSTR(UnknownComponent),
  263. MACROSTR(UnknownVariable),
  264. MACROSTR(NotSupportedAttributeType)
  265. };
  266. static char *HashAlgorithmEnumTypeStr[] = {
  267. MACROSTR(SHA256),
  268. MACROSTR(SHA384),
  269. MACROSTR(SHA512)
  270. };
  271. static char *IdTokenEnumTypeStr[] = {
  272. MACROSTR(Central),
  273. MACROSTR(eMAID),
  274. MACROSTR(ISO14443),
  275. MACROSTR(KeyCode),
  276. MACROSTR(Local),
  277. MACROSTR(NoAuthorization),
  278. MACROSTR(ISO15693)
  279. };
  280. static char *InstallCertificateUseEnumTypeStr[] = {
  281. MACROSTR(V2GRootCertificate),
  282. MACROSTR(MORootCertificate),
  283. MACROSTR(CSMSRootCertificate),
  284. MACROSTR(ManufacturerRootCertificate)
  285. };
  286. static char *InstallCertificateStatusEnumTypeStr[]={
  287. MACROSTR(Accepted),
  288. MACROSTR(Failed),
  289. MACROSTR(Rejected)
  290. };
  291. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  292. MACROSTR(Accepted),
  293. MACROSTR(Failed)
  294. };
  295. static char *LocationEnumTypeStr[] = {
  296. MACROSTR(Body),
  297. MACROSTR(Cable),
  298. MACROSTR(EV),
  299. MACROSTR(Inlet),
  300. MACROSTR(Outlet)
  301. };
  302. static char *LogEnumTypeStr[] = {
  303. MACROSTR(DiagnosticsLog),
  304. MACROSTR(SecurityLog)
  305. };
  306. static char *LogStatusEnumTypeStr[] = {
  307. MACROSTR(Accepted),
  308. MACROSTR(Rejected),
  309. MACROSTR(AcceptedCanceled)
  310. };
  311. static char *MeasurandEnumTypeStr[] = {
  312. MACROSTR(Current.Export),
  313. MACROSTR(Current.Import),
  314. MACROSTR(Current.Offered),
  315. MACROSTR(Energy.Active.Export.Register),
  316. MACROSTR(Energy.Active.Import.Register),
  317. MACROSTR(Energy.Reactive.Export.Register),
  318. MACROSTR(Energy.Reactive.Import.Register),
  319. MACROSTR(Energy.Active.Export.Interval),
  320. MACROSTR(Energy.Active.Import.Interval),
  321. MACROSTR(Energy.Active.Net),
  322. MACROSTR(Energy.Reactive.Export.Interval),
  323. MACROSTR(Energy.Reactive.Import.Interval),
  324. MACROSTR(Energy.Reactive.Net),
  325. MACROSTR(Energy.Apparent.Net),
  326. MACROSTR(Energy.Apparent.Import),
  327. MACROSTR(Energy.Apparent.Export),
  328. MACROSTR(Frequency),
  329. MACROSTR(Power.Active.Export),
  330. MACROSTR(Power.Active.Import),
  331. MACROSTR(Power.Factor),
  332. MACROSTR(Power.Offered),
  333. MACROSTR(Power.Reactive.Export),
  334. MACROSTR(Power.Reactive.Import),
  335. MACROSTR(SoC),
  336. MACROSTR(Voltage)
  337. };
  338. static char *MessageFormatEnumTypeStr[] = {
  339. MACROSTR(ASCII),
  340. MACROSTR(HTML),
  341. MACROSTR(URI),
  342. MACROSTR(UTF8)
  343. };
  344. static char *MessagePriorityEnumTypeStr[] = {
  345. MACROSTR(AlwaysFront),
  346. MACROSTR(InFront),
  347. MACROSTR(NormalCycle)
  348. };
  349. static char *MessageStateEnumTypeStr[] = {
  350. MACROSTR(Charging),
  351. MACROSTR(Faulted),
  352. MACROSTR(Idle),
  353. MACROSTR(Unavailable)
  354. };
  355. static char *MessageTriggerEnumTypeStr[] = {
  356. MACROSTR(BootNotification),
  357. MACROSTR(LogStatusNotification),
  358. MACROSTR(FirmwareStatusNotification),
  359. MACROSTR(Heartbeat),
  360. MACROSTR(MeterValues),
  361. MACROSTR(SignChargingStationCertificate),
  362. MACROSTR(SignV2GCertificate),
  363. MACROSTR(StatusNotification),
  364. MACROSTR(TransactionEvent),
  365. MACROSTR(SignCombinedCertificate),
  366. MACROSTR(PublishFirmwareStatusNotification)
  367. };
  368. static char *MonitorEnumTypeStr[] = {
  369. MACROSTR(UpperThreshold),
  370. MACROSTR(LowerThreshold),
  371. MACROSTR(Delta),
  372. MACROSTR(Periodic),
  373. MACROSTR(PeriodicClockAligned)
  374. };
  375. static char *MonitoringBaseEnumTypeStr[] = {
  376. MACROSTR(All),
  377. MACROSTR(FactoryDefault),
  378. MACROSTR(HardWiredOnly)
  379. };
  380. static char *MonitoringCriterionEnumTypeStr[] = {
  381. MACROSTR(ThresholdMonitoring),
  382. MACROSTR(DeltaMonitoring),
  383. MACROSTR(PeriodicMonitoring)
  384. };
  385. static char *MutabilityEnumTypeStr[] = {
  386. MACROSTR(ReadOnly),
  387. MACROSTR(WriteOnly),
  388. MACROSTR(ReadWrite)
  389. };
  390. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  391. MACROSTR(Accepted),
  392. MACROSTR(Rejected),
  393. MACROSTR(Processing)
  394. };
  395. static char *OCPPInterfaceEnumTypeStr[] = {
  396. MACROSTR(Wired0),
  397. MACROSTR(Wired1),
  398. MACROSTR(Wired2),
  399. MACROSTR(Wired3),
  400. MACROSTR(Wireless0),
  401. MACROSTR(Wireless1),
  402. MACROSTR(Wireless2),
  403. MACROSTR(Wireless3)
  404. };
  405. static char *OCPPTransportEnumTypeStr[] = {
  406. MACROSTR(JSON),
  407. MACROSTR(SOAP)
  408. };
  409. static char *OCPPVersionEnumTypeStr[] = {
  410. MACROSTR(OCPP12),
  411. MACROSTR(OCPP15),
  412. MACROSTR(OCPP16),
  413. MACROSTR(OCPP20)
  414. };
  415. static char *OperationalStatusEnumTypeStr[] = {
  416. MACROSTR(Inoperative),
  417. MACROSTR(Operative)
  418. };
  419. static char *PhaseEnumTypeStr[] = {
  420. MACROSTR(L1),
  421. MACROSTR(L2),
  422. MACROSTR(L3),
  423. MACROSTR(N),
  424. MACROSTR(L1-N),
  425. MACROSTR(L2-N),
  426. MACROSTR(L3-N),
  427. MACROSTR(L1-L2),
  428. MACROSTR(L2-L3),
  429. MACROSTR(L3-L1)
  430. };
  431. static char *PublishFirmwareStatusEnumTypeStr[] = {
  432. MACROSTR(Downloaded),
  433. MACROSTR(DownloadFailed),
  434. MACROSTR(Downloading),
  435. MACROSTR(DownloadScheduled),
  436. MACROSTR(DownloadPaused),
  437. MACROSTR(PublishFailed),
  438. MACROSTR(Published),
  439. MACROSTR(InvalidChecksum),
  440. MACROSTR(ChecksumVerified)
  441. };
  442. static char *ReadingContextEnumTypeStr[] = {
  443. MACROSTR(Interruption.Begin),
  444. MACROSTR(Interruption.End),
  445. MACROSTR(Other),
  446. MACROSTR(Sample.Clock),
  447. MACROSTR(Sample.Periodic),
  448. MACROSTR(Transaction.Begin),
  449. MACROSTR(Transaction.End),
  450. MACROSTR(Trigger)
  451. };
  452. static char *ReasonEnumTypeStr[] = {
  453. MACROSTR(DeAuthorized),
  454. MACROSTR(EmergencyStop),
  455. MACROSTR(EnergyLimitReached),
  456. MACROSTR(EVDisconnected),
  457. MACROSTR(GroundFault),
  458. MACROSTR(ImmediateReset),
  459. MACROSTR(Local),
  460. MACROSTR(LocalOutOfCredit),
  461. MACROSTR(MasterPass),
  462. MACROSTR(Other),
  463. MACROSTR(OvercurrentFault),
  464. MACROSTR(PowerLoss),
  465. MACROSTR(PowerQuality),
  466. MACROSTR(Reboot),
  467. MACROSTR(Remote),
  468. MACROSTR(SOCLimitReached),
  469. MACROSTR(StoppedByEV),
  470. MACROSTR(TimeLimitReached),
  471. MACROSTR(TimeLimitReached)
  472. };
  473. static char *RecurrencyKindEnumTypeStr[] = {
  474. MACROSTR(Daily),
  475. MACROSTR(Weekly)
  476. };
  477. static char *RegistrationStatusEnumTypeStr[] = {
  478. MACROSTR(Accepted),
  479. MACROSTR(Pending),
  480. MACROSTR(Rejected)
  481. };
  482. static char *ReportBaseEnumTypeStr[] = {
  483. MACROSTR(ConfigurationInventory),
  484. MACROSTR(FullInventory),
  485. MACROSTR(SummaryInventory)
  486. };
  487. static char *RequestStartStopStatusEnumTypeStr[] = {
  488. MACROSTR(Accepted),
  489. MACROSTR(Rejected)
  490. };
  491. static char *ReservationUpdateStatusEnumTypeStr[] = {
  492. MACROSTR(Expired),
  493. MACROSTR(Removed)
  494. };
  495. static char *ReserveNowStatusEnumTypeStr[] = {
  496. MACROSTR(Accepted),
  497. MACROSTR(Faulted),
  498. MACROSTR(Occupied),
  499. MACROSTR(Rejected),
  500. MACROSTR(Unavailable)
  501. };
  502. static char *ResetEnumTypeStr[] = {
  503. MACROSTR(Immediate),
  504. MACROSTR(OnIdle)
  505. };
  506. static char *ResetStatusEnumTypeStr[] = {
  507. MACROSTR(Accepted),
  508. MACROSTR(Rejected),
  509. MACROSTR(Scheduled)
  510. };
  511. static char *SetMonitoringStatusEnumTypeStr[] = {
  512. MACROSTR(Accepted),
  513. MACROSTR(UnknownComponent),
  514. MACROSTR(UnknownVariable),
  515. MACROSTR(UnsupportedMonitorType),
  516. MACROSTR(Rejected),
  517. MACROSTR(OutOfRange),
  518. MACROSTR(Duplicate)
  519. };
  520. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  521. MACROSTR(Accepted),
  522. MACROSTR(Rejected),
  523. MACROSTR(Failed)
  524. };
  525. static char *SetVariableStatusEnumTypeStr[] = {
  526. MACROSTR(Accepted),
  527. MACROSTR(Rejected),
  528. MACROSTR(InvalidValue),
  529. MACROSTR(UnknownComponent),
  530. MACROSTR(UnknownVariable),
  531. MACROSTR(NotSupportedAttributeType),
  532. MACROSTR(OutOfRange),
  533. MACROSTR(RebootRequired)
  534. };
  535. static char *TransactionEventEnumTypeStr[] = {
  536. MACROSTR(Ended),
  537. MACROSTR(Started),
  538. MACROSTR(Updated)
  539. };
  540. static char *TriggerMessageStatusEnumTypeStr[] = {
  541. MACROSTR(Accepted),
  542. MACROSTR(Rejected),
  543. MACROSTR(NotImplemented)
  544. };
  545. static char *TriggerReasonEnumTypeStr[] = {
  546. MACROSTR(Authorized),
  547. MACROSTR(CablePluggedIn),
  548. MACROSTR(ChargingRateChanged),
  549. MACROSTR(ChargingStateChanged),
  550. MACROSTR(Deauthorized),
  551. MACROSTR(EnergyLimitReached),
  552. MACROSTR(EVCommunicationLost),
  553. MACROSTR(EVConnectTimeout),
  554. MACROSTR(MeterValueClock),
  555. MACROSTR(MeterValuePeriodic),
  556. MACROSTR(TimeLimitReached),
  557. MACROSTR(Trigger),
  558. MACROSTR(UnlockCommand),
  559. MACROSTR(StopAuthorized),
  560. MACROSTR(EVDeparted),
  561. MACROSTR(EVDetected),
  562. MACROSTR(RemoteStop),
  563. MACROSTR(RemoteStart),
  564. MACROSTR(AbnormalCondition),
  565. MACROSTR(SignedDataReceived),
  566. MACROSTR(ResetCommand)
  567. };
  568. static char *UnlockStatusEnumTypeStr[] = {
  569. MACROSTR(Unlocked),
  570. MACROSTR(UnlockFailed),
  571. MACROSTR(OngoingAuthorizedTransaction),
  572. MACROSTR(UnknownConnector)
  573. };
  574. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  575. MACROSTR(DownloadOngoing),
  576. MACROSTR(NoFirmware),
  577. MACROSTR(Unpublished)
  578. };
  579. static char *UpdateEnumTypeStr[] = {
  580. MACROSTR(Differential),
  581. MACROSTR(Full)
  582. };
  583. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  584. MACROSTR(Accepted),
  585. MACROSTR(Rejected),
  586. MACROSTR(AcceptedCanceled),
  587. MACROSTR(InvalidCertificate),
  588. MACROSTR(RevokedCertificate)
  589. };
  590. static char *UpdateStatusEnumTypeStr[] = {
  591. MACROSTR(Accepted),
  592. MACROSTR(Failed),
  593. MACROSTR(VersionMismatch)
  594. };
  595. static char *UploadLogStatusEnumTypeStr[] = {
  596. MACROSTR(BadMessage),
  597. MACROSTR(Idle),
  598. MACROSTR(NotSupportedOperation),
  599. MACROSTR(PermissionDenied),
  600. MACROSTR(Uploaded),
  601. MACROSTR(UploadFailure),
  602. MACROSTR(Uploading)
  603. };
  604. static char *VPNEnumTypeStr[] = {
  605. MACROSTR(IKEv2),
  606. MACROSTR(IPSec),
  607. MACROSTR(L2TP),
  608. MACROSTR(PPTP)
  609. };
  610. #if 0
  611. static char *ChargePointErrorCodeEnumTypeStr[] = {
  612. MACROSTR(ConnectorLockFailure),
  613. MACROSTR(EVCommunicationError),
  614. MACROSTR(GroundFailure),
  615. MACROSTR(HighTemperature),
  616. MACROSTR(InternalError),
  617. MACROSTR(LocalListConflict),
  618. MACROSTR(NoError),
  619. MACROSTR(OtherError),
  620. MACROSTR(OverCurrentFailure),
  621. MACROSTR(OverVoltage),
  622. MACROSTR(PowerMeterFailure),
  623. MACROSTR(PowerSwitchFailure),
  624. MACROSTR(ReaderFailure),
  625. MACROSTR(ResetFailure),
  626. MACROSTR(UnderVoltage),
  627. MACROSTR(WeakSignal)
  628. };
  629. #endif
  630. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  631. MACROSTR(Accepted),
  632. MACROSTR(Rejected)
  633. };
  634. static char *RemoteStartStopStatusEnumTypeStr[] = {
  635. MACROSTR(Accepted),
  636. MACROSTR(Rejected)
  637. };
  638. static char *ReservationStatusEnumTypeStr[] = {
  639. MACROSTR(Accepted),
  640. MACROSTR(Faulted),
  641. MACROSTR(Occupied),
  642. MACROSTR(Rejected),
  643. MACROSTR(Unavailable)
  644. };
  645. #if 0
  646. static char * StopTransactionReasonEnumTypeStr[] = {
  647. MACROSTR(EmergencyStop),
  648. MACROSTR(EVDisconnected),
  649. MACROSTR(HardReset),
  650. MACROSTR(Local),
  651. MACROSTR(Other),
  652. MACROSTR(PowerLoss),
  653. MACROSTR(Reboot),
  654. MACROSTR(Remote),
  655. MACROSTR(SoftReset),
  656. MACROSTR(UnlockCommand),
  657. MACROSTR(DeAuthorized)
  658. };
  659. #endif
  660. //ChargePointMaxProfile
  661. #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile_OCPP20.json"
  662. //TxDefaultProfile
  663. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  664. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  665. struct StatusCodeData *ShmStatusCodeData;
  666. struct PsuData *ShmPsuData ;
  667. struct OCPP20Data *ShmOCPP20Data;
  668. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  669. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  670. //===============================
  671. // Gun Total Numbers
  672. //===============================
  673. static int gunTotalNumber = 0;
  674. static uint8_t gunType[4] = {0};
  675. //===============================
  676. // Local List Version
  677. //===============================
  678. static int localversion=0;
  679. //===============================
  680. // OCPP sign variable
  681. //===============================
  682. static int server_sign = FALSE;
  683. int server_pending = FALSE;
  684. static int BootNotificationInterval = 0;
  685. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  686. //===============================
  687. // OCPP auth variable
  688. //===============================
  689. static int authorizeRetryTimes = 0; //number of Retry times
  690. //===============================
  691. // OCPP other variables
  692. //===============================
  693. static int HeartBeatWaitTime = 10;
  694. static int FirstHeartBeat = 0;
  695. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  696. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  697. static char CurrentChargingProfileScheduleStr[30] = {0};
  698. //========================================
  699. // OCPP status/previous related variables
  700. //========================================
  701. static int GunStatusInterval = 10;
  702. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  703. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  704. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  705. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  706. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  707. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  708. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  709. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  710. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  711. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  712. static int TransactionMessageAttemptsValue = 0;
  713. static int TransactionMessageRetryIntervalValue = 0;
  714. static int TempMeterValueInterval = 0;
  715. static struct AuthorizationData idTagQuery;
  716. //=============================================
  717. // OCPP HeartBeat Response Not Receive Counts
  718. //============================================
  719. static int HeartBeatWithNOResponse = 0;
  720. static int HeartBeatCountPerHour = 0;
  721. sqlite3 *db;
  722. int TransactionMessageAttemptsGet(void);
  723. int TransactionMessageRetryIntervalGet(void);
  724. int GetOcppConnStatus(void);
  725. void SetOcppConnStatus(uint8_t status);
  726. int setKeyValue(char *key, char *value);
  727. void OCPP_get_TableAuthlocalAllData(void);
  728. void processUnkownKey(void);
  729. struct StructOCPPMeterValue
  730. {
  731. unsigned char TimeStamp[28];
  732. struct StructSampledValue SampledValue[10];
  733. };
  734. struct ClientTime
  735. {
  736. unsigned int Heartbeat;
  737. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  738. unsigned int StartTransaction;
  739. unsigned int StopTransaction;
  740. unsigned int MeterValues[CONNECTOR_QUANTITY];
  741. }clientTime;
  742. typedef union
  743. {
  744. //Operations Initiated by Central System
  745. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  746. struct
  747. {
  748. //CsMsgValue[0]
  749. unsigned char StatusNotificationReq:1; //bit 0,
  750. unsigned char StatusNotificationConf:1; //bit 1,
  751. unsigned char TriggerMeterValueReq:1; //bit 2,
  752. unsigned char TransactionEventReq:1; //bit 3,
  753. unsigned char SampleMeterReq:1; //bit 4,
  754. unsigned char ClockAlignMeterReq:1; //bit 5,
  755. unsigned char :2;
  756. }bits[CONNECTOR_QUANTITY];
  757. }CpinitiateMsg;
  758. CpinitiateMsg cpinitateMsg;
  759. //=========================================
  760. // Date time related function
  761. //=========================================
  762. void getNowDatetime(uint8_t *data)
  763. {
  764. time_t t = time(NULL);
  765. struct tm tm = *localtime(&t);
  766. 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);
  767. }
  768. //=========================================
  769. // Sqlite3 related function
  770. //=========================================
  771. int DB_Initial()
  772. {
  773. int result = PASS;
  774. char* errMsg = NULL;
  775. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  776. "idToken text UNIQUE,"
  777. "type text,"
  778. "status text,"
  779. "cacheExpiryDateTime text,"
  780. "chargingPriority integer,"
  781. "language1 text,"
  782. "evseId text,"
  783. "language2 text,"
  784. "groupIdToken_idToken text,"
  785. "groupIdToken_type text,"
  786. "personalMessage text);";
  787. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  788. "idToken text UNIQUE,"
  789. "type text,"
  790. "status text,"
  791. "cacheExpiryDateTime text,"
  792. "chargingPriority integer,"
  793. "language1 text,"
  794. "evseId text,"
  795. "language2 text,"
  796. "groupIdToken_idToken text,"
  797. "groupIdToken_type text,"
  798. "personalMessage text,"
  799. "version text);";
  800. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  801. "componentName text NOT NULL ,"
  802. "componentInstance text, "
  803. "variableName text NOT NULL, "
  804. "variableInstance text, "
  805. "variableCharacteristicsDataType integer, "
  806. "variableCharacteristicsUnit text, "
  807. "variableCharacteristicsMaxLimit real,"
  808. "variableAttributesType text, "
  809. "variableAttributesTypeMutability text, "
  810. "variableAttributesTypeValue text, "
  811. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  812. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  813. "type);";
  814. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  815. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  816. {
  817. result = FAIL;
  818. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  819. sqlite3_close(db);
  820. }
  821. else
  822. {
  823. DEBUG_INFO( "OCPP local database open successfully.\n");
  824. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  825. {
  826. result = FAIL;
  827. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  828. }
  829. else
  830. {
  831. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  832. }
  833. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  834. {
  835. result = FAIL;
  836. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  837. }
  838. else
  839. {
  840. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  841. }
  842. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  843. {
  844. result = FAIL;
  845. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  846. }
  847. else
  848. {
  849. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  850. }
  851. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  852. {
  853. result = FAIL;
  854. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  855. }
  856. else
  857. {
  858. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  859. }
  860. //sqlite3_close(db);
  861. }
  862. return result;
  863. }
  864. int versionCallback(void *para, int columnCount, char **columnValue, char **columnName)
  865. {
  866. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  867. return 0;
  868. }
  869. void DB_getListVerion()
  870. {
  871. char sql[256];
  872. char* errMsg = NULL;
  873. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  874. /* Execute SQL statement */
  875. if( sqlite3_exec(db, sql, versionCallback, 0, &errMsg) != SQLITE_OK )
  876. {
  877. DEBUG_INFO("SQL error: %s", errMsg);
  878. }
  879. }
  880. int IdTagCallback(void *para, int columnCount, char **columnValue, char **columnName)
  881. {
  882. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  883. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  884. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  885. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  886. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  887. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  888. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  889. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  890. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  891. return 0;
  892. }
  893. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  894. {
  895. char sql[256];
  896. char* errMsg = NULL;
  897. memset(&idTagQuery, 0, sizeof(idTagQuery));
  898. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  899. if(isQueryFromCache)
  900. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  901. else
  902. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  903. /* Execute SQL statement */
  904. if(sqlite3_exec(db, sql, IdTagCallback, 0, &errMsg) != SQLITE_OK )
  905. {
  906. DEBUG_INFO("SQL error: %s", errMsg);
  907. }
  908. }
  909. int sqlite3_exec_callback(void *para, int columnCount, char **columnValue, char **columnName)
  910. {
  911. for (int i = 0; i < columnCount; i++)
  912. {
  913. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  914. }
  915. return 0;
  916. }
  917. void DB_get_TableAuthlocalAllData(void)
  918. {
  919. char sql[256];
  920. char* errMsg = NULL;
  921. sprintf(sql,"select * from ocpp20_auth_local;");
  922. /* Execute SQL statement */
  923. if(sqlite3_exec(db, sql, &sqlite3_exec_callback, 0,(char **)&errMsg) != SQLITE_OK)
  924. {
  925. DEBUG_INFO("SQL error: %s", errMsg);
  926. }
  927. }
  928. int listCallback(void *para, int columnCount, char **columnValue, char **columnName)
  929. {
  930. for(int i = 0; i<columnCount; i++)
  931. {
  932. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  933. }
  934. return 0;
  935. }
  936. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  937. {
  938. int result = PASS;
  939. char sql[512];
  940. char* errMsg = NULL;
  941. 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;",
  942. data->idToken.idToken,
  943. data->idToken.type,
  944. data->idTokenInfo.status,
  945. data->idTokenInfo.cacheExpiryDateTime,
  946. data->idTokenInfo.chargingPriority,
  947. data->idTokenInfo.language1,
  948. data->idTokenInfo.language2,
  949. data->idTokenInfo.groupIdToken.idToken,
  950. data->idTokenInfo.groupIdToken.type,
  951. listVersion);
  952. //* Execute SQL statement */
  953. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  954. {
  955. DEBUG_INFO("SQL error: %s\n", errMsg);
  956. result = FAIL;
  957. }
  958. else
  959. {
  960. memset(sql, 0, ARRAY_SIZE(sql));
  961. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  962. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  963. {
  964. DEBUG_INFO("SQL error: %s\n", errMsg);
  965. result = FAIL;
  966. }
  967. }
  968. return result;
  969. }
  970. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  971. {
  972. int result = PASS;
  973. char sql[512];
  974. char* errMsg = NULL;
  975. 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;",
  976. idToken->idToken,
  977. idToken->type,
  978. idTokenInfo->status,
  979. idTokenInfo->cacheExpiryDateTime,
  980. idTokenInfo->chargingPriority,
  981. idTokenInfo->language1,
  982. idTokenInfo->language2,
  983. idTokenInfo->groupIdToken.idToken,
  984. idTokenInfo->groupIdToken.type);
  985. //* Execute SQL statement */
  986. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  987. {
  988. DEBUG_INFO("SQL error: %s\n", errMsg);
  989. result = FAIL;
  990. }
  991. return result;
  992. }
  993. static int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  994. {
  995. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  996. // printf("localversion=%d\n", localversion);
  997. return 0;
  998. }
  999. void DB_deleteIdTag(char idTag[])
  1000. {
  1001. char sql[512];
  1002. char* errMsg = NULL;
  1003. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1004. //* Execute SQL statement */
  1005. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1006. {
  1007. DEBUG_INFO("SQL error: %s", errMsg);
  1008. }
  1009. }
  1010. int DB_cleanLocalList()
  1011. {
  1012. int result = PASS;
  1013. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1014. char *errMsg = 0;
  1015. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1016. {
  1017. DEBUG_INFO("%s\n", errMsg);
  1018. result = FAIL;
  1019. }
  1020. return result;
  1021. }
  1022. int DB_cleanLocalCache()
  1023. {
  1024. int result = PASS;
  1025. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1026. char *errMsg = 0;
  1027. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1028. {
  1029. DEBUG_INFO("%s\n", errMsg);
  1030. result = FAIL;
  1031. }
  1032. return result;
  1033. }
  1034. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1035. {
  1036. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1037. return 0;
  1038. }
  1039. void DB_getBooType()
  1040. {
  1041. char sql[256];
  1042. char* errMsg = NULL;
  1043. sprintf(sql,"select * from ocpp20_boot_type;");
  1044. /* Execute SQL statement */
  1045. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1046. {
  1047. DEBUG_INFO("SQL error: %s\n", errMsg);
  1048. }
  1049. }
  1050. int DB_updateBootType(BootReasonEnumType reason)
  1051. {
  1052. int result = PASS;
  1053. char sql[512];
  1054. char* errMsg = NULL;
  1055. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1056. //* Execute SQL statement */
  1057. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  1058. {
  1059. DEBUG_INFO("SQL error: %s\n", errMsg);
  1060. result = FAIL;
  1061. }
  1062. return result;
  1063. }
  1064. uint8_t DB_variableSaveToDb(struct ReportDataType *variable)
  1065. {
  1066. uint8_t result = FAIL;
  1067. char sql[4096];
  1068. char* errMsg = NULL;
  1069. 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;",
  1070. variable->component.name,
  1071. variable->component.instance,
  1072. variable->variable.name,
  1073. variable->variable.instance,
  1074. variable->variableCharacteristics.dataType,
  1075. variable->variableCharacteristics.unit,
  1076. variable->variableCharacteristics.maxLimit,
  1077. variable->variableAttribute[0].type,
  1078. variable->variableAttribute[0].mutability,
  1079. variable->variableAttribute[0].value);
  1080. //* Execute SQL statement */
  1081. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  1082. {
  1083. DEBUG_INFO("SQL error: %s\n", errMsg);
  1084. result = FAIL;
  1085. }
  1086. return result;
  1087. }
  1088. int cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1089. {
  1090. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1091. if(atoi(columnValue[0]) == 0)
  1092. {
  1093. DB_updateBootType(BootReasonEnumType_PowerUp);
  1094. // Create variable table content
  1095. /* AlignedDataCtrlr Required item */
  1096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1102. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1109. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1115. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1117. else
  1118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1119. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1127. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1134. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1141. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1147. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1149. else
  1150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1151. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1159. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1160. /* AuthCtrlrVariable Required item */
  1161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1167. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1174. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1181. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1188. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1195. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1202. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1206. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1210. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1211. /* AuthCacheCtrlr Variable Required item*/
  1212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1218. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1225. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1233. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1237. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*100);
  1238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1241. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1248. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1249. /* ClockCtrlr Variable Required item */
  1250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1255. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1256. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1263. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1271. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1278. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1285. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1293. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1300. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1307. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1308. /* ChargingStation Required item */
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1315. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1322. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1329. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1330. /* Connector Required item */
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1337. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1344. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1351. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1352. /* CustomizationCtrlr Required item */
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1359. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1360. /* DeviceDataCtrlr Required item */
  1361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1368. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1376. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1384. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1392. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1395. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1400. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1403. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1408. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1416. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1424. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1425. /* DisplayMessageCtrlr Required item */
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1432. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1439. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "0");
  1446. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1453. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1460. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1461. /* EVSE Required item */
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1468. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1475. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1482. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1489. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1490. /* LocalAuthListCtrlr Required item */
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1497. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1504. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1511. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "50");
  1519. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "2048");
  1527. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1531. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = 1024*1024;
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "5000");
  1535. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1536. /* MonitoringCtrlr Required item */
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1543. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1550. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1558. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1566. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1574. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1582. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1583. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1589. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1590. /* OCPPCommCtrlr Required item */
  1591. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1597. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1606. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1613. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1621. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1622. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "LAN,WIFI,4G");
  1628. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1635. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1643. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1650. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1659. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1660. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1668. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1675. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1683. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1690. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1697. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1698. /* ReservationCtrlr Required item */
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1705. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1712. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1719. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1720. /* SampledDataCtrlr Required item */
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1727. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1730. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1734. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1741. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, " ");
  1748. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1752. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1756. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1763. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, " ");
  1770. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "0");
  1778. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1779. /* SecurityCtrlr Required item */
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1783. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
  1787. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1788. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1791. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
  1795. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1796. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
  1802. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1807. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1809. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
  1816. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1821. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1823. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1824. /* SmartChargingCtrlr Required item */
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1829. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1831. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1836. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1838. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1843. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1845. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1850. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1852. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1857. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  1859. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1865. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  1866. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1871. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  1873. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1878. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  1880. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  1887. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1892. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "3");
  1894. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1899. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  1901. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  1902. /* TariffCostCtrlr Required item */
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  1910. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  1913. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  1918. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  1920. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1922. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  1926. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  1927. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  1928. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  1929. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  1934. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  1942. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  1944. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1946. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  1950. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  1952. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1954. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  1958. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  1959. /* TxCtrlr Required item */
  1960. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1964. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1966. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  1967. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  1968. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  1974. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1981. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1988. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1992. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "EVConnected,Authorized,PowerPathClosed");
  1995. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2000. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "EVConnected,Authorized,PowerPathClosed");
  2002. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2005. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "60000");
  2010. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2017. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2018. }
  2019. else
  2020. {
  2021. // Variable name init
  2022. /* AlignedDataCtrlr Required item */
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2028. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2036. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2039. /* AuthCtrlrVariable Required item */
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2043. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2044. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2045. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2046. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2047. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2048. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2051. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2054. /* AuthCacheCtrlr Variable Required item */
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2065. /* ClockCtrlr Variable Required item */
  2066. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2084. /* ChargingStation Required item */
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2088. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2091. /* Connector Required item */
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2098. /* DeviceDataCtrlr Required item */
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2121. /* DisplayMessageCtrlr Required item */
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2132. /* EVSE Required item */
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2141. /* LocalAuthListCtrlr Required item */
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2156. /* MonitoringCtrlr Required item */
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2175. /* OCPPCommCtrlr Required item */
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2207. /* ReservationCtrlr Required item */
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2214. /* SampledDataCtrlr Required item */
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2231. /* SecurityCtrlr Required item */
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2244. /* SmartChargingCtrlr Required item */
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2267. /* TariffCostCtrlr Required item */
  2268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2286. /* TxCtrlr Required item */
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2303. }
  2304. return 0;
  2305. }
  2306. void DB_variableIsCreate()
  2307. {
  2308. char sql[512];
  2309. char* errMsg = NULL;
  2310. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2311. /* Execute SQL statement */
  2312. if(sqlite3_exec(db, sql, cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2313. {
  2314. DEBUG_INFO("SQL error: %s\n", errMsg);
  2315. }
  2316. }
  2317. int cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2318. {
  2319. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2320. {
  2321. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) != NULL) &&
  2322. (strlen(columnValue[2])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) != NULL):TRUE) &&
  2323. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) != NULL) &&
  2324. (strlen(columnValue[4])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) != NULL):TRUE))
  2325. {
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2328. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2332. }
  2333. }
  2334. return 0;
  2335. }
  2336. void DB_variableLoadFromDb()
  2337. {
  2338. char sql[512];
  2339. char* errMsg = NULL;
  2340. sprintf(sql,"select * from ocpp20_variable;");
  2341. /* Execute SQL statement */
  2342. if(sqlite3_exec(db, sql, cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2343. {
  2344. DEBUG_INFO("SQL error: %s\n", errMsg);
  2345. }
  2346. }
  2347. //==========================================
  2348. // Check time passed since today
  2349. //==========================================
  2350. long long DiffTimebWithNow(struct timeb ST)
  2351. {
  2352. //return milli-second
  2353. struct timeb ET;
  2354. long long StartTime,StopTime;
  2355. ftime(&ET);
  2356. StartTime=(long long)ST.time;
  2357. StopTime=(long long)ET.time;
  2358. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2359. }
  2360. int getTimePassSinceToday()
  2361. {
  2362. int result = -1;
  2363. time_t t;
  2364. struct tm *tmStartToday;
  2365. struct timeb tbStartToday;
  2366. t=time(NULL);
  2367. tmStartToday=localtime(&t);
  2368. tmStartToday->tm_hour = 0;
  2369. tmStartToday->tm_min = 0;
  2370. tmStartToday->tm_sec = 0;
  2371. tbStartToday.time = mktime(tmStartToday);
  2372. tbStartToday.millitm = 0;
  2373. result = DiffTimebWithNow(tbStartToday)/1000;
  2374. return result;
  2375. }
  2376. //==========================================
  2377. // GetCompositeSchedule logic related function
  2378. //==========================================
  2379. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2380. {
  2381. //return milli-second
  2382. unsigned int StartTime,StopTime;
  2383. StartTime=(unsigned int)ST.time;
  2384. StopTime=(unsigned int)ET.time;
  2385. return (StopTime-StartTime);
  2386. }
  2387. int DiffTimebWithNowSec(struct timeb ST)
  2388. {
  2389. //return milli-second
  2390. struct timeb ET;
  2391. unsigned int StartTime,StopTime;
  2392. ftime(&ET);
  2393. StartTime=(unsigned int)ST.time;
  2394. StopTime=(unsigned int)ET.time;
  2395. return (StopTime-StartTime);
  2396. }
  2397. int getStartStop(uint8_t *start, uint8_t *stop)
  2398. {
  2399. int result = -1;
  2400. struct tm tmStart;
  2401. struct timeb tbStart;
  2402. struct tm tmStop;
  2403. struct timeb tbStop;
  2404. 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) &&
  2405. (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))
  2406. {
  2407. //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);
  2408. //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);
  2409. tmStart.tm_year -= 1900;
  2410. tmStart.tm_mon -= 1;
  2411. tbStart.time = mktime(&tmStart);
  2412. tbStart.millitm = 0;
  2413. tmStop.tm_year -= 1900;
  2414. tmStop.tm_mon -= 1;
  2415. tbStop.time = mktime(&tmStop);
  2416. tbStop.millitm = 0;
  2417. result = DiffTimebSec(tbStart, tbStop);
  2418. //DEBUG_INFO("getStartStop(): %d\n", result);
  2419. }
  2420. else
  2421. {
  2422. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2423. }
  2424. return result;
  2425. }
  2426. int isOvertNow(uint8_t *start)
  2427. {
  2428. int result = YES;
  2429. struct tm tmStart;
  2430. struct timeb tbStart;
  2431. 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))
  2432. {
  2433. //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);
  2434. tmStart.tm_year -= 1900;
  2435. tmStart.tm_mon -= 1;
  2436. tbStart.time = mktime(&tmStart);
  2437. tbStart.millitm = 0;
  2438. if(DiffTimebWithNowSec(tbStart) <= 0)
  2439. result = NO;
  2440. }
  2441. else
  2442. {
  2443. DEBUG_WARN("Start date parsing error.\r\n");
  2444. }
  2445. return result;
  2446. }
  2447. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2448. {
  2449. int result = -1;
  2450. struct tm tmStart;
  2451. struct timeb tbStart;
  2452. struct tm tmStop;
  2453. struct timeb tbStop;
  2454. 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) &&
  2455. (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))
  2456. {
  2457. tmStart.tm_year -= 1900;
  2458. tmStart.tm_mon -= 1;
  2459. tbStart.time = mktime(&tmStart);
  2460. tbStart.millitm = 0;
  2461. tmStop.tm_year -= 1900;
  2462. tmStop.tm_mon -= 1;
  2463. tbStop.time = mktime(&tmStop);
  2464. tbStop.millitm = 0;
  2465. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2466. }
  2467. return result;
  2468. }
  2469. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile)
  2470. {
  2471. FILE *fp;
  2472. char profileFileName[128];
  2473. char *line = NULL;
  2474. size_t len = 0;
  2475. time_t CurrentTime;
  2476. struct tm *tmComposite;
  2477. struct ChargingProfileType maxProfile;
  2478. struct ChargingProfileType defaultTxProfile;
  2479. struct ChargingProfileType txProfile;
  2480. struct ChargingSchedulePeriodType tmpPeriod;
  2481. uint8_t limitMax=0;
  2482. uint8_t limitDef=0;
  2483. uint8_t limitTx=0;
  2484. int compositePeriodIdx = 0;
  2485. CurrentTime = time(NULL);
  2486. tmComposite=localtime(&CurrentTime);
  2487. 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);
  2488. sprintf((char*)compositeProfile->chargingSchedule[0].chargingRateUnit, "A");
  2489. compositeProfile->chargingSchedule[0].duration = durationReq;
  2490. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2491. {
  2492. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2493. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2494. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2495. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  2496. }
  2497. compositeProfile->id = 0;
  2498. compositeProfile->stackLevel = 99 ;
  2499. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  2500. maxProfile.id = -1;
  2501. defaultTxProfile.id = -1;
  2502. txProfile.id = -1;
  2503. maxProfile.chargingSchedule[0].duration = -1;
  2504. defaultTxProfile.chargingSchedule[0].duration = -1;
  2505. txProfile.chargingSchedule[0].duration = -1;
  2506. system("yes|rm /tmp/*.json");
  2507. system("cp /Storage/OCPP/*.json /tmp");
  2508. /*
  2509. * Search valid charging profile
  2510. */
  2511. //DEBUG_INFO("====================================\n");
  2512. // Search tx profile
  2513. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  2514. if((access(profileFileName, F_OK))!=-1)
  2515. {
  2516. fp = fopen(profileFileName, "r");
  2517. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2518. {
  2519. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2520. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2521. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2522. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2523. }
  2524. txProfile.id = -1;
  2525. txProfile.stackLevel = -1;
  2526. while(getline(&line, &len, fp) != -1)
  2527. {
  2528. json_object *obj = NULL;
  2529. obj = json_tokener_parse(line);
  2530. if(is_error(obj))
  2531. {
  2532. DEBUG_ERROR("Parse txProfile from file error.\n");
  2533. }
  2534. else
  2535. {
  2536. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  2537. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  2538. )
  2539. {
  2540. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2541. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2542. )
  2543. {
  2544. struct tm tmFrom, tmTo;
  2545. struct timeb tbFrom, tbTo;
  2546. 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) &&
  2547. (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))
  2548. {
  2549. tmFrom.tm_year -= 1900;
  2550. tmFrom.tm_mon -= 1;
  2551. tbFrom.time = mktime(&tmFrom);
  2552. tmTo.tm_year -= 1900;
  2553. tmTo.tm_mon -= 1;
  2554. tbTo.time = mktime(&tmTo);
  2555. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2556. {
  2557. if(txProfile.id == -1)
  2558. DEBUG_INFO("TxProfile found.\n");
  2559. else
  2560. DEBUG_INFO("TxProfile updated.\n");
  2561. // Required item
  2562. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2563. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2564. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2565. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2566. 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++)
  2567. {
  2568. 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"));
  2569. 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")));
  2570. 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?
  2571. 3:
  2572. 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")));
  2573. }
  2574. // Optional item
  2575. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2576. {
  2577. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2578. }
  2579. else
  2580. {
  2581. sprintf((char*)txProfile.validFrom, " ");
  2582. }
  2583. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2584. {
  2585. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2586. }
  2587. else
  2588. {
  2589. sprintf((char*)txProfile.validTo, " ");
  2590. }
  2591. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2592. {
  2593. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2594. }
  2595. else
  2596. {
  2597. sprintf((char*)txProfile.recurrencyKind, " ");
  2598. }
  2599. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2600. {
  2601. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2602. }
  2603. else
  2604. {
  2605. sprintf((char*)txProfile.transactionId, " ");
  2606. }
  2607. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2608. {
  2609. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2610. }
  2611. else
  2612. {
  2613. txProfile.chargingSchedule[0].duration = 86400;
  2614. }
  2615. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2616. {
  2617. 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")));
  2618. }
  2619. else
  2620. {
  2621. 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));
  2622. }
  2623. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2624. {
  2625. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2626. }
  2627. else
  2628. {
  2629. txProfile.chargingSchedule[0].minChargingRate = -1;
  2630. }
  2631. }
  2632. }
  2633. }
  2634. else
  2635. {
  2636. if(txProfile.id == -1)
  2637. DEBUG_INFO("TxProfile found.\n");
  2638. else
  2639. DEBUG_INFO("TxProfile updated.\n");
  2640. // Required item
  2641. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2642. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2643. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2644. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2645. 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++)
  2646. {
  2647. 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"));
  2648. 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")));
  2649. 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?
  2650. 3:
  2651. 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")));
  2652. }
  2653. // Optional item
  2654. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2655. {
  2656. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2657. }
  2658. else
  2659. {
  2660. sprintf((char*)txProfile.validFrom, " ");
  2661. }
  2662. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2663. {
  2664. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2665. }
  2666. else
  2667. {
  2668. sprintf((char*)txProfile.validTo, " ");
  2669. }
  2670. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2671. {
  2672. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2673. }
  2674. else
  2675. {
  2676. sprintf((char*)txProfile.recurrencyKind, " ");
  2677. }
  2678. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2679. {
  2680. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2681. }
  2682. else
  2683. {
  2684. sprintf((char*)txProfile.transactionId, " ");
  2685. }
  2686. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2687. {
  2688. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2689. }
  2690. else
  2691. {
  2692. txProfile.chargingSchedule[0].duration = 86400;
  2693. }
  2694. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2695. {
  2696. 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")));
  2697. }
  2698. else
  2699. {
  2700. 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));
  2701. }
  2702. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2703. {
  2704. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2705. }
  2706. else
  2707. {
  2708. txProfile.chargingSchedule[0].minChargingRate = -1;
  2709. }
  2710. }
  2711. }
  2712. }
  2713. json_object_put(obj);
  2714. }
  2715. fclose(fp);
  2716. /*
  2717. if(txProfile.ChargingProfileId != -1)
  2718. {
  2719. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  2720. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  2721. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  2722. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  2723. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  2724. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  2725. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  2726. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[0].StartSchedule);
  2727. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  2728. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  2729. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  2730. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2731. {
  2732. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2733. {
  2734. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2735. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2736. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2737. }
  2738. }
  2739. }
  2740. else
  2741. DEBUG_INFO("TxProfile not found.\n");*/
  2742. }
  2743. // Search default tx profile
  2744. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  2745. if((access(profileFileName, F_OK))==-1)
  2746. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  2747. if((access(profileFileName, F_OK))!=-1)
  2748. {
  2749. fp = fopen(profileFileName, "r");
  2750. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2751. {
  2752. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2753. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2754. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2755. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2756. }
  2757. defaultTxProfile.id = -1;
  2758. defaultTxProfile.stackLevel = -1;
  2759. while(getline(&line, &len, fp) != -1)
  2760. {
  2761. json_object *obj = NULL;
  2762. obj = json_tokener_parse(line);
  2763. if(is_error(obj))
  2764. {
  2765. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  2766. }
  2767. else
  2768. {
  2769. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  2770. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  2771. )
  2772. {
  2773. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2774. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2775. )
  2776. {
  2777. struct tm tmFrom, tmTo;
  2778. struct timeb tbFrom, tbTo;
  2779. 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) &&
  2780. (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))
  2781. {
  2782. tmFrom.tm_year -= 1900;
  2783. tmFrom.tm_mon -= 1;
  2784. tbFrom.time = mktime(&tmFrom);
  2785. tmTo.tm_year -= 1900;
  2786. tmTo.tm_mon -= 1;
  2787. tbTo.time = mktime(&tmTo);
  2788. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2789. {
  2790. if(defaultTxProfile.id == -1)
  2791. DEBUG_INFO("TxDefaultProfile found.\n");
  2792. else
  2793. DEBUG_INFO("TxDefaultProfile updated.\n");
  2794. // Required item
  2795. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2796. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2797. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2798. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2799. 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++)
  2800. {
  2801. 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"));
  2802. 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")));
  2803. 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?
  2804. 3:
  2805. 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")));
  2806. }
  2807. // Optional item
  2808. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2809. {
  2810. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2811. }
  2812. else
  2813. {
  2814. sprintf((char*)defaultTxProfile.validFrom, " ");
  2815. }
  2816. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2817. {
  2818. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2819. }
  2820. else
  2821. {
  2822. sprintf((char*)defaultTxProfile.validTo, " ");
  2823. }
  2824. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2825. {
  2826. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2827. }
  2828. else
  2829. {
  2830. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2831. }
  2832. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2833. {
  2834. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2835. }
  2836. else
  2837. {
  2838. sprintf((char*)defaultTxProfile.transactionId, " ");
  2839. }
  2840. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2841. {
  2842. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2843. }
  2844. else
  2845. {
  2846. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2847. }
  2848. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2849. {
  2850. 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")));
  2851. }
  2852. else
  2853. {
  2854. 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));
  2855. }
  2856. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2857. {
  2858. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2859. }
  2860. else
  2861. {
  2862. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  2863. }
  2864. }
  2865. }
  2866. }
  2867. else
  2868. {
  2869. if(defaultTxProfile.id == -1)
  2870. DEBUG_INFO("TxDefaultProfile found.\n");
  2871. else
  2872. DEBUG_INFO("TxDefaultProfile updated.\n");
  2873. // Required item
  2874. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2875. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2876. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2877. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2878. 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++)
  2879. {
  2880. 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"));
  2881. 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")));
  2882. 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?
  2883. 3:
  2884. 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")));
  2885. }
  2886. // Optional item
  2887. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2888. {
  2889. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2890. }
  2891. else
  2892. {
  2893. sprintf((char*)defaultTxProfile.validFrom, " ");
  2894. }
  2895. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2896. {
  2897. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2898. }
  2899. else
  2900. {
  2901. sprintf((char*)defaultTxProfile.validTo, " ");
  2902. }
  2903. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2904. {
  2905. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2906. }
  2907. else
  2908. {
  2909. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2910. }
  2911. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2912. {
  2913. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2914. }
  2915. else
  2916. {
  2917. sprintf((char*)defaultTxProfile.transactionId, " ");
  2918. }
  2919. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2920. {
  2921. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2922. }
  2923. else
  2924. {
  2925. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2926. }
  2927. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2928. {
  2929. 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")));
  2930. }
  2931. else
  2932. {
  2933. 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));
  2934. }
  2935. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2936. {
  2937. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2938. }
  2939. else
  2940. {
  2941. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  2942. }
  2943. }
  2944. }
  2945. }
  2946. json_object_put(obj);
  2947. }
  2948. fclose(fp);
  2949. /*
  2950. if(defaultTxProfile.ChargingProfileId != -1)
  2951. {
  2952. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  2953. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  2954. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  2955. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  2956. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  2957. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  2958. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  2959. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[0].StartSchedule);
  2960. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  2961. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  2962. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  2963. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2964. {
  2965. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2966. {
  2967. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2968. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2969. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2970. }
  2971. }
  2972. }
  2973. else
  2974. DEBUG_INFO("TxDefaultProfile not found.\n");
  2975. DEBUG_INFO("------------------------------------\n");*/
  2976. }
  2977. // Search max profile
  2978. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  2979. if((access(profileFileName, F_OK))!=-1)
  2980. {
  2981. fp = fopen(profileFileName, "r");
  2982. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2983. {
  2984. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2985. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2986. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2987. }
  2988. maxProfile.id = -1;
  2989. maxProfile.stackLevel = -1;
  2990. while(getline(&line, &len, fp) != -1)
  2991. {
  2992. json_object *obj = NULL;
  2993. obj = json_tokener_parse(line);
  2994. if(is_error(obj))
  2995. {
  2996. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  2997. }
  2998. else
  2999. {
  3000. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  3001. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3002. )
  3003. {
  3004. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3005. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3006. )
  3007. {
  3008. struct tm tmFrom, tmTo;
  3009. struct timeb tbFrom, tbTo;
  3010. 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) &&
  3011. (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))
  3012. {
  3013. tmFrom.tm_year -= 1900;
  3014. tmFrom.tm_mon -= 1;
  3015. tbFrom.time = mktime(&tmFrom);
  3016. tmTo.tm_year -= 1900;
  3017. tmTo.tm_mon -= 1;
  3018. tbTo.time = mktime(&tmTo);
  3019. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3020. {
  3021. if(maxProfile.id == -1)
  3022. DEBUG_INFO("MaxProfile found.\n");
  3023. else
  3024. DEBUG_INFO("MaxProfile updated.\n");
  3025. // Required item
  3026. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3027. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3028. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3029. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3030. 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++)
  3031. {
  3032. 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"));
  3033. 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")));
  3034. 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?
  3035. 3:
  3036. 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")));
  3037. }
  3038. // Optional item
  3039. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3040. {
  3041. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3042. }
  3043. else
  3044. {
  3045. sprintf((char*)maxProfile.validFrom, " ");
  3046. }
  3047. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3048. {
  3049. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3050. }
  3051. else
  3052. {
  3053. sprintf((char*)maxProfile.validTo, " ");
  3054. }
  3055. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3056. {
  3057. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3058. }
  3059. else
  3060. {
  3061. sprintf((char*)maxProfile.recurrencyKind, " ");
  3062. }
  3063. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3064. {
  3065. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3066. }
  3067. else
  3068. {
  3069. sprintf((char*)maxProfile.transactionId, " ");
  3070. }
  3071. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3072. {
  3073. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3074. }
  3075. else
  3076. {
  3077. maxProfile.chargingSchedule[0].duration = 86400;
  3078. }
  3079. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3080. {
  3081. 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")));
  3082. }
  3083. else
  3084. {
  3085. 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));
  3086. }
  3087. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3088. {
  3089. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3090. }
  3091. else
  3092. {
  3093. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3094. }
  3095. }
  3096. }
  3097. }
  3098. else
  3099. {
  3100. if(maxProfile.id == -1)
  3101. DEBUG_INFO("MaxProfile found.\n");
  3102. else
  3103. DEBUG_INFO("MaxProfile updated.\n");
  3104. // Required item
  3105. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3106. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3107. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3108. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3109. 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++)
  3110. {
  3111. 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"));
  3112. 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")));
  3113. 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?
  3114. 3:
  3115. 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")));
  3116. }
  3117. // Optional item
  3118. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3119. {
  3120. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3121. }
  3122. else
  3123. {
  3124. sprintf((char*)maxProfile.validFrom, " ");
  3125. }
  3126. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3127. {
  3128. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3129. }
  3130. else
  3131. {
  3132. sprintf((char*)maxProfile.validTo, " ");
  3133. }
  3134. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3135. {
  3136. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3137. }
  3138. else
  3139. {
  3140. sprintf((char*)maxProfile.recurrencyKind, " ");
  3141. }
  3142. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3143. {
  3144. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3145. }
  3146. else
  3147. {
  3148. sprintf((char*)maxProfile.transactionId, " ");
  3149. }
  3150. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3151. {
  3152. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3153. }
  3154. else
  3155. {
  3156. maxProfile.chargingSchedule[0].duration = 86400;
  3157. }
  3158. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3159. {
  3160. 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")));
  3161. }
  3162. else
  3163. {
  3164. 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));
  3165. }
  3166. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3167. {
  3168. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3169. }
  3170. else
  3171. {
  3172. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3173. }
  3174. }
  3175. }
  3176. }
  3177. json_object_put(obj);
  3178. }
  3179. fclose(fp);
  3180. /*
  3181. if(maxProfile.ChargingProfileId !=-1)
  3182. {
  3183. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3184. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3185. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3186. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3187. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3188. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3189. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3190. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[0].StartSchedule);
  3191. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3192. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3193. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3194. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3195. {
  3196. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3197. {
  3198. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3199. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3200. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3201. }
  3202. }
  3203. }
  3204. else
  3205. DEBUG_INFO("MaxProfile not found.\n");
  3206. DEBUG_INFO("------------------------------------\n");*/
  3207. }
  3208. /*
  3209. * Align found profile start schedule & periods
  3210. */
  3211. //DEBUG_INFO("====================================\n");
  3212. /*
  3213. // For local test usage, force modify found profile start schedule info
  3214. 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);
  3215. 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);
  3216. 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);
  3217. */
  3218. if(txProfile.id != -1)
  3219. {
  3220. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3221. {
  3222. if(txProfile.chargingSchedule[0].duration != -1)
  3223. {
  3224. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3225. 0:
  3226. (txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3227. }
  3228. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3229. {
  3230. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3231. {
  3232. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3233. 0:
  3234. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3235. if(idxPeriod > 0)
  3236. {
  3237. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3238. {
  3239. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3240. }
  3241. }
  3242. }
  3243. }
  3244. }
  3245. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3246. {
  3247. if(txProfile.chargingSchedule[0].duration != -1)
  3248. {
  3249. 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?
  3250. 0:
  3251. (txProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3252. }
  3253. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3254. {
  3255. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3256. {
  3257. 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?
  3258. 0:
  3259. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3260. if(idxPeriod > 0)
  3261. {
  3262. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3263. {
  3264. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3265. }
  3266. }
  3267. }
  3268. }
  3269. }
  3270. else
  3271. {
  3272. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3273. {
  3274. if(txProfile.chargingSchedule[0].duration != -1)
  3275. {
  3276. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3277. 0:
  3278. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3279. }
  3280. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3281. {
  3282. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3283. {
  3284. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3285. 0:
  3286. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3287. if(idxPeriod > 0)
  3288. {
  3289. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3290. {
  3291. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3292. }
  3293. }
  3294. }
  3295. }
  3296. }
  3297. else
  3298. {
  3299. if(txProfile.chargingSchedule[0].duration != -1)
  3300. {
  3301. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3302. 0:
  3303. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3304. }
  3305. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3306. {
  3307. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3308. {
  3309. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3310. 0:
  3311. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3312. if(idxPeriod > 0)
  3313. {
  3314. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3315. {
  3316. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3317. }
  3318. }
  3319. }
  3320. }
  3321. }
  3322. }
  3323. /*
  3324. DEBUG_INFO("txProfile after align.\n");
  3325. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3326. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3327. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3328. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3329. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3330. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3331. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3332. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3333. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  3334. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  3335. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  3336. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3337. {
  3338. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3339. {
  3340. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3341. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3342. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3343. }
  3344. }*/
  3345. }
  3346. if(defaultTxProfile.id != -1)
  3347. {
  3348. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3349. {
  3350. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3351. {
  3352. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3353. 0:
  3354. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3355. }
  3356. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3357. {
  3358. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3359. {
  3360. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3361. 0:
  3362. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3363. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3364. {
  3365. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3366. }
  3367. if(idxPeriod > 0)
  3368. {
  3369. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3370. {
  3371. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3372. }
  3373. }
  3374. }
  3375. }
  3376. }
  3377. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3378. {
  3379. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3380. {
  3381. 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?
  3382. 0:
  3383. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3384. }
  3385. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3386. {
  3387. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3388. {
  3389. 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?
  3390. 0:
  3391. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3392. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3393. {
  3394. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3395. }
  3396. if(idxPeriod > 0)
  3397. {
  3398. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3399. {
  3400. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3401. }
  3402. }
  3403. }
  3404. }
  3405. }
  3406. else
  3407. {
  3408. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3409. {
  3410. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3411. {
  3412. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3413. 0:
  3414. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3415. }
  3416. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3417. {
  3418. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3419. {
  3420. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3421. 0:
  3422. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3423. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3424. {
  3425. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3426. }
  3427. if(idxPeriod > 0)
  3428. {
  3429. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3430. {
  3431. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3432. }
  3433. }
  3434. }
  3435. }
  3436. }
  3437. else
  3438. {
  3439. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3440. {
  3441. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3442. 0:
  3443. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3444. }
  3445. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3446. {
  3447. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3448. {
  3449. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3450. 0:
  3451. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3452. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3453. {
  3454. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3455. }
  3456. if(idxPeriod > 0)
  3457. {
  3458. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3459. {
  3460. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3461. }
  3462. }
  3463. }
  3464. }
  3465. }
  3466. }
  3467. /*
  3468. DEBUG_INFO("defaultTxProfile after align.\n");
  3469. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3470. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3471. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3472. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3473. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3474. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3475. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3476. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3477. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3478. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3479. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3480. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3481. {
  3482. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3483. {
  3484. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3485. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3486. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3487. }
  3488. }
  3489. DEBUG_INFO("------------------------------------\n");*/
  3490. }
  3491. if(maxProfile.id != -1)
  3492. {
  3493. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3494. {
  3495. if(maxProfile.chargingSchedule[0].duration != -1)
  3496. {
  3497. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3498. 0:
  3499. (maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3500. }
  3501. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3502. {
  3503. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3504. {
  3505. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3506. 0:
  3507. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3508. if(idxPeriod > 0)
  3509. {
  3510. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3511. {
  3512. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3513. }
  3514. }
  3515. }
  3516. }
  3517. }
  3518. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3519. {
  3520. if(maxProfile.chargingSchedule[0].duration != -1)
  3521. {
  3522. 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?
  3523. 0:
  3524. (maxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  3525. }
  3526. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3527. {
  3528. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3529. {
  3530. 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?
  3531. 0:
  3532. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3533. if(idxPeriod > 0)
  3534. {
  3535. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3536. {
  3537. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3538. }
  3539. }
  3540. }
  3541. }
  3542. }
  3543. else
  3544. {
  3545. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3546. {
  3547. if(maxProfile.chargingSchedule[0].duration != -1)
  3548. {
  3549. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3550. 0:
  3551. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3552. }
  3553. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3554. {
  3555. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3556. {
  3557. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3558. 0:
  3559. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3560. if(idxPeriod > 0)
  3561. {
  3562. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3563. {
  3564. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3565. }
  3566. }
  3567. }
  3568. }
  3569. }
  3570. else
  3571. {
  3572. if(maxProfile.chargingSchedule[0].duration != -1)
  3573. {
  3574. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3575. 0:
  3576. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3577. }
  3578. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3579. {
  3580. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3581. {
  3582. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3583. 0:
  3584. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3585. if(idxPeriod > 0)
  3586. {
  3587. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3588. {
  3589. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3590. }
  3591. }
  3592. }
  3593. }
  3594. }
  3595. }
  3596. /*
  3597. DEBUG_INFO("MaxProfile after align.\n");
  3598. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3599. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3600. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3601. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3602. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3603. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3604. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3605. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3606. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3607. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3608. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3609. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3610. {
  3611. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3612. {
  3613. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3614. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3615. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3616. }
  3617. }
  3618. DEBUG_INFO("------------------------------------\n");*/
  3619. }
  3620. /*
  3621. * Merge to conposite schedule
  3622. */
  3623. //DEBUG_INFO("====================================\n");
  3624. // Find each profile period quantity
  3625. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3626. {
  3627. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3628. limitMax = idx+1;
  3629. }
  3630. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3631. {
  3632. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3633. limitDef = idx+1;
  3634. }
  3635. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3636. {
  3637. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3638. limitTx = idx+1;
  3639. }
  3640. // TxProfile found, composite schedule based on it
  3641. if(txProfile.id != -1)
  3642. {
  3643. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  3644. {
  3645. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  3646. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  3647. (txProfile.chargingSchedule[0].duration > 0))
  3648. {
  3649. if(maxProfile.id != -1)
  3650. {
  3651. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3652. {
  3653. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  3654. {
  3655. if((maxProfile.chargingSchedule[0].duration > 0))
  3656. {
  3657. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3658. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3659. 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);
  3660. }
  3661. else
  3662. {
  3663. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3664. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3665. tmpPeriod.limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit;
  3666. }
  3667. }
  3668. if(idxMaxPeriod == (limitMax-1))
  3669. {
  3670. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3671. {
  3672. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3673. {
  3674. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3675. compositePeriodIdx++;
  3676. }
  3677. else
  3678. {
  3679. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3680. }
  3681. }
  3682. }
  3683. }
  3684. }
  3685. else
  3686. {
  3687. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3688. {
  3689. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3690. compositePeriodIdx++;
  3691. }
  3692. else
  3693. {
  3694. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3695. }
  3696. }
  3697. }
  3698. if(idxTxPeriod == (limitTx-1))
  3699. {
  3700. if(defaultTxProfile.id != -1)
  3701. {
  3702. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3703. {
  3704. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  3705. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3706. (defaultTxProfile.chargingSchedule[0].duration>0))
  3707. {
  3708. if(maxProfile.id != -1)
  3709. {
  3710. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3711. {
  3712. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3713. {
  3714. if((maxProfile.chargingSchedule[0].duration > 0))
  3715. {
  3716. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3717. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3718. 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);
  3719. }
  3720. else
  3721. {
  3722. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3723. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3724. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3725. }
  3726. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3727. {
  3728. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3729. {
  3730. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3731. compositePeriodIdx++;
  3732. }
  3733. else
  3734. {
  3735. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3736. }
  3737. }
  3738. break;
  3739. }
  3740. }
  3741. }
  3742. else
  3743. {
  3744. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3745. {
  3746. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3747. compositePeriodIdx++;
  3748. }
  3749. else
  3750. {
  3751. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3752. }
  3753. }
  3754. }
  3755. }
  3756. }
  3757. }
  3758. }
  3759. }
  3760. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  3761. else if(defaultTxProfile.id != -1)
  3762. {
  3763. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3764. {
  3765. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  3766. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3767. (defaultTxProfile.chargingSchedule[0].duration > 0))
  3768. {
  3769. if(maxProfile.id != -1)
  3770. {
  3771. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3772. {
  3773. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3774. {
  3775. if((maxProfile.chargingSchedule[0].duration > 0))
  3776. {
  3777. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3778. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3779. 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);
  3780. }
  3781. else
  3782. {
  3783. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3784. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3785. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3786. }
  3787. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3788. {
  3789. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3790. {
  3791. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3792. compositePeriodIdx++;
  3793. }
  3794. else
  3795. {
  3796. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3797. }
  3798. }
  3799. break;
  3800. }
  3801. }
  3802. }
  3803. else
  3804. {
  3805. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3806. {
  3807. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3808. compositePeriodIdx++;
  3809. }
  3810. else
  3811. {
  3812. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3813. }
  3814. }
  3815. }
  3816. }
  3817. }
  3818. // Fill other period by MaxProfile
  3819. if(maxProfile.id != -1)
  3820. {
  3821. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3822. {
  3823. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3824. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3825. (maxProfile.chargingSchedule[0].duration > 0))
  3826. {
  3827. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  3828. (maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3829. {
  3830. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  3831. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  3832. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3833. }
  3834. if((maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3835. {
  3836. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].duration;
  3837. tmpPeriod.numberPhases = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  3838. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3839. }
  3840. if(tmpPeriod.limit != -1)
  3841. {
  3842. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3843. {
  3844. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3845. {
  3846. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3847. compositePeriodIdx++;
  3848. }
  3849. else
  3850. {
  3851. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3852. }
  3853. }
  3854. }
  3855. }
  3856. }
  3857. }
  3858. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  3859. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[0].startSchedule);
  3860. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[0].duration);
  3861. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[0].chargingRateUnit);
  3862. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3863. {
  3864. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  3865. {
  3866. compositeProfile->id = 1;
  3867. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3868. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit);
  3869. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases);
  3870. }
  3871. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit == -1)
  3872. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit =0;
  3873. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  3874. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  3875. }
  3876. if(line)
  3877. free(line);
  3878. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  3879. }
  3880. //==========================================
  3881. // Init all share memory
  3882. //==========================================
  3883. int InitShareMemory()
  3884. {
  3885. int result = PASS;
  3886. int MeterSMId;
  3887. //creat ShmSysConfigAndInfo
  3888. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  3889. {
  3890. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  3891. result = FAIL;
  3892. }
  3893. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3894. {
  3895. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  3896. result = FAIL;
  3897. }
  3898. else
  3899. {}
  3900. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  3901. {
  3902. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  3903. result = FAIL;
  3904. }
  3905. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3906. {
  3907. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  3908. result = FAIL;
  3909. }
  3910. else
  3911. {}
  3912. //creat ShmPsuData
  3913. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  3914. {
  3915. DEBUG_ERROR("shmget ShmPsuData NG\n");
  3916. result = FAIL;
  3917. }
  3918. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3919. {
  3920. DEBUG_ERROR("shmat ShmPsuData NG\n");
  3921. result = FAIL;
  3922. }
  3923. else
  3924. {}
  3925. //creat ShmOCPP20Data
  3926. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  3927. {
  3928. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  3929. result = FAIL;
  3930. }
  3931. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3932. {
  3933. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  3934. result = FAIL;
  3935. }
  3936. else
  3937. {}
  3938. /****************************** For Initial Settings************************************************/
  3939. //offline MeterValue Interval
  3940. TempMeterValueInterval = 0;
  3941. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  3942. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  3943. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  3944. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  3945. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  3946. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  3947. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  3948. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  3949. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  3950. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  3951. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  3952. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  3953. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  3954. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  3955. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  3956. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  3957. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  3958. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  3959. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  3960. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  3961. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  3962. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  3963. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  3964. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  3965. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  3966. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  3967. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  3968. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  3969. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  3970. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  3971. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  3972. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  3973. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  3974. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  3975. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  3976. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  3977. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  3978. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  3979. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  3980. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  3981. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  3982. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  3983. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  3984. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  3985. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  3986. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  3987. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  3988. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  3989. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  3990. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  3991. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  3992. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  3993. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  3994. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  3995. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  3996. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  3997. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  3998. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  3999. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  4000. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  4001. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  4002. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  4003. return result;
  4004. }
  4005. int ProcessShareMemory()
  4006. {
  4007. if(InitShareMemory() == FAIL)
  4008. {
  4009. DEBUG_ERROR("InitShareMemory NG\n");
  4010. if(ShmStatusCodeData!=NULL)
  4011. {
  4012. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  4013. }
  4014. sleep(5);
  4015. return FAIL;
  4016. }
  4017. return PASS;
  4018. }
  4019. //---------------------common routine---------------------------//
  4020. int isOFFline(void)
  4021. {
  4022. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  4023. {
  4024. if(TempMeterValueInterval >= 2 )
  4025. {
  4026. TempMeterValueInterval = 0;
  4027. return TRUE;
  4028. }
  4029. else
  4030. {
  4031. TempMeterValueInterval = TempMeterValueInterval+ 1;
  4032. return FALSE;
  4033. }
  4034. }
  4035. else
  4036. {
  4037. return FALSE;
  4038. }
  4039. }
  4040. void CheckSystemValue(void)
  4041. {
  4042. char filenmae[100]={0};
  4043. char str[100]={0};
  4044. int tempIndex = 0;
  4045. //===============================
  4046. // EVSE operation check
  4047. //===============================
  4048. //===============================
  4049. // Heartbeat check
  4050. //===============================
  4051. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  4052. {
  4053. clientTime.Heartbeat = time((time_t*)NULL);
  4054. if(server_sign == TRUE)
  4055. {
  4056. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  4057. }
  4058. else
  4059. {
  4060. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  4061. }
  4062. }
  4063. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  4064. {
  4065. //parameter for test
  4066. sendHeartbeatRequest(0);
  4067. //==============================================
  4068. // Reset Waiting Time
  4069. //==============================================
  4070. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  4071. }
  4072. //===============================
  4073. // CSU Trigger Reset Conf
  4074. //===============================
  4075. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->MsMsg.bits.ResetConf == ON))
  4076. {
  4077. sendResetConfirmation((char *)ShmOCPP20Data->Reset.guid);
  4078. }
  4079. //===============================
  4080. // CSU Trigger Authorize Request
  4081. //===============================
  4082. if(isWebsocketSendable &&
  4083. (server_sign == TRUE) &&
  4084. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4085. (authorizeRetryTimes < 3))
  4086. {
  4087. sendAuthorizeRequest(0);
  4088. authorizeRetryTimes = authorizeRetryTimes + 1;
  4089. if(authorizeRetryTimes < 3)
  4090. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4091. }
  4092. else if((server_sign == TRUE) &&
  4093. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4094. (authorizeRetryTimes >= 3))
  4095. {
  4096. authorizeRetryTimes = 0;
  4097. ShmOCPP20Data->OcppConnStatus = 0; // ocpp off-line
  4098. server_sign = FALSE;
  4099. }
  4100. else if((server_sign == FALSE) &&
  4101. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  4102. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  4103. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  4104. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  4105. {
  4106. sendAuthorizeRequest(0);
  4107. }
  4108. //===============================
  4109. // Each connector operation check
  4110. //===============================
  4111. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  4112. {
  4113. //===============================
  4114. // CSU Trigger Smart Charging Profilw
  4115. //===============================
  4116. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4117. {
  4118. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index]);
  4119. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4120. }
  4121. //==============================================
  4122. // Charger start transaction
  4123. //==============================================
  4124. /*
  4125. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  4126. {
  4127. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4128. sendStartTransactionRequest(gun_index);
  4129. clientTime.StartTransaction = time((time_t*)NULL);
  4130. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4131. }*/
  4132. //==============================================
  4133. // Charger stop transaction
  4134. //==============================================
  4135. /*
  4136. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  4137. {
  4138. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  4139. sendStopTransactionRequest(gun_index);
  4140. clientTime.StopTransaction = time((time_t*)NULL);
  4141. }*/
  4142. //==============================================
  4143. // Charger status notification & Transaction event report
  4144. //==============================================
  4145. //--- Check Mode Change ---//
  4146. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4147. if(gunType[gun_index] == 'J')
  4148. {
  4149. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4150. {
  4151. tempIndex = ((gun_index==2) ? 1: 0);
  4152. }
  4153. else
  4154. {
  4155. tempIndex = gun_index;
  4156. }
  4157. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4158. {
  4159. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4160. {
  4161. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4162. {
  4163. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4164. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4165. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4166. if(SystemInitial == 0)
  4167. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4168. }
  4169. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4170. {
  4171. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4172. if((access(filenmae,F_OK))!=-1)
  4173. {
  4174. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4175. sprintf(str,"rm -f %s",filenmae);
  4176. system(str);
  4177. }
  4178. }
  4179. #if 1 // for TempStopTransaction
  4180. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4181. {
  4182. checkTempStopTransaction(gun_index);
  4183. }
  4184. #endif
  4185. }
  4186. }
  4187. }
  4188. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4189. {
  4190. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4191. {
  4192. tempIndex = ((gun_index==2) ? 1: 0);
  4193. }
  4194. else
  4195. {
  4196. tempIndex = gun_index;
  4197. }
  4198. for (int index = 0; index < CCS_QUANTITY; index++)
  4199. {
  4200. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4201. {
  4202. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != CcsPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn != CcsPreviousConnectorPlugIn[index]) )//if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != CcsPreviousSystemStatus[index]/*PRE_SYS_MODE[gun_index]*/ )
  4203. {
  4204. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4205. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4206. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4207. if(SystemInitial == 0)
  4208. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4209. }
  4210. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4211. {
  4212. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4213. if((access(filenmae,F_OK))!=-1)
  4214. {
  4215. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4216. sprintf(str,"rm -f %s",filenmae);
  4217. system(str);
  4218. }
  4219. }
  4220. #if 1 // for TempStopTransaction
  4221. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4222. {
  4223. checkTempStopTransaction(gun_index);
  4224. }
  4225. #endif
  4226. }
  4227. }
  4228. }
  4229. else if(gunType[gun_index] == 'G')
  4230. {
  4231. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4232. {
  4233. tempIndex = ((gun_index==2) ? 1: 0);
  4234. }
  4235. else
  4236. {
  4237. tempIndex = gun_index;
  4238. }
  4239. for (int index = 0; index < GB_QUANTITY; index++)
  4240. {
  4241. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4242. {
  4243. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4244. {
  4245. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4246. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4247. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4248. if(SystemInitial == 0)
  4249. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4250. }
  4251. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4252. {
  4253. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4254. if((access(filenmae,F_OK))!=-1)
  4255. {
  4256. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4257. sprintf(str,"rm -f %s",filenmae);
  4258. system(str);
  4259. }
  4260. }
  4261. #if 1 // for TempStopTransaction
  4262. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4263. {
  4264. checkTempStopTransaction(gun_index);
  4265. }
  4266. #endif
  4267. }
  4268. }
  4269. }
  4270. else if(gunType[gun_index] == 'O')
  4271. {
  4272. tempIndex = gun_index;
  4273. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4274. {
  4275. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4276. {
  4277. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4278. {
  4279. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4280. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4281. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4282. if(SystemInitial == 0)
  4283. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4284. }
  4285. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4286. {
  4287. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4288. if((access(filenmae,F_OK))!=-1)
  4289. {
  4290. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4291. sprintf(str,"rm -f %s",filenmae);
  4292. system(str);
  4293. }
  4294. }
  4295. #if 1 // for TempStopTransaction
  4296. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4297. {
  4298. checkTempStopTransaction(gun_index);
  4299. }
  4300. #endif
  4301. }
  4302. }
  4303. }
  4304. else
  4305. {
  4306. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4307. {
  4308. tempIndex = 2;
  4309. }
  4310. else
  4311. {
  4312. tempIndex = gun_index;
  4313. }
  4314. for (int index = 0; index < AC_QUANTITY; index++)
  4315. {
  4316. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4317. {
  4318. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4319. {
  4320. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4321. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4322. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4323. if(SystemInitial == 0)
  4324. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4325. }
  4326. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4327. {
  4328. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4329. if((access(filenmae,F_OK))!=-1)
  4330. {
  4331. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4332. sprintf(str,"rm -f %s",filenmae);
  4333. system(str);
  4334. }
  4335. }
  4336. #if 1 // for TempStopTransaction
  4337. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4338. {
  4339. checkTempStopTransaction(gun_index);
  4340. }
  4341. #endif
  4342. }
  4343. }// END
  4344. }
  4345. if(isWebsocketSendable &&
  4346. (cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) &&
  4347. ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 10) )
  4348. {
  4349. if(SystemInitial > 0)
  4350. SystemInitial -= 1;
  4351. sendStatusNotificationRequest(gun_index);
  4352. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4353. }
  4354. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  4355. {
  4356. sendTransactionEventRequest(gun_index);
  4357. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  4358. }
  4359. //==============================================
  4360. // Meter report
  4361. //==============================================
  4362. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  4363. {
  4364. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4365. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  4366. }
  4367. // ClockAlign MeterValue
  4368. 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))
  4369. {
  4370. //check Transaction active
  4371. if(gunType[gun_index] == 'J')
  4372. {
  4373. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4374. {
  4375. tempIndex = ((gun_index==2) ? 1: 0);
  4376. }
  4377. else
  4378. {
  4379. tempIndex = gun_index;
  4380. }
  4381. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4382. {
  4383. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4384. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4385. {
  4386. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4387. {
  4388. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4389. }
  4390. }
  4391. }// End for CHAdeMO
  4392. }
  4393. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4394. {
  4395. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4396. {
  4397. tempIndex = ((gun_index==2) ? 1: 0);
  4398. }
  4399. else
  4400. {
  4401. tempIndex = gun_index;
  4402. }
  4403. for (int index = 0; index < CCS_QUANTITY; index++)
  4404. {
  4405. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4406. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4407. {
  4408. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4409. {
  4410. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4411. }
  4412. }
  4413. } // End for CCS
  4414. }
  4415. else if(gunType[gun_index] == 'G')
  4416. {
  4417. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4418. {
  4419. tempIndex = ((gun_index==2) ? 1: 0);
  4420. }
  4421. else
  4422. {
  4423. tempIndex = gun_index;
  4424. }
  4425. for (int index = 0; index < GB_QUANTITY; index++)
  4426. {
  4427. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4428. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4429. {
  4430. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4431. {
  4432. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4433. }
  4434. }
  4435. }// End for GB
  4436. }
  4437. else if(gunType[gun_index] == 'O')
  4438. {
  4439. tempIndex = gun_index;
  4440. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4441. {
  4442. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4443. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4444. {
  4445. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_CHARGING)
  4446. {
  4447. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4448. }
  4449. }
  4450. }
  4451. }
  4452. else
  4453. {
  4454. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4455. {
  4456. tempIndex = 2;
  4457. }
  4458. else
  4459. {
  4460. tempIndex = gun_index;
  4461. }
  4462. for (int index = 0; index < AC_QUANTITY; index++)
  4463. {
  4464. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4465. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4466. {
  4467. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4468. {
  4469. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4470. }
  4471. }
  4472. }//End for AC
  4473. }
  4474. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  4475. {
  4476. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  4477. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  4478. }
  4479. }
  4480. // Sample period MeterValue
  4481. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)))
  4482. {
  4483. //check Transaction active
  4484. if(gunType[gun_index] == 'J')
  4485. {
  4486. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4487. {
  4488. tempIndex = ((gun_index==2) ? 1: 0);
  4489. }
  4490. else
  4491. {
  4492. tempIndex = gun_index;
  4493. }
  4494. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4495. {
  4496. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4497. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4498. {
  4499. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4500. {
  4501. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4502. }
  4503. }
  4504. }// End for CHAdeMO
  4505. }
  4506. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4507. {
  4508. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4509. {
  4510. tempIndex = ((gun_index==2) ? 1: 0);
  4511. }
  4512. else
  4513. {
  4514. tempIndex = gun_index;
  4515. }
  4516. for (int index = 0; index < CCS_QUANTITY; index++)
  4517. {
  4518. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4519. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4520. {
  4521. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4522. {
  4523. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4524. }
  4525. }
  4526. } // End for CCS
  4527. }
  4528. else if(gunType[gun_index] == 'G')
  4529. {
  4530. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4531. {
  4532. tempIndex = ((gun_index==2) ? 1: 0);
  4533. }
  4534. else
  4535. {
  4536. tempIndex = gun_index;
  4537. }
  4538. for (int index = 0; index < GB_QUANTITY; index++)
  4539. {
  4540. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4541. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4542. {
  4543. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4544. {
  4545. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4546. }
  4547. }
  4548. }// End for GB
  4549. }
  4550. else if(gunType[gun_index] == 'O')
  4551. {
  4552. tempIndex = gun_index;
  4553. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4554. {
  4555. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4556. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4557. {
  4558. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  4559. {
  4560. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4561. }
  4562. }
  4563. }
  4564. }
  4565. else
  4566. {
  4567. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4568. {
  4569. tempIndex = 2;
  4570. }
  4571. else
  4572. {
  4573. tempIndex = gun_index;
  4574. }
  4575. for (int index = 0; index < AC_QUANTITY; index++)
  4576. {
  4577. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4578. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4579. {
  4580. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4581. {
  4582. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4583. }
  4584. }
  4585. }//End for AC
  4586. }
  4587. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  4588. {
  4589. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  4590. storeTempStopTransaction(gun_index);
  4591. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  4592. }
  4593. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4594. }
  4595. //==============================================
  4596. // Check Connector reserved
  4597. //==============================================
  4598. //===============================
  4599. // Check if Reserve is expired
  4600. //===============================
  4601. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  4602. {
  4603. double diff_t;
  4604. struct tm tp;
  4605. // current time
  4606. time_t t = time(NULL);
  4607. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  4608. tp.tm_isdst = -1;
  4609. time_t utc = mktime(&tp);
  4610. diff_t = difftime(utc, t);
  4611. if(diff_t <= 0)
  4612. {
  4613. DEBUG_INFO("reserve expired.\n");
  4614. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  4615. }
  4616. }//END OF Check if Reserve is expired
  4617. //==========================================
  4618. // csu trigger FirmwareStatusNotificationReq
  4619. //==========================================
  4620. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  4621. {
  4622. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  4623. }
  4624. //==========================================
  4625. // csu trigger CancelReservationConf
  4626. //==========================================
  4627. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  4628. {
  4629. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  4630. }
  4631. //==========================================
  4632. // csu trigger ChangeAvailabilityConf
  4633. //==========================================
  4634. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  4635. {
  4636. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  4637. }
  4638. //==========================================
  4639. // csu trigger UnlockConnectorConf
  4640. //==========================================
  4641. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  4642. {
  4643. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  4644. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  4645. }
  4646. //==========================================
  4647. // csu trigger ReserveNowConf
  4648. //==========================================
  4649. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  4650. {
  4651. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  4652. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  4653. }
  4654. //==========================================
  4655. // csu trigger DataTransferReq
  4656. //==========================================
  4657. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4658. {
  4659. sendDataTransferRequest(gun_index);
  4660. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  4661. }
  4662. }
  4663. }
  4664. //==========================================
  4665. // send request routine
  4666. //==========================================
  4667. int sendAuthorizeRequest(int gun_index)
  4668. {
  4669. mtrace();
  4670. int result = FAIL;
  4671. char message[4096]={0};
  4672. char guid[37];
  4673. char tempdata[128]={0};
  4674. json_object *Authorize = json_object_new_object();
  4675. json_object *idToken = json_object_new_object();
  4676. DEBUG_INFO("sendAuthorizeRequest...\n");
  4677. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  4678. //Local Authorize
  4679. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) &&(ShmOCPP20Data->OcppConnStatus == 0))
  4680. {
  4681. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  4682. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4683. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  4684. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  4685. result = PASS;
  4686. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4687. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4688. authorizeRetryTimes = 0;
  4689. return result;
  4690. }
  4691. 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))||
  4692. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  4693. {
  4694. // Query idtag from cache
  4695. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  4696. // Query idtag from list
  4697. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4698. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  4699. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4700. {
  4701. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  4702. {
  4703. DEBUG_INFO("offline Local Authorization Fail !!!!, Card %s is blank!!!!\n", idTagQuery.idToken.idToken);
  4704. }
  4705. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  4706. {
  4707. DEBUG_INFO("offline Local Authorization Fail !!!!, Card %s is not Accepted!!!!\n", idTagQuery.idToken.idToken);
  4708. }
  4709. DEBUG_INFO("offline Local Authorization Fail !!!!\n");
  4710. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4711. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4712. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  4713. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4714. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4715. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4716. authorizeRetryTimes = 0;
  4717. return result;
  4718. }
  4719. else
  4720. {
  4721. DEBUG_INFO("offline Local Authorization get result !!!!\n");
  4722. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  4723. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4724. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  4725. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  4726. else
  4727. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  4728. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4729. result = PASS;
  4730. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4731. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4732. authorizeRetryTimes = 0;
  4733. return result;
  4734. }
  4735. }
  4736. //initialize struct Authorize
  4737. memset(&(ShmOCPP20Data->Authorize), 0 , sizeof(struct StructAuthorize));
  4738. //get data from shared memory
  4739. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4740. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  4741. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  4742. json_object_object_add(Authorize, "idToken", idToken);
  4743. random_uuid(guid);
  4744. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  4745. json_object_put(Authorize);
  4746. LWS_Send(message);
  4747. sprintf(tempdata, "Authorize,%d", gun_index);
  4748. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4749. {
  4750. result = PASS;
  4751. }
  4752. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4753. return result;
  4754. }
  4755. int sendBootNotificationRequest()
  4756. {
  4757. mtrace();
  4758. int result = FAIL;
  4759. char message[4096]={0};
  4760. char guid[37]={0};
  4761. char tempdata[128]={0};
  4762. json_object *BootNotification = json_object_new_object();
  4763. json_object *chargingStation = json_object_new_object();
  4764. json_object *modem = json_object_new_object();
  4765. // Fill BootNotification fields
  4766. DB_getBooType();
  4767. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  4768. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  4769. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  4770. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  4771. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  4772. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  4773. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  4774. {
  4775. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  4776. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  4777. json_object_object_add(chargingStation, "modem", modem);
  4778. }
  4779. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  4780. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  4781. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  4782. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  4783. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  4784. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  4785. random_uuid(guid);
  4786. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  4787. json_object_put(BootNotification);
  4788. LWS_Send(message);
  4789. sprintf(tempdata, "BootNotification,0");
  4790. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4791. {
  4792. result = PASS;
  4793. }
  4794. return result;
  4795. }
  4796. int sendClearedChargingLimitRequest(int gun_index)
  4797. {
  4798. mtrace();
  4799. int result = FAIL;
  4800. char message[4096]={0};
  4801. char guid[37]={0};
  4802. char tempdata[128]={0};
  4803. json_object *ClearedChargingLimit = json_object_new_object();
  4804. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  4805. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  4806. random_uuid(guid);
  4807. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  4808. json_object_put(ClearedChargingLimit);
  4809. LWS_Send(message);
  4810. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  4811. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4812. {
  4813. result = PASS;
  4814. }
  4815. return result;
  4816. }
  4817. int sendDataTransferRequest(int gun_index)
  4818. {
  4819. mtrace();
  4820. char message[1000]={0};
  4821. char guid[37]={0};
  4822. char tempdata[65]={0};
  4823. int result = FAIL;
  4824. random_uuid(guid);
  4825. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  4826. MESSAGE_TYPE_CALL,
  4827. guid,
  4828. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  4829. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  4830. ShmOCPP20Data->DataTransfer[gun_index].data);
  4831. LWS_Send(message);
  4832. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  4833. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4834. {
  4835. result = PASS;
  4836. }
  4837. return result;
  4838. }
  4839. int sendFirmwareStatusNotificationRequest(char *status)
  4840. {
  4841. mtrace();
  4842. int result = FAIL;
  4843. char message[110]={0};
  4844. char guid[37]={0};
  4845. char tempdata[65]={0};
  4846. json_object *FirmwareStatusNotification = json_object_new_object();
  4847. DEBUG_INFO("sendFirmwareStatusNotificationRequest \n");
  4848. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  4849. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  4850. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  4851. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  4852. random_uuid(guid);
  4853. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  4854. json_object_put(FirmwareStatusNotification);
  4855. LWS_SendNow(message);
  4856. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  4857. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4858. {
  4859. result = PASS;
  4860. }
  4861. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  4862. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  4863. //record status
  4864. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  4865. {
  4866. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  4867. }
  4868. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  4869. {
  4870. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  4871. }
  4872. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  4873. {
  4874. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  4875. }
  4876. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  4877. {
  4878. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  4879. }
  4880. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  4881. {
  4882. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  4883. }
  4884. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  4885. {
  4886. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  4887. }
  4888. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  4889. {
  4890. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  4891. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  4892. }
  4893. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  4894. {
  4895. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  4896. }
  4897. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  4898. {
  4899. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  4900. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  4901. }
  4902. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  4903. {
  4904. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  4905. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  4906. }
  4907. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  4908. {
  4909. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  4910. }
  4911. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  4912. {
  4913. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  4914. }
  4915. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  4916. {
  4917. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  4918. }
  4919. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  4920. {
  4921. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  4922. }
  4923. return result;
  4924. }
  4925. int sendGet15118EVCertificateRequest()
  4926. {
  4927. mtrace();
  4928. int result = FAIL;
  4929. char message[4096]={0};
  4930. char guid[37]={0};
  4931. char tempdata[128]={0};
  4932. json_object *Get15118EVCertificate = json_object_new_object();
  4933. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  4934. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  4935. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  4936. random_uuid(guid);
  4937. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  4938. json_object_put(Get15118EVCertificate);
  4939. LWS_Send(message);
  4940. sprintf(tempdata, "Get15118EVCertificate,0");
  4941. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4942. {
  4943. result = PASS;
  4944. }
  4945. return result;
  4946. }
  4947. int sendGetCertificateStatusRequest()
  4948. {
  4949. mtrace();
  4950. int result = FAIL;
  4951. char message[4096]={0};
  4952. char guid[37]={0};
  4953. char tempdata[128]={0};
  4954. json_object *GetCertificateStatus = json_object_new_object();
  4955. json_object *ocspRequestData = json_object_new_object();
  4956. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  4957. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  4958. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  4959. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  4960. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  4961. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  4962. random_uuid(guid);
  4963. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  4964. json_object_put(GetCertificateStatus);
  4965. LWS_Send(message);
  4966. sprintf(tempdata, "GetCertificateStatus,0");
  4967. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4968. {
  4969. result = PASS;
  4970. }
  4971. return result;
  4972. }
  4973. int sendHeartbeatRequest()
  4974. {
  4975. mtrace();
  4976. int result = FAIL;
  4977. char message[40096]={0};
  4978. char guid[37]={0};
  4979. char tempdata[128]={0};
  4980. random_uuid(guid);
  4981. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  4982. , MESSAGE_TYPE_CALL
  4983. , guid );
  4984. LWS_Send(message);
  4985. sprintf(tempdata, "Heartbeat,%d", 0);
  4986. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4987. {
  4988. result = PASS;
  4989. }
  4990. return result;
  4991. }
  4992. int sendLogStatusNotificationRequest(char *status)
  4993. {
  4994. mtrace();
  4995. int result = FAIL;
  4996. char message[4096]={0};
  4997. char guid[37]={0};
  4998. char tempdata[128]={0};
  4999. json_object *LogStatusNotification = json_object_new_object();
  5000. DEBUG_INFO("sendLogStatusNotificationRequest \n");
  5001. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  5002. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  5003. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  5004. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  5005. random_uuid(guid);
  5006. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  5007. json_object_put(LogStatusNotification);
  5008. LWS_SendNow(message);
  5009. sprintf(tempdata, "LogStatusNotification,%d", 0);
  5010. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5011. {
  5012. result = PASS;
  5013. }
  5014. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  5015. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  5016. //record status
  5017. if(strcmp(status,"BadMessage")==0)
  5018. {
  5019. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  5020. }
  5021. else if(strcmp(status,"Idle")==0)
  5022. {
  5023. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  5024. }
  5025. else if(strcmp(status,"NotSupportedOperation")==0)
  5026. {
  5027. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  5028. }
  5029. else if(strcmp(status,"PermissionDenied")==0)
  5030. {
  5031. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  5032. }
  5033. else if(strcmp(status,"Uploaded")==0)
  5034. {
  5035. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  5036. }
  5037. else if(strcmp(status,"UploadFailure")==0)
  5038. {
  5039. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  5040. }
  5041. else if(strcmp(status,"Uploading")==0)
  5042. {
  5043. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  5044. }
  5045. return result;
  5046. }
  5047. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  5048. {
  5049. mtrace();
  5050. int result = FAIL;
  5051. char guid[37]={0};
  5052. char tempdata[65]={0};
  5053. int tempIndex = 0;
  5054. json_object *MeterValueReq = json_object_new_object();
  5055. json_object *meterValues = json_object_new_array();
  5056. json_object *meterValue = json_object_new_object();
  5057. json_object *sampledValues = json_object_new_array();
  5058. json_object *sampledValue = json_object_new_object();
  5059. json_object *unitOfMeasure = json_object_new_object();
  5060. DEBUG_INFO("sendMeterValuesRequest ...\n");
  5061. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  5062. //set value
  5063. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  5064. //UTC Date time
  5065. struct timeval tmnow;
  5066. struct tm *tm;
  5067. char buf[28];//, usec_buf[6];
  5068. gettimeofday(&tmnow, NULL);
  5069. time_t t;
  5070. t = time(NULL);
  5071. /*UTC time and date*/
  5072. tm = gmtime(&t);
  5073. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  5074. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  5075. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  5076. //idx_sample=0;
  5077. //********************************(1)Current.Import L1************************************************/
  5078. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5079. if(gunType[gun_index] == 'J')
  5080. {
  5081. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5082. {
  5083. tempIndex = ((gun_index==2) ? 1: 0);
  5084. }
  5085. else
  5086. {
  5087. tempIndex = gun_index;
  5088. }
  5089. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5090. {
  5091. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5092. {
  5093. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  5094. }
  5095. }
  5096. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5097. }
  5098. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5099. {
  5100. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5101. {
  5102. tempIndex = ((gun_index==2) ? 1: 0);
  5103. }
  5104. else
  5105. {
  5106. tempIndex = gun_index;
  5107. }
  5108. for (int index = 0; index < CCS_QUANTITY; index++)
  5109. {
  5110. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5111. {
  5112. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  5113. }
  5114. }
  5115. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5116. }
  5117. else if(gunType[gun_index] == 'G')
  5118. {
  5119. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5120. {
  5121. tempIndex = ((gun_index==2) ? 1: 0);
  5122. }
  5123. else
  5124. {
  5125. tempIndex = gun_index;
  5126. }
  5127. for (int index = 0; index < GB_QUANTITY; index++)
  5128. {
  5129. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5130. {
  5131. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  5132. }
  5133. }
  5134. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5135. }
  5136. else if(gunType[gun_index] == 'O')
  5137. {
  5138. tempIndex = gun_index;
  5139. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5140. {
  5141. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5142. {
  5143. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
  5144. }
  5145. }
  5146. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5147. }
  5148. else
  5149. {
  5150. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5151. {
  5152. tempIndex = 2;
  5153. }
  5154. else
  5155. {
  5156. tempIndex = gun_index;
  5157. }
  5158. for (int index = 0; index < AC_QUANTITY; index++)
  5159. {
  5160. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5161. {
  5162. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  5163. }
  5164. }
  5165. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5166. }
  5167. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  5168. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5169. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5170. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  5171. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  5172. //idx_sample=1;
  5173. //********************************(2)Energy.Active.Import.Register ************************************************/
  5174. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5175. if(gunType[gun_index] == 'J')
  5176. {
  5177. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5178. {
  5179. tempIndex = ((gun_index==2) ? 1: 0);
  5180. }
  5181. else
  5182. {
  5183. tempIndex = gun_index;
  5184. }
  5185. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5186. {
  5187. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5188. {
  5189. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5190. }
  5191. }
  5192. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5193. }
  5194. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5195. {
  5196. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5197. {
  5198. tempIndex = ((gun_index==2) ? 1: 0);
  5199. }
  5200. else
  5201. {
  5202. tempIndex = gun_index;
  5203. }
  5204. for (int index = 0; index < CCS_QUANTITY; index++)
  5205. {
  5206. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5207. {
  5208. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5209. }
  5210. }
  5211. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5212. }
  5213. else if(gunType[gun_index] == 'G')
  5214. {
  5215. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5216. {
  5217. tempIndex = ((gun_index==2) ? 1: 0);
  5218. }
  5219. else
  5220. {
  5221. tempIndex = gun_index;
  5222. }
  5223. for (int index = 0; index < GB_QUANTITY; index++)
  5224. {
  5225. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5226. {
  5227. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5228. }
  5229. }
  5230. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5231. }
  5232. else if(gunType[gun_index] == 'O')
  5233. {
  5234. tempIndex = gun_index;
  5235. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5236. {
  5237. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5238. {
  5239. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5240. }
  5241. }
  5242. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5243. }
  5244. else
  5245. {
  5246. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5247. {
  5248. tempIndex = 2;
  5249. }
  5250. else
  5251. {
  5252. tempIndex = gun_index;
  5253. }
  5254. for (int index = 0; index < AC_QUANTITY; index++)
  5255. {
  5256. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5257. {
  5258. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5259. }
  5260. }
  5261. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5262. }
  5263. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  5264. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  5265. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5266. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  5267. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5268. //idx_sample=2;
  5269. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  5270. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5271. if(gunType[gun_index] == 'J')
  5272. {
  5273. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5274. {
  5275. tempIndex = ((gun_index==2) ? 1: 0);
  5276. }
  5277. else
  5278. {
  5279. tempIndex = gun_index;
  5280. }
  5281. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5282. {
  5283. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5284. {
  5285. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  5286. }
  5287. } // END OF FOR CHAdeMO_QUANTITY
  5288. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5289. }
  5290. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5291. {
  5292. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5293. {
  5294. tempIndex = ((gun_index==2) ? 1: 0);
  5295. }
  5296. else
  5297. {
  5298. tempIndex = gun_index;
  5299. }
  5300. for (int index = 0; index < CCS_QUANTITY; index++)
  5301. {
  5302. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5303. {
  5304. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  5305. }
  5306. } // END OF CCS_QUANTITY
  5307. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5308. }
  5309. else if(gunType[gun_index] == 'G')
  5310. {
  5311. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5312. {
  5313. tempIndex = ((gun_index==2) ? 1: 0);
  5314. }
  5315. else
  5316. {
  5317. tempIndex = gun_index;
  5318. }
  5319. for (int index = 0; index < GB_QUANTITY; index++)
  5320. {
  5321. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5322. {
  5323. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  5324. }
  5325. } // END OF GB_QUANTITY
  5326. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5327. }
  5328. else if(gunType[gun_index] == 'O')
  5329. {
  5330. tempIndex = gun_index;
  5331. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5332. {
  5333. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5334. {
  5335. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
  5336. }
  5337. }
  5338. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5339. }
  5340. else
  5341. {
  5342. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5343. {
  5344. tempIndex = 2;
  5345. }
  5346. else
  5347. {
  5348. tempIndex = gun_index;
  5349. }
  5350. for (int index = 0; index < AC_QUANTITY; index++)
  5351. {
  5352. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5353. {
  5354. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  5355. }
  5356. }
  5357. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5358. }
  5359. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  5360. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  5361. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5362. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  5363. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5364. //idx_sample=3;
  5365. //********************************(4)Power.Active.Import************************************************/
  5366. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5367. if(gunType[gun_index] == 'J')
  5368. {
  5369. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5370. {
  5371. tempIndex = ((gun_index==2) ? 1: 0);
  5372. }
  5373. else
  5374. {
  5375. tempIndex = gun_index;
  5376. }
  5377. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5378. {
  5379. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5380. {
  5381. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  5382. }
  5383. } // END OF FOR
  5384. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5385. }
  5386. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5387. {
  5388. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5389. {
  5390. tempIndex = ((gun_index==2) ? 1: 0);
  5391. }
  5392. else
  5393. {
  5394. tempIndex = gun_index;
  5395. }
  5396. for (int index = 0; index < CCS_QUANTITY; index++)
  5397. {
  5398. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5399. {
  5400. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  5401. }
  5402. }
  5403. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5404. }
  5405. else if(gunType[gun_index] == 'G')
  5406. {
  5407. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5408. {
  5409. tempIndex = ((gun_index==2) ? 1: 0);
  5410. }
  5411. else
  5412. {
  5413. tempIndex = gun_index;
  5414. }
  5415. for (int index = 0; index < GB_QUANTITY; index++)
  5416. {
  5417. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5418. {
  5419. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5420. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  5421. }
  5422. }
  5423. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5424. }
  5425. else if(gunType[gun_index] == 'O')
  5426. {
  5427. tempIndex = gun_index;
  5428. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5429. {
  5430. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5431. {
  5432. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5433. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
  5434. }
  5435. }
  5436. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5437. }
  5438. else
  5439. {
  5440. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5441. {
  5442. tempIndex = 2;
  5443. }
  5444. else
  5445. {
  5446. tempIndex = gun_index;
  5447. }
  5448. for (int index = 0; index < AC_QUANTITY; index++)
  5449. {
  5450. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5451. {
  5452. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  5453. }
  5454. }
  5455. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5456. }
  5457. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  5458. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  5459. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5460. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  5461. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  5462. //idx_sample=4;
  5463. //***********************************************(5)VOLTAGE L1******************************************************/
  5464. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5465. if(gunType[gun_index] == 'J')
  5466. {
  5467. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5468. {
  5469. tempIndex = ((gun_index==2) ? 1: 0);
  5470. }
  5471. else
  5472. {
  5473. tempIndex = gun_index;
  5474. }
  5475. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5476. {
  5477. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5478. {
  5479. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  5480. }
  5481. }
  5482. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5483. }
  5484. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5485. {
  5486. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5487. {
  5488. tempIndex = ((gun_index==2) ? 1: 0);
  5489. }
  5490. else
  5491. {
  5492. tempIndex = gun_index;
  5493. }
  5494. for (int index = 0; index < CCS_QUANTITY; index++)
  5495. {
  5496. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5497. {
  5498. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  5499. }
  5500. }
  5501. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5502. }
  5503. else if(gunType[gun_index] == 'G')
  5504. {
  5505. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5506. {
  5507. tempIndex = ((gun_index==2) ? 1: 0);
  5508. }
  5509. else
  5510. {
  5511. tempIndex = gun_index;
  5512. }
  5513. for (int index = 0; index < GB_QUANTITY; index++)
  5514. {
  5515. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5516. {
  5517. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  5518. }
  5519. }
  5520. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5521. }
  5522. else if(gunType[gun_index] == 'O')
  5523. {
  5524. tempIndex = gun_index;
  5525. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5526. {
  5527. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5528. {
  5529. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
  5530. }
  5531. }
  5532. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5533. }
  5534. else
  5535. {
  5536. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5537. {
  5538. tempIndex = 2;
  5539. }
  5540. else
  5541. {
  5542. tempIndex = gun_index;
  5543. }
  5544. for (int index = 0; index < AC_QUANTITY; index++)
  5545. {
  5546. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5547. {
  5548. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  5549. }
  5550. }
  5551. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5552. }
  5553. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  5554. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5555. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5556. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  5557. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  5558. //***********************************************(6)SOC******************************************************/
  5559. if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G'))
  5560. {
  5561. //idx_sample=5;
  5562. //sampledValue = NULL;
  5563. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5564. {
  5565. tempIndex = ((gun_index==2) ? 1: 0);
  5566. }
  5567. else
  5568. {
  5569. tempIndex = gun_index;
  5570. }
  5571. if(gunType[gun_index] == 'J')
  5572. {
  5573. //tempIndex = ((gun_index==2) ? 1: 0);
  5574. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5575. {
  5576. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5577. {
  5578. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  5579. }
  5580. }
  5581. }
  5582. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5583. {
  5584. //tempIndex = ((gun_index==2) ? 1: 0);
  5585. for (int index = 0; index < CCS_QUANTITY; index++)
  5586. {
  5587. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5588. {
  5589. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  5590. }
  5591. }
  5592. }
  5593. else if(gunType[gun_index] == 'G')
  5594. {
  5595. //tempIndex = ((gun_index==2) ? 1: 0);
  5596. for (int index = 0; index < GB_QUANTITY; index++)
  5597. {
  5598. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5599. {
  5600. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  5601. }
  5602. }
  5603. }
  5604. else if(gunType[gun_index] == 'O')
  5605. {
  5606. //tempIndex = ((gun_index==2) ? 1: 0);
  5607. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5608. {
  5609. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5610. {
  5611. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  5612. }
  5613. }
  5614. }
  5615. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  5616. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  5617. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5618. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  5619. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  5620. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  5621. }
  5622. //********************************(7)Current.Import L2************************************************/
  5623. // Only for AC 3 phase
  5624. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5625. {
  5626. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5627. {
  5628. tempIndex = 2;
  5629. }
  5630. else
  5631. {
  5632. tempIndex = gun_index;
  5633. }
  5634. for (int index = 0; index < AC_QUANTITY; index++)
  5635. {
  5636. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5637. {
  5638. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  5639. }
  5640. }
  5641. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5642. }
  5643. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  5644. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5645. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5646. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  5647. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  5648. //********************************(8)Current.Import L3************************************************/
  5649. // Only for AC 3 phase
  5650. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5651. {
  5652. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5653. {
  5654. tempIndex = 2;
  5655. }
  5656. else
  5657. {
  5658. tempIndex = gun_index;
  5659. }
  5660. for (int index = 0; index < AC_QUANTITY; index++)
  5661. {
  5662. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5663. {
  5664. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  5665. }
  5666. }
  5667. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5668. }
  5669. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  5670. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5671. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5672. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  5673. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  5674. //***********************************************(9)VOLTAGE L2******************************************************/
  5675. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5676. {
  5677. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5678. {
  5679. tempIndex = 2;
  5680. }
  5681. else
  5682. {
  5683. tempIndex = gun_index;
  5684. }
  5685. for (int index = 0; index < AC_QUANTITY; index++)
  5686. {
  5687. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5688. {
  5689. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  5690. }
  5691. }
  5692. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5693. }
  5694. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  5695. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5696. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5697. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  5698. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  5699. //***********************************************(10)VOLTAGE L3******************************************************/
  5700. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5701. {
  5702. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5703. {
  5704. tempIndex = 2;
  5705. }
  5706. else
  5707. {
  5708. tempIndex = gun_index;
  5709. }
  5710. for (int index = 0; index < AC_QUANTITY; index++)
  5711. {
  5712. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5713. {
  5714. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  5715. }
  5716. }
  5717. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5718. }
  5719. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  5720. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5721. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5722. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  5723. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  5724. // Message create ====================================================================================================
  5725. random_uuid(guid);
  5726. uint8_t idxMeter = 0;
  5727. while(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp) > 0)
  5728. {
  5729. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  5730. {
  5731. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  5732. {
  5733. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  5734. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  5735. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  5736. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  5737. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  5738. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  5739. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  5740. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  5741. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  5742. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  5743. {
  5744. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  5745. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  5746. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  5747. }
  5748. json_object_array_add(sampledValues, sampledValue);
  5749. }
  5750. }
  5751. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  5752. json_object_object_add(meterValue, "sampledValue", sampledValues);
  5753. json_object_array_add(meterValues, meterValue);
  5754. idxMeter++;
  5755. }
  5756. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  5757. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  5758. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  5759. ,gun_index + 1
  5760. ,MESSAGE_TYPE_CALL
  5761. ,guid
  5762. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  5763. json_object_put(MeterValueReq);
  5764. // Put request guid to hash map
  5765. sprintf(tempdata, "MeterValues,%d", (gun_index));
  5766. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5767. {
  5768. result = PASS;
  5769. }
  5770. if((dataType != ReadingContextEnumType_Trigger) &&
  5771. (dataType != ReadingContextEnumType_Sample_Clock))
  5772. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  5773. else
  5774. {
  5775. if(FirstHeartBeat)
  5776. LWS_Send(queuedata +2);
  5777. }
  5778. return result;
  5779. }
  5780. int sendNotifyChargingLimitRequest(int gun_index)
  5781. {
  5782. mtrace();
  5783. int result = FAIL;
  5784. char message[4096]={0};
  5785. char guid[37]={0};
  5786. char tempdata[128]={0};
  5787. json_object *NotifyChargingLimit = json_object_new_object();
  5788. json_object *chargingLimit = json_object_new_object();
  5789. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  5790. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  5791. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  5792. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  5793. random_uuid(guid);
  5794. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  5795. json_object_put(NotifyChargingLimit);
  5796. LWS_Send(message);
  5797. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  5798. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5799. {
  5800. result = PASS;
  5801. }
  5802. return result;
  5803. }
  5804. int sendNotifyCustomerInformationRequest()
  5805. {
  5806. mtrace();
  5807. int result = FAIL;
  5808. char message[4096]={0};
  5809. char guid[37]={0};
  5810. char tempdata[128]={0};
  5811. json_object *NotifyCustomerInformation = json_object_new_object();
  5812. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  5813. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  5814. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  5815. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  5816. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  5817. random_uuid(guid);
  5818. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  5819. json_object_put(NotifyCustomerInformation);
  5820. LWS_Send(message);
  5821. sprintf(tempdata, "NotifyCustomerInformation,0");
  5822. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5823. {
  5824. result = PASS;
  5825. }
  5826. return result;
  5827. }
  5828. int sendNotifyDisplayMessagesRequest()
  5829. {
  5830. mtrace();
  5831. int result = FAIL;
  5832. char message[4096]={0};
  5833. char guid[37]={0};
  5834. char tempdata[128]={0};
  5835. json_object *NotifyDisplayMessages = json_object_new_object();
  5836. json_object *messageInfos = json_object_new_array();
  5837. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  5838. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  5839. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  5840. {
  5841. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  5842. {
  5843. json_object *messageInfo = json_object_new_object();
  5844. json_object *message = json_object_new_object();
  5845. json_object *display = json_object_new_object();
  5846. json_object *evse = json_object_new_object();
  5847. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  5848. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  5849. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  5850. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  5851. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  5852. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  5853. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  5854. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  5855. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  5856. json_object_object_add(messageInfo, "message", message);
  5857. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  5858. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  5859. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  5860. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  5861. json_object_object_add(display, "evse",evse);
  5862. json_object_object_add(messageInfo, "evse", display);
  5863. json_object_array_add(messageInfos, messageInfo);
  5864. }
  5865. }
  5866. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  5867. random_uuid(guid);
  5868. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  5869. json_object_put(NotifyDisplayMessages);
  5870. LWS_Send(message);
  5871. sprintf(tempdata, "NotifyDisplayMessages,0");
  5872. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5873. {
  5874. result = PASS;
  5875. }
  5876. return result;
  5877. }
  5878. int sendNotifyEVChargingNeedsRequest(int gun_index)
  5879. {
  5880. mtrace();
  5881. int result = FAIL;
  5882. char message[4096]={0};
  5883. char guid[37]={0};
  5884. char tempdata[128]={0};
  5885. json_object *NotifyEVChargingNeeds = json_object_new_object();
  5886. json_object *chargingNeeds = json_object_new_object();
  5887. json_object *acChargingParameters = json_object_new_object();
  5888. json_object *dcChargingParameters = json_object_new_object();
  5889. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  5890. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  5891. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  5892. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  5893. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  5894. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  5895. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  5896. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  5897. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  5898. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  5899. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  5900. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  5901. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  5902. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  5903. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  5904. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  5905. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  5906. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  5907. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  5908. random_uuid(guid);
  5909. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  5910. json_object_put(NotifyEVChargingNeeds);
  5911. LWS_Send(message);
  5912. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  5913. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5914. {
  5915. result = PASS;
  5916. }
  5917. return result;
  5918. }
  5919. int sendNotifyEVChargingScheduleRequest(int gun_index)
  5920. {
  5921. mtrace();
  5922. int result = FAIL;
  5923. char message[4096]={0};
  5924. char guid[37]={0};
  5925. char tempdata[128]={0};
  5926. json_object *NotifyEVChargingSchedule = json_object_new_object();
  5927. json_object *chargingSchedule = json_object_new_object();
  5928. json_object *periods = json_object_new_array();
  5929. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  5930. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  5931. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  5932. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  5933. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  5934. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  5935. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  5936. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  5937. {
  5938. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  5939. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  5940. {
  5941. json_object *Period = json_object_new_object();
  5942. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  5943. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  5944. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  5945. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  5946. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  5947. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  5948. json_object_array_add(periods, Period);
  5949. }
  5950. }
  5951. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  5952. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  5953. random_uuid(guid);
  5954. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  5955. json_object_put(NotifyEVChargingSchedule);
  5956. LWS_Send(message);
  5957. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  5958. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5959. {
  5960. result = PASS;
  5961. }
  5962. return result;
  5963. }
  5964. int sendNotifyEventRequest()
  5965. {
  5966. mtrace();
  5967. int result = FAIL;
  5968. char message[4096]={0};
  5969. char guid[37]={0};
  5970. char tempdata[128]={0};
  5971. json_object *NotifyEvent = json_object_new_object();
  5972. json_object *eventDatas = json_object_new_array();
  5973. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  5974. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  5975. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  5976. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  5977. {
  5978. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  5979. {
  5980. json_object *eventData = json_object_new_object();
  5981. json_object *component = json_object_new_object();
  5982. json_object *evse = json_object_new_object();
  5983. json_object *variable = json_object_new_object();
  5984. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  5985. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  5986. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  5987. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  5988. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  5989. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  5990. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  5991. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  5992. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  5993. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  5994. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  5995. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  5996. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  5997. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  5998. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  5999. json_object_object_add(component, "evse",evse);
  6000. json_object_object_add(eventData, "component", component);
  6001. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  6002. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  6003. json_object_object_add(eventData, "variable", variable);
  6004. json_object_array_add(eventDatas, eventData);
  6005. }
  6006. }
  6007. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  6008. random_uuid(guid);
  6009. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  6010. json_object_put(NotifyEvent);
  6011. LWS_Send(message);
  6012. sprintf(tempdata, "NotifyEvent,0");
  6013. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6014. {
  6015. result = PASS;
  6016. }
  6017. return result;
  6018. }
  6019. int sendNotifyMonitoringReportRequest()
  6020. {
  6021. mtrace();
  6022. int result = FAIL;
  6023. char message[4096]={0};
  6024. char guid[37]={0};
  6025. char tempdata[128]={0};
  6026. json_object *NotifyMonitoringReport = json_object_new_object();
  6027. json_object *monitors = json_object_new_array();
  6028. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  6029. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  6030. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  6031. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  6032. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  6033. {
  6034. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  6035. {
  6036. json_object *monitor = json_object_new_object();
  6037. json_object *component = json_object_new_object();
  6038. json_object *evse = json_object_new_object();
  6039. json_object *variable = json_object_new_object();
  6040. json_object *variableMonitorings = json_object_new_array();
  6041. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  6042. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  6043. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  6044. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  6045. json_object_object_add(component, "evse",evse);
  6046. json_object_object_add(monitor, "component", component);
  6047. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  6048. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  6049. json_object_object_add(monitor, "variable", variable);
  6050. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  6051. {
  6052. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  6053. {
  6054. json_object *variableMonitoring = json_object_new_object();
  6055. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  6056. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  6057. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  6058. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  6059. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  6060. json_object_array_add(variableMonitorings, variableMonitoring);
  6061. }
  6062. }
  6063. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  6064. json_object_array_add(monitors, monitor);
  6065. }
  6066. }
  6067. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  6068. random_uuid(guid);
  6069. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  6070. json_object_put(NotifyMonitoringReport);
  6071. LWS_Send(message);
  6072. sprintf(tempdata, "NotifyMonitoringReport,0");
  6073. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6074. {
  6075. result = PASS;
  6076. }
  6077. return result;
  6078. }
  6079. int sendNotifyReportRequest()
  6080. {
  6081. mtrace();
  6082. int result = FAIL;
  6083. char message[4096]={0};
  6084. char guid[37]={0};
  6085. char tempdata[128]={0};
  6086. json_object *NotifyReport = json_object_new_object();
  6087. json_object *reportDatas = json_object_new_array();
  6088. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  6089. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  6090. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  6091. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  6092. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  6093. {
  6094. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  6095. {
  6096. json_object *reportData = json_object_new_object();
  6097. json_object *component = json_object_new_object();
  6098. json_object *evse = json_object_new_object();
  6099. json_object *variable = json_object_new_object();
  6100. json_object *variableAttributes = json_object_new_array();
  6101. json_object *variableCharacteristics = json_object_new_object();
  6102. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  6103. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  6104. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  6105. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  6106. json_object_object_add(component, "evse",evse);
  6107. json_object_object_add(reportData, "component", component);
  6108. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  6109. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  6110. json_object_object_add(reportData, "variable",variable);
  6111. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  6112. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  6113. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  6114. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  6115. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  6116. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  6117. {
  6118. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  6119. {
  6120. json_object *variableAttribute = json_object_new_object();
  6121. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  6122. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  6123. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  6124. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  6125. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  6126. json_object_array_add(variableAttributes, variableAttribute);
  6127. }
  6128. }
  6129. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  6130. json_object_array_add(reportDatas, reportData);
  6131. }
  6132. }
  6133. json_object_object_add(NotifyReport, "reportData", reportDatas);
  6134. random_uuid(guid);
  6135. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  6136. json_object_put(NotifyReport);
  6137. LWS_Send(message);
  6138. sprintf(tempdata, "NotifyReport,0");
  6139. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6140. {
  6141. result = PASS;
  6142. }
  6143. return result;
  6144. }
  6145. int sendPublishFirmwareStatusNotificationRequest()
  6146. {
  6147. mtrace();
  6148. int result = FAIL;
  6149. char message[4096]={0};
  6150. char guid[37]={0};
  6151. char tempdata[128]={0};
  6152. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  6153. json_object *locations = json_object_new_array();
  6154. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  6155. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  6156. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  6157. {
  6158. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  6159. }
  6160. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  6161. random_uuid(guid);
  6162. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6163. json_object_put(PublishFirmwareStatusNotification);
  6164. LWS_Send(message);
  6165. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  6166. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6167. {
  6168. result = PASS;
  6169. }
  6170. return result;
  6171. }
  6172. int sendReportChargingProfilesRequest(int gun_index)
  6173. {
  6174. mtrace();
  6175. int result = FAIL;
  6176. char message[4096]={0};
  6177. char guid[37]={0};
  6178. char tempdata[128]={0};
  6179. json_object *ReportChargingProfiles = json_object_new_object();
  6180. json_object *chargingProfiles = json_object_new_array();
  6181. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  6182. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  6183. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  6184. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  6185. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  6186. {
  6187. json_object *chargingProfile = json_object_new_object();
  6188. json_object *chargingSchedules = json_object_new_array();
  6189. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  6190. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  6191. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  6192. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  6193. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  6194. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  6195. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  6196. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  6197. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  6198. {
  6199. json_object *chargingSchedule = json_object_new_object();
  6200. json_object *chargingSchedulePeriods = json_object_new_array();
  6201. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  6202. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  6203. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  6204. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  6205. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  6206. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  6207. {
  6208. json_object *chargingSchedulePeriod = json_object_new_object();
  6209. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  6210. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  6211. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  6212. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  6213. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  6214. }
  6215. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  6216. json_object_array_add(chargingSchedules, chargingSchedule);
  6217. }
  6218. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  6219. json_object_array_add(chargingProfiles, chargingProfile);
  6220. }
  6221. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  6222. random_uuid(guid);
  6223. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6224. json_object_put(ReportChargingProfiles);
  6225. LWS_Send(message);
  6226. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  6227. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6228. {
  6229. result = PASS;
  6230. }
  6231. return result;
  6232. }
  6233. int sendReservationStatusUpdateRequest(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 *ReservationStatusUpdate = json_object_new_object();
  6241. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  6242. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  6243. random_uuid(guid);
  6244. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  6245. json_object_put(ReservationStatusUpdate);
  6246. LWS_Send(message);
  6247. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  6248. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6249. {
  6250. result = PASS;
  6251. }
  6252. return result;
  6253. }
  6254. int sendSecurityEventNotificationRequest()
  6255. {
  6256. mtrace();
  6257. int result = FAIL;
  6258. char message[4096]={0};
  6259. char guid[37]={0};
  6260. char tempdata[128]={0};
  6261. json_object *SecurityEventNotification = json_object_new_object();
  6262. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  6263. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  6264. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techinfo));
  6265. random_uuid(guid);
  6266. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  6267. json_object_put(SecurityEventNotification);
  6268. LWS_Send(message);
  6269. sprintf(tempdata, "SecurityEventNotification,0");
  6270. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6271. {
  6272. result = PASS;
  6273. }
  6274. return result;
  6275. }
  6276. int sendSignCertificateRequest()
  6277. {
  6278. mtrace();
  6279. int result = FAIL;
  6280. char message[4096]={0};
  6281. char guid[37]={0};
  6282. char tempdata[128]={0};
  6283. json_object *SignCertificate = json_object_new_object();
  6284. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  6285. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  6286. random_uuid(guid);
  6287. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  6288. json_object_put(SignCertificate);
  6289. LWS_Send(message);
  6290. sprintf(tempdata, "SignCertificate,0");
  6291. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6292. {
  6293. result = PASS;
  6294. }
  6295. return result;
  6296. }
  6297. int sendStatusNotificationRequest(int gun_index)
  6298. {
  6299. mtrace();
  6300. int result = FAIL;
  6301. char message[600]={0};
  6302. char guid[37];
  6303. int currentStatus = 0;
  6304. struct timeval tmnow;
  6305. struct tm *tm;
  6306. char buf[28];//, usec_buf[6];
  6307. char tempdata[65]={0};
  6308. int tempIndex = 0;
  6309. gettimeofday(&tmnow, NULL);
  6310. time_t t;
  6311. t = time(NULL);
  6312. /*UTC time and date*/
  6313. tm = gmtime(&t);
  6314. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6315. #if 0 // remove temporally
  6316. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  6317. strcat(buf,".");
  6318. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  6319. strcat(buf,usec_buf);
  6320. #endif
  6321. printf("%s",buf);
  6322. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  6323. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  6324. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  6325. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  6326. /*
  6327. enum _SYSTEM_STATUS
  6328. {
  6329. S_BOOTING = 0,
  6330. S_IDLE, = 1
  6331. S_AUTHORIZING, =2
  6332. S_REASSIGN_CHECK, =3
  6333. S_REASSIGN, =4
  6334. S_PRECHARGE, =5
  6335. S_PREPARING_FOR_EV, =6
  6336. S_PREPARING_FOR_EVSE, =7
  6337. S_CHARGING, =8
  6338. S_TERMINATING, =9
  6339. S_COMPLETE, =10
  6340. S_ALARM, =11
  6341. S_FAULT =12
  6342. }
  6343. */
  6344. //check Transaction active
  6345. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6346. if(gunType[gun_index] == 'J')
  6347. {
  6348. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6349. {
  6350. tempIndex = ((gun_index==2) ? 1: 0);
  6351. }
  6352. else
  6353. {
  6354. tempIndex = gun_index;
  6355. }
  6356. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6357. {
  6358. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6359. {
  6360. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6361. {
  6362. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6363. {
  6364. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6365. }
  6366. else
  6367. {
  6368. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6369. }
  6370. }
  6371. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6372. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6373. ) //S_PRECHARGE
  6374. {
  6375. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6376. }
  6377. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6378. {
  6379. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6380. }
  6381. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6382. {
  6383. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6384. }
  6385. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6386. {
  6387. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6388. }
  6389. 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
  6390. {
  6391. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6392. }
  6393. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6394. {
  6395. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6396. }
  6397. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6398. {
  6399. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6400. }
  6401. } //end of the same index
  6402. }//end of for CHAdeMO_QUANTITY
  6403. }
  6404. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6405. {
  6406. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6407. {
  6408. tempIndex = ((gun_index==2) ? 1: 0);
  6409. }
  6410. else
  6411. {
  6412. tempIndex = gun_index;
  6413. }
  6414. for (int index = 0; index < CCS_QUANTITY; index++)
  6415. {
  6416. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6417. {
  6418. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6419. {
  6420. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6421. {
  6422. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6423. }
  6424. else
  6425. {
  6426. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6427. }
  6428. }
  6429. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6430. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6431. ) //S_PRECHARGE
  6432. {
  6433. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6434. }
  6435. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6436. {
  6437. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6438. }
  6439. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6440. {
  6441. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6442. }
  6443. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  6444. {
  6445. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6446. }
  6447. 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
  6448. {
  6449. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  6450. }
  6451. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6452. {
  6453. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6454. }
  6455. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6456. {
  6457. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6458. }
  6459. } //end of the same index
  6460. } // end of for CCS_QUANTITY
  6461. }
  6462. else if(gunType[gun_index] == 'G')
  6463. {
  6464. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6465. {
  6466. tempIndex = ((gun_index==2) ? 1: 0);
  6467. }
  6468. else
  6469. {
  6470. tempIndex = gun_index;
  6471. }
  6472. for (int index = 0; index < GB_QUANTITY; index++)
  6473. {
  6474. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6475. {
  6476. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6477. {
  6478. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6479. {
  6480. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6481. }
  6482. else
  6483. {
  6484. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6485. }
  6486. }
  6487. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6488. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6489. ) //S_PRECHARGE
  6490. {
  6491. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6492. }
  6493. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6494. {
  6495. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6496. }
  6497. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6498. {
  6499. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6500. }
  6501. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6502. {
  6503. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6504. }
  6505. 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
  6506. {
  6507. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6508. }
  6509. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6510. {
  6511. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6512. }
  6513. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6514. {
  6515. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6516. }
  6517. } //end of the same index
  6518. } // end of for GB_QUANTITY
  6519. }
  6520. else if(gunType[gun_index] == 'O')
  6521. {
  6522. tempIndex = gun_index;
  6523. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6524. {
  6525. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6526. {
  6527. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6528. {
  6529. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6530. {
  6531. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6532. }
  6533. else
  6534. {
  6535. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6536. }
  6537. }
  6538. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6539. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6540. ) //S_PRECHARGE
  6541. {
  6542. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6543. }
  6544. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6545. {
  6546. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6547. }
  6548. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6549. {
  6550. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6551. }
  6552. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6553. {
  6554. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6555. }
  6556. 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
  6557. {
  6558. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6559. }
  6560. 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
  6561. {
  6562. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6563. }
  6564. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6565. {
  6566. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6567. }
  6568. } //end of the same index
  6569. }
  6570. }
  6571. else
  6572. {
  6573. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6574. {
  6575. tempIndex = 2;
  6576. }
  6577. else
  6578. {
  6579. tempIndex = gun_index;
  6580. }
  6581. for (int index = 0; index < AC_QUANTITY; index++)
  6582. {
  6583. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6584. {
  6585. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  6586. {
  6587. 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))
  6588. {
  6589. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6590. }
  6591. else
  6592. {
  6593. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6594. }
  6595. }
  6596. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  6597. {
  6598. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6599. }
  6600. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  6601. {
  6602. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6603. }
  6604. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  6605. {
  6606. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6607. }
  6608. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6609. {
  6610. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6611. }
  6612. 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
  6613. {
  6614. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6615. }
  6616. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6617. {
  6618. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6619. }
  6620. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6621. {
  6622. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6623. }
  6624. }//end of the same index
  6625. }//end of for AC_QUANTITY
  6626. }
  6627. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  6628. random_uuid(guid);
  6629. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  6630. , MESSAGE_TYPE_CALL
  6631. , guid
  6632. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  6633. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  6634. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  6635. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  6636. if((server_sign == TRUE))
  6637. {
  6638. LWS_Send(message);
  6639. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  6640. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6641. {
  6642. result = PASS;
  6643. }
  6644. }
  6645. else
  6646. {
  6647. result = PASS;
  6648. }
  6649. return result;
  6650. }
  6651. int sendTransactionEventRequest(int gun_index)
  6652. {
  6653. mtrace();
  6654. int result = FAIL;
  6655. static uint32_t seqNo[CONNECTOR_QUANTITY] = {0};
  6656. char message[1024*20]={0};
  6657. char guid[37]={0};
  6658. char tempdata[128]={0};
  6659. uint8_t tempIndex;
  6660. json_object *TransactionEvent = json_object_new_object();
  6661. json_object *transactionInfo = json_object_new_object();
  6662. json_object *idToken = json_object_new_object();
  6663. json_object *evse = json_object_new_object();
  6664. json_object *meterValues = json_object_new_array();
  6665. if(gunType[gun_index] == 'J')
  6666. {
  6667. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6668. {
  6669. tempIndex = ((gun_index==2) ? 1: 0);
  6670. }
  6671. else
  6672. {
  6673. tempIndex = gun_index;
  6674. }
  6675. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6676. {
  6677. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6678. {
  6679. memset(&ShmOCPP20Data->TransactionEvent[index], 0x00, sizeof(struct TransactionEvent_20));
  6680. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6681. if((seqNo[index]+1) < INT_MAX)
  6682. seqNo[index]++;
  6683. else
  6684. seqNo[index] = 0;
  6685. ShmOCPP20Data->TransactionEvent[index].seqNo = seqNo[index];
  6686. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6687. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6688. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6689. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6690. {
  6691. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6692. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6693. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6694. {
  6695. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6696. }
  6697. else
  6698. {
  6699. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6700. }
  6701. }
  6702. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6703. {
  6704. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6705. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6706. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6707. }
  6708. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6709. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6710. ) //S_PRECHARGE
  6711. {
  6712. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6713. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6714. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6715. }
  6716. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6717. {
  6718. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6719. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6720. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6721. }
  6722. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6723. {
  6724. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  6725. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6726. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6727. }
  6728. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6729. {
  6730. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6731. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  6732. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6733. }
  6734. 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
  6735. {
  6736. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6737. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6738. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6739. }
  6740. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6741. {
  6742. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6743. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6744. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6745. }
  6746. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6747. {
  6748. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6749. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6750. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6751. }
  6752. } //end of the same index
  6753. }//end of for CHAdeMO_QUANTITY
  6754. }
  6755. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6756. {
  6757. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6758. {
  6759. tempIndex = ((gun_index==2) ? 1: 0);
  6760. }
  6761. else
  6762. {
  6763. tempIndex = gun_index;
  6764. }
  6765. for (int index = 0; index < CCS_QUANTITY; index++)
  6766. {
  6767. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6768. {
  6769. memset(&ShmOCPP20Data->TransactionEvent[index], 0x00, sizeof(struct TransactionEvent_20));
  6770. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6771. if((seqNo[index]+1) < INT_MAX)
  6772. seqNo[index]++;
  6773. else
  6774. seqNo[index] = 0;
  6775. ShmOCPP20Data->TransactionEvent[index].seqNo = seqNo[index];
  6776. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6777. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6778. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6779. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6780. {
  6781. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6782. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6783. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6784. {
  6785. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6786. }
  6787. else
  6788. {
  6789. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6790. }
  6791. }
  6792. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6793. {
  6794. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6795. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6796. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6797. }
  6798. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6799. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6800. ) //S_PRECHARGE
  6801. {
  6802. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6803. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6804. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6805. }
  6806. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6807. {
  6808. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6809. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6810. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6811. }
  6812. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6813. {
  6814. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  6815. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6816. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6817. }
  6818. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6819. {
  6820. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6821. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  6822. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6823. }
  6824. 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
  6825. {
  6826. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6827. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6828. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6829. }
  6830. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6831. {
  6832. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6833. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6834. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6835. }
  6836. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6837. {
  6838. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6839. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6840. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6841. }
  6842. } //end of the same index
  6843. } // end of for CCS_QUANTITY
  6844. }
  6845. else if(gunType[gun_index] == 'G')
  6846. {
  6847. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6848. {
  6849. tempIndex = ((gun_index==2) ? 1: 0);
  6850. }
  6851. else
  6852. {
  6853. tempIndex = gun_index;
  6854. }
  6855. for (int index = 0; index < GB_QUANTITY; index++)
  6856. {
  6857. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6858. {
  6859. memset(&ShmOCPP20Data->TransactionEvent[index], 0x00, sizeof(struct TransactionEvent_20));
  6860. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6861. if((seqNo[index]+1) < INT_MAX)
  6862. seqNo[index]++;
  6863. else
  6864. seqNo[index] = 0;
  6865. ShmOCPP20Data->TransactionEvent[index].seqNo = seqNo[index];
  6866. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6867. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6868. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6869. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6870. {
  6871. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6872. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6873. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6874. {
  6875. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6876. }
  6877. else
  6878. {
  6879. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6880. }
  6881. }
  6882. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6883. {
  6884. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6885. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6886. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6887. }
  6888. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6889. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6890. ) //S_PRECHARGE
  6891. {
  6892. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6893. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6894. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6895. }
  6896. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6897. {
  6898. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6899. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6900. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6901. }
  6902. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6903. {
  6904. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  6905. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6906. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6907. }
  6908. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6909. {
  6910. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6911. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  6912. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6913. }
  6914. 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
  6915. {
  6916. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6917. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6918. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6919. }
  6920. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6921. {
  6922. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6923. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6924. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6925. }
  6926. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6927. {
  6928. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6929. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6930. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6931. }
  6932. } //end of the same index
  6933. } // end of for GB_QUANTITY
  6934. }
  6935. else if(gunType[gun_index] == 'O')
  6936. {
  6937. tempIndex = gun_index;
  6938. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6939. {
  6940. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6941. {
  6942. memset(&ShmOCPP20Data->TransactionEvent[index], 0x00, sizeof(struct TransactionEvent_20));
  6943. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6944. if((seqNo[index]+1) < INT_MAX)
  6945. seqNo[index]++;
  6946. else
  6947. seqNo[index] = 0;
  6948. ShmOCPP20Data->TransactionEvent[index].seqNo = seqNo[index];
  6949. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6950. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6951. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6952. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6953. {
  6954. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6955. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6956. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6957. {
  6958. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6959. }
  6960. else
  6961. {
  6962. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6963. }
  6964. }
  6965. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6966. {
  6967. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6968. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6969. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6970. }
  6971. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6972. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6973. ) //S_PRECHARGE
  6974. {
  6975. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6976. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6977. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6978. }
  6979. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6980. {
  6981. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6982. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6983. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6984. }
  6985. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6986. {
  6987. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  6988. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6989. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6990. }
  6991. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6992. {
  6993. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6994. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  6995. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6996. }
  6997. 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
  6998. {
  6999. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7000. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7001. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7002. }
  7003. 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
  7004. {
  7005. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7006. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7007. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7008. }
  7009. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7010. {
  7011. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7012. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7013. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7014. }
  7015. } //end of the same index
  7016. }
  7017. }
  7018. else
  7019. {
  7020. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7021. {
  7022. tempIndex = 2;
  7023. }
  7024. else
  7025. {
  7026. tempIndex = gun_index;
  7027. }
  7028. for (int index = 0; index < AC_QUANTITY; index++)
  7029. {
  7030. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7031. {
  7032. memset(&ShmOCPP20Data->TransactionEvent[index], 0x00, sizeof(struct TransactionEvent_20));
  7033. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7034. if((seqNo[index]+1) < INT_MAX)
  7035. seqNo[index]++;
  7036. else
  7037. seqNo[index] = 0;
  7038. ShmOCPP20Data->TransactionEvent[index].seqNo = seqNo[index];
  7039. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7040. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  7041. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7042. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  7043. {
  7044. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7045. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7046. 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))
  7047. {
  7048. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7049. }
  7050. else
  7051. {
  7052. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7053. }
  7054. }
  7055. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7056. {
  7057. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7058. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7059. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7060. }
  7061. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7062. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7063. ) //S_PRECHARGE
  7064. {
  7065. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7066. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7067. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7068. }
  7069. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7070. {
  7071. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7072. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7073. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7074. }
  7075. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7076. {
  7077. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7078. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7079. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7080. }
  7081. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7082. {
  7083. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7084. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7085. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7086. }
  7087. 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
  7088. {
  7089. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7090. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7091. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7092. }
  7093. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7094. {
  7095. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7096. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7097. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7098. }
  7099. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7100. {
  7101. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7102. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7103. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7104. }
  7105. }//end of the same index
  7106. }//end of for AC_QUANTITY
  7107. }
  7108. // Message
  7109. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7110. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  7111. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  7112. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  7113. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  7114. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  7115. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  7116. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  7117. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  7118. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  7119. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  7120. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  7121. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  7122. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  7123. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  7124. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  7125. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  7126. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  7127. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  7128. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  7129. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  7130. {
  7131. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  7132. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  7133. json_object_object_add(TransactionEvent, "idToken", idToken);
  7134. }
  7135. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  7136. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  7137. json_object_object_add(TransactionEvent, "evse", evse);
  7138. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  7139. {
  7140. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  7141. {
  7142. json_object *meterValue = json_object_new_object();
  7143. json_object *sampledValues = json_object_new_array();
  7144. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  7145. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7146. {
  7147. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7148. {
  7149. json_object *sampledValue = json_object_new_object();
  7150. json_object *unitOfMeasure = json_object_new_object();
  7151. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7152. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7153. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7154. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7155. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7156. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7157. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7158. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7159. json_object_array_add(sampledValues, sampledValue);
  7160. }
  7161. }
  7162. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7163. json_object_array_add(meterValues, meterValue);
  7164. }
  7165. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  7166. }
  7167. random_uuid(guid);
  7168. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  7169. json_object_put(TransactionEvent);
  7170. LWS_Send(message);
  7171. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  7172. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7173. {
  7174. result = PASS;
  7175. }
  7176. return result;
  7177. }
  7178. //==========================================
  7179. // send confirm routine
  7180. //==========================================
  7181. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  7182. {
  7183. mtrace();
  7184. int result = FAIL;
  7185. char message[4096]={0};
  7186. json_object *CancelReservation = json_object_new_object();
  7187. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  7188. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  7189. sprintf(message,"[%d,\"%s\",%s]"
  7190. ,MESSAGE_TYPE_CALLRESULT
  7191. ,uuid
  7192. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  7193. json_object_put(CancelReservation);
  7194. ShmOCPP20Data->CsMsg.bits[0].CancelReservationConf = OFF;
  7195. LWS_Send(message);
  7196. result = TRUE;
  7197. return result;
  7198. }
  7199. int sendCertificateSignedConfirmation(char *uuid)
  7200. {
  7201. mtrace();
  7202. int result = FAIL;
  7203. char message[4096]={0};
  7204. json_object *CertificateSigned = json_object_new_object();
  7205. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  7206. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  7207. sprintf(message,"[%d,\"%s\",%s]"
  7208. ,MESSAGE_TYPE_CALLRESULT
  7209. ,uuid
  7210. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  7211. json_object_put(CertificateSigned);
  7212. LWS_Send(message);
  7213. result = TRUE;
  7214. return result;
  7215. }
  7216. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  7217. {
  7218. mtrace();
  7219. int result = FAIL;
  7220. char message[4096]={0};
  7221. json_object *ChangeAvailability = json_object_new_object();
  7222. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  7223. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  7224. sprintf(message,"[%d,\"%s\",%s]"
  7225. ,MESSAGE_TYPE_CALLRESULT
  7226. ,uuid
  7227. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  7228. json_object_put(ChangeAvailability);
  7229. LWS_Send(message);
  7230. result = TRUE;
  7231. return result;
  7232. }
  7233. int sendClearCacheConfirmation(char *uuid)
  7234. {
  7235. mtrace();
  7236. int result = FAIL;
  7237. char message[4096]={0};
  7238. json_object *ClearCache = json_object_new_object();
  7239. DEBUG_INFO("sendClearCacheConfirmation...\n");
  7240. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  7241. sprintf(message,"[%d,\"%s\",%s]"
  7242. ,MESSAGE_TYPE_CALLRESULT
  7243. ,uuid
  7244. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  7245. json_object_put(ClearCache);
  7246. LWS_Send(message);
  7247. result = TRUE;
  7248. return result;
  7249. }
  7250. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  7251. {
  7252. mtrace();
  7253. int result = FAIL;
  7254. char message[500]={0};
  7255. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  7256. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  7257. LWS_Send(message);
  7258. return result;
  7259. }
  7260. int sendClearDisplayMessageConfirmation(char *uuid)
  7261. {
  7262. mtrace();
  7263. int result = FAIL;
  7264. char message[4096]={0};
  7265. json_object *ClearDisplayMessage = json_object_new_object();
  7266. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  7267. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  7268. sprintf(message,"[%d,\"%s\",%s]"
  7269. ,MESSAGE_TYPE_CALLRESULT
  7270. ,uuid
  7271. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7272. json_object_put(ClearDisplayMessage);
  7273. LWS_Send(message);
  7274. result = TRUE;
  7275. return result;
  7276. }
  7277. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7278. {
  7279. mtrace();
  7280. int result = FAIL;
  7281. char message[4096]={0};
  7282. json_object *ClearVariableMonitoring = json_object_new_object();
  7283. json_object *clearMonitoringResults = json_object_new_array();
  7284. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  7285. for(int idx=0;idx<variableQuantity;idx++)
  7286. {
  7287. json_object *clearMonitoringResult = json_object_new_object();
  7288. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  7289. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  7290. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  7291. }
  7292. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  7293. sprintf(message,"[%d,\"%s\",%s]"
  7294. ,MESSAGE_TYPE_CALLRESULT
  7295. ,uuid
  7296. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7297. json_object_put(ClearVariableMonitoring);
  7298. LWS_Send(message);
  7299. result = TRUE;
  7300. return result;
  7301. }
  7302. int sendCostUpdatedConfirmation(char *uuid)
  7303. {
  7304. mtrace();
  7305. int result = FAIL;
  7306. char message[4096]={0};
  7307. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  7308. sprintf(message,"[%d,\"%s\",{}]"
  7309. ,MESSAGE_TYPE_CALLRESULT
  7310. ,uuid);
  7311. LWS_Send(message);
  7312. result = TRUE;
  7313. return result;
  7314. }
  7315. int sendCustomerInformationConfirmation(char *uuid)
  7316. {
  7317. mtrace();
  7318. int result = FAIL;
  7319. char message[4096]={0};
  7320. json_object *CustomerInformation = json_object_new_object();
  7321. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  7322. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  7323. sprintf(message,"[%d,\"%s\",%s]"
  7324. ,MESSAGE_TYPE_CALLRESULT
  7325. ,uuid
  7326. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  7327. json_object_put(CustomerInformation);
  7328. LWS_Send(message);
  7329. result = TRUE;
  7330. return result;
  7331. }
  7332. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  7333. {
  7334. mtrace();
  7335. int result = FAIL;
  7336. char message[4096]={0};
  7337. json_object *DataTransfer = json_object_new_object();
  7338. DEBUG_INFO("sendDataTransferConfirmation...\n");
  7339. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  7340. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  7341. sprintf(message,"[%d,\"%s\",%s]"
  7342. ,MESSAGE_TYPE_CALLRESULT
  7343. ,uuid
  7344. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  7345. json_object_put(DataTransfer);
  7346. LWS_Send(message);
  7347. result = TRUE;
  7348. return result;
  7349. }
  7350. int sendDeleteCertificateConfirmation(char *uuid)
  7351. {
  7352. mtrace();
  7353. int result = FAIL;
  7354. char message[4096]={0};
  7355. json_object *DeleteCertificate = json_object_new_object();
  7356. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  7357. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  7358. sprintf(message,"[%d,\"%s\",%s]"
  7359. ,MESSAGE_TYPE_CALLRESULT
  7360. ,uuid
  7361. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  7362. json_object_put(DeleteCertificate);
  7363. LWS_Send(message);
  7364. result = TRUE;
  7365. return result;
  7366. }
  7367. int sendGetBaseReportConfirmation(char *uuid)
  7368. {
  7369. mtrace();
  7370. int result = FAIL;
  7371. char message[4096]={0};
  7372. json_object *GetBaseReport = json_object_new_object();
  7373. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  7374. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  7375. sprintf(message,"[%d,\"%s\",%s]"
  7376. ,MESSAGE_TYPE_CALLRESULT
  7377. ,uuid
  7378. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  7379. json_object_put(GetBaseReport);
  7380. LWS_Send(message);
  7381. result = TRUE;
  7382. return result;
  7383. }
  7384. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  7385. {
  7386. mtrace();
  7387. int result = FAIL;
  7388. char message[4096]={0};
  7389. json_object *GetChargingProfiles = json_object_new_object();
  7390. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  7391. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  7392. sprintf(message,"[%d,\"%s\",%s]"
  7393. ,MESSAGE_TYPE_CALLRESULT
  7394. ,uuid
  7395. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  7396. json_object_put(GetChargingProfiles);
  7397. LWS_Send(message);
  7398. result = TRUE;
  7399. return result;
  7400. }
  7401. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  7402. {
  7403. mtrace();
  7404. int result = FAIL;
  7405. char message[4096]={0};
  7406. int CompositeScheduleIndex = 0;
  7407. json_object *GetCompositeSchedule = json_object_new_object();
  7408. json_object *schedule = json_object_new_object();
  7409. json_object *chargingSchedule = json_object_new_object();
  7410. json_object *chargingSchedulePeriod = json_object_new_array();
  7411. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  7412. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  7413. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  7414. if(nPeriod == 0)
  7415. {
  7416. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  7417. {
  7418. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7419. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7420. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7421. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7422. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7423. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7424. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7425. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7426. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7427. {
  7428. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7429. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7430. {
  7431. json_object *Period = json_object_new_object();
  7432. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7433. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7434. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7435. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7436. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7437. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7438. json_object_array_add(chargingSchedulePeriod, Period);
  7439. }
  7440. }
  7441. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7442. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7443. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7444. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7445. }
  7446. }
  7447. else
  7448. {
  7449. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7450. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7451. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7452. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7453. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7454. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7455. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7456. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7457. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7458. {
  7459. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7460. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7461. {
  7462. json_object *Period = json_object_new_object();
  7463. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7464. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7465. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7466. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7467. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7468. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7469. json_object_array_add(chargingSchedulePeriod, Period);
  7470. }
  7471. }
  7472. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7473. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7474. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7475. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7476. }
  7477. sprintf(message,"[%d,\"%s\",%s]"
  7478. ,MESSAGE_TYPE_CALLRESULT
  7479. ,uuid
  7480. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  7481. json_object_put(GetCompositeSchedule);
  7482. LWS_Send(message);
  7483. result = TRUE;
  7484. return result;
  7485. }
  7486. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  7487. {
  7488. mtrace();
  7489. int result = FAIL;
  7490. char message[4096]={0};
  7491. json_object *GetGetDisplayMessages = json_object_new_object();
  7492. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  7493. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  7494. sprintf(message,"[%d,\"%s\",%s]"
  7495. ,MESSAGE_TYPE_CALLRESULT
  7496. ,uuid
  7497. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7498. json_object_put(GetGetDisplayMessages);
  7499. LWS_Send(message);
  7500. result = TRUE;
  7501. return result;
  7502. }
  7503. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  7504. {
  7505. mtrace();
  7506. int result = FAIL;
  7507. char message[4096]={0};
  7508. json_object *GetInstalledCertificateIds = json_object_new_object();
  7509. json_object *certificateHashDataChains = json_object_new_array();
  7510. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  7511. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  7512. for(int idx=0;idx<certQuantity;idx++)
  7513. {
  7514. json_object *cert = json_object_new_object();
  7515. json_object *certificateHashData = json_object_new_object();
  7516. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  7517. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  7518. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  7519. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  7520. json_object_object_add(cert, "certificateHashData", certificateHashData);
  7521. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  7522. json_object_array_add(certificateHashDataChains, cert);
  7523. }
  7524. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  7525. sprintf(message,"[%d,\"%s\",%s]"
  7526. ,MESSAGE_TYPE_CALLRESULT
  7527. ,uuid
  7528. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  7529. json_object_put(GetInstalledCertificateIds);
  7530. LWS_Send(message);
  7531. result = TRUE;
  7532. return result;
  7533. }
  7534. int sendGetLocalListVersionConfirmation(char *uuid)
  7535. {
  7536. mtrace();
  7537. int result = FAIL;
  7538. char message[4096]={0};
  7539. json_object *GetLocalListVersion = json_object_new_object();
  7540. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  7541. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  7542. sprintf(message,"[%d,\"%s\",%s]"
  7543. ,MESSAGE_TYPE_CALLRESULT
  7544. ,uuid
  7545. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  7546. json_object_put(GetLocalListVersion);
  7547. LWS_Send(message);
  7548. result = TRUE;
  7549. return result;
  7550. }
  7551. int sendGetLogConfirmation(char *uuid)
  7552. {
  7553. mtrace();
  7554. int result = FAIL;
  7555. char message[4096]={0};
  7556. json_object *GetLog = json_object_new_object();
  7557. DEBUG_INFO("sendGetLogConfirmation...\n");
  7558. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  7559. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  7560. sprintf(message,"[%d,\"%s\",%s]"
  7561. ,MESSAGE_TYPE_CALLRESULT
  7562. ,uuid
  7563. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  7564. json_object_put(GetLog);
  7565. LWS_Send(message);
  7566. result = TRUE;
  7567. return result;
  7568. }
  7569. int sendGetMonitoringReportConfirmation(char *uuid)
  7570. {
  7571. mtrace();
  7572. int result = FAIL;
  7573. char message[4096]={0};
  7574. json_object *GetMonitoringReport = json_object_new_object();
  7575. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  7576. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  7577. sprintf(message,"[%d,\"%s\",%s]"
  7578. ,MESSAGE_TYPE_CALLRESULT
  7579. ,uuid
  7580. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  7581. json_object_put(GetMonitoringReport);
  7582. LWS_Send(message);
  7583. result = TRUE;
  7584. return result;
  7585. }
  7586. int sendGetReportConfirmation(char *uuid)
  7587. {
  7588. mtrace();
  7589. int result = FAIL;
  7590. char message[4096]={0};
  7591. json_object *GetReport = json_object_new_object();
  7592. DEBUG_INFO("sendGetReportConfirmation...\n");
  7593. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  7594. sprintf(message,"[%d,\"%s\",%s]"
  7595. ,MESSAGE_TYPE_CALLRESULT
  7596. ,uuid
  7597. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  7598. json_object_put(GetReport);
  7599. LWS_Send(message);
  7600. result = TRUE;
  7601. return result;
  7602. }
  7603. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  7604. {
  7605. mtrace();
  7606. int result = FAIL;
  7607. char message[4096]={0};
  7608. json_object *GetTransactionStatus = json_object_new_object();
  7609. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  7610. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  7611. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  7612. sprintf(message,"[%d,\"%s\",%s]"
  7613. ,MESSAGE_TYPE_CALLRESULT
  7614. ,uuid
  7615. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  7616. json_object_put(GetTransactionStatus);
  7617. LWS_Send(message);
  7618. result = TRUE;
  7619. return result;
  7620. }
  7621. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  7622. {
  7623. mtrace();
  7624. int result = FAIL;
  7625. char message[4096]={0};
  7626. json_object *GetVariables = json_object_new_object();
  7627. json_object *getVariableResults = json_object_new_array();
  7628. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  7629. for(int idx=0;idx<variableQuantity;idx++)
  7630. {
  7631. json_object *variableResult = json_object_new_object();
  7632. json_object *component = json_object_new_object();
  7633. json_object *variable = json_object_new_object();
  7634. json_object *evse = json_object_new_object();
  7635. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  7636. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  7637. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  7638. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  7639. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  7640. json_object_object_add(component, "component", evse);
  7641. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  7642. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  7643. json_object_object_add(variableResult, "component", component);
  7644. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  7645. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  7646. json_object_object_add(variableResult, "variable", variable);
  7647. json_object_array_add(getVariableResults, variableResult);
  7648. }
  7649. json_object_object_add(GetVariables , "setVariableResult", getVariableResults);
  7650. sprintf(message,"[%d,\"%s\",%s]"
  7651. ,MESSAGE_TYPE_CALLRESULT
  7652. ,uuid
  7653. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  7654. json_object_put(GetVariables);
  7655. LWS_Send(message);
  7656. result = TRUE;
  7657. return result;
  7658. }
  7659. int sendInstallCertificateConfirmation(char *uuid)
  7660. {
  7661. mtrace();
  7662. int result = FAIL;
  7663. char message[4096]={0};
  7664. json_object *InstallCertificate = json_object_new_object();
  7665. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  7666. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  7667. sprintf(message,"[%d,\"%s\",%s]"
  7668. ,MESSAGE_TYPE_CALLRESULT
  7669. ,uuid
  7670. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  7671. json_object_put(InstallCertificate);
  7672. LWS_Send(message);
  7673. result = TRUE;
  7674. return result;
  7675. }
  7676. int sendPublishFirmwareConfirmation(char *uuid)
  7677. {
  7678. mtrace();
  7679. int result = FAIL;
  7680. char message[4096]={0};
  7681. json_object *PublishFirmware = json_object_new_object();
  7682. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  7683. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  7684. sprintf(message,"[%d,\"%s\",%s]"
  7685. ,MESSAGE_TYPE_CALLRESULT
  7686. ,uuid
  7687. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  7688. json_object_put(PublishFirmware);
  7689. LWS_Send(message);
  7690. result = TRUE;
  7691. return result;
  7692. }
  7693. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  7694. {
  7695. mtrace();
  7696. int result = FAIL;
  7697. char message[4096]={0};
  7698. json_object *RemoteStartTransaction = json_object_new_object();
  7699. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  7700. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  7701. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  7702. sprintf(message,"[%d,\"%s\",%s]"
  7703. ,MESSAGE_TYPE_CALLRESULT
  7704. ,uuid
  7705. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  7706. json_object_put(RemoteStartTransaction);
  7707. LWS_Send(message);
  7708. result = TRUE;
  7709. return result;
  7710. }
  7711. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  7712. {
  7713. mtrace();
  7714. int result = FAIL;
  7715. char message[4096]={0};
  7716. json_object *RemoteStopTransaction = json_object_new_object();
  7717. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  7718. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  7719. sprintf(message,"[%d,\"%s\",%s]"
  7720. ,MESSAGE_TYPE_CALLRESULT
  7721. ,uuid
  7722. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  7723. json_object_put(RemoteStopTransaction);
  7724. LWS_Send(message);
  7725. result = TRUE;
  7726. return result;
  7727. }
  7728. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  7729. {
  7730. mtrace();
  7731. int result = FAIL;
  7732. char message[4096]={0};
  7733. json_object *ReserveNow = json_object_new_object();
  7734. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  7735. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  7736. sprintf(message,"[%d,\"%s\",%s]"
  7737. ,MESSAGE_TYPE_CALLRESULT
  7738. ,uuid
  7739. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  7740. json_object_put(ReserveNow);
  7741. LWS_Send(message);
  7742. result = TRUE;
  7743. return result;
  7744. }
  7745. int sendResetConfirmation(char *uuid)
  7746. {
  7747. mtrace();
  7748. int result = FAIL;
  7749. char message[4096]={0};
  7750. json_object *Reset = json_object_new_object();
  7751. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  7752. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  7753. sprintf(message,"[%d,\"%s\",%s]"
  7754. ,MESSAGE_TYPE_CALLRESULT
  7755. ,uuid
  7756. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  7757. json_object_put(Reset);
  7758. LWS_Send(message);
  7759. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  7760. {
  7761. DB_updateBootType(BootReasonEnumType_RemoteReset);
  7762. }
  7763. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  7764. {
  7765. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  7766. }
  7767. result = TRUE;
  7768. return result;
  7769. }
  7770. int sendSendLocalListConfirmation(char *uuid)
  7771. {
  7772. mtrace();
  7773. int result = FAIL;
  7774. char message[4096]={0};
  7775. json_object *SendLocalList = json_object_new_object();
  7776. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  7777. sprintf(message,"[%d,\"%s\",%s]"
  7778. ,MESSAGE_TYPE_CALLRESULT
  7779. ,uuid
  7780. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  7781. json_object_put(SendLocalList);
  7782. LWS_Send(message);
  7783. result = TRUE;
  7784. return result;
  7785. }
  7786. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  7787. {
  7788. mtrace();
  7789. int result = FAIL;
  7790. char message[4096]={0};
  7791. json_object *SetChargingProfile = json_object_new_object();
  7792. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  7793. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  7794. sprintf(message,"[%d,\"%s\",%s]"
  7795. ,MESSAGE_TYPE_CALLRESULT
  7796. ,uuid
  7797. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  7798. json_object_put(SetChargingProfile);
  7799. LWS_Send(message);
  7800. result = TRUE;
  7801. return result;
  7802. }
  7803. int sendSetDisplayMessageConfirmation(char *uuid)
  7804. {
  7805. mtrace();
  7806. int result = FAIL;
  7807. char message[4096]={0};
  7808. json_object *SetDisplayMessage = json_object_new_object();
  7809. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  7810. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  7811. sprintf(message,"[%d,\"%s\",%s]"
  7812. ,MESSAGE_TYPE_CALLRESULT
  7813. ,uuid
  7814. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7815. json_object_put(SetDisplayMessage);
  7816. LWS_Send(message);
  7817. result = TRUE;
  7818. return result;
  7819. }
  7820. int sendSetMonitoringBaseConfirmation(char *uuid)
  7821. {
  7822. mtrace();
  7823. int result = FAIL;
  7824. char message[4096]={0};
  7825. json_object *SetMonitoringBase = json_object_new_object();
  7826. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  7827. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  7828. sprintf(message,"[%d,\"%s\",%s]"
  7829. ,MESSAGE_TYPE_CALLRESULT
  7830. ,uuid
  7831. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  7832. json_object_put(SetMonitoringBase);
  7833. LWS_Send(message);
  7834. result = TRUE;
  7835. return result;
  7836. }
  7837. int sendSetMonitoringLevelConfirmation(char *uuid)
  7838. {
  7839. mtrace();
  7840. int result = FAIL;
  7841. char message[4096]={0};
  7842. json_object *SetMonitoringLevel = json_object_new_object();
  7843. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  7844. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  7845. sprintf(message,"[%d,\"%s\",%s]"
  7846. ,MESSAGE_TYPE_CALLRESULT
  7847. ,uuid
  7848. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  7849. json_object_put(SetMonitoringLevel);
  7850. LWS_Send(message);
  7851. result = TRUE;
  7852. return result;
  7853. }
  7854. int sendSetNetworkProfileConfirmation(char *uuid)
  7855. {
  7856. mtrace();
  7857. int result = FAIL;
  7858. char message[4096]={0};
  7859. json_object *SetNetworkProfile = json_object_new_object();
  7860. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  7861. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  7862. sprintf(message,"[%d,\"%s\",%s]"
  7863. ,MESSAGE_TYPE_CALLRESULT
  7864. ,uuid
  7865. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  7866. json_object_put(SetNetworkProfile);
  7867. LWS_Send(message);
  7868. result = TRUE;
  7869. return result;
  7870. }
  7871. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7872. {
  7873. mtrace();
  7874. int result = FAIL;
  7875. char message[4096]={0};
  7876. json_object *SetVariableMonitoring = json_object_new_object();
  7877. json_object *setMonitoringResults = json_object_new_array();
  7878. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  7879. for(int idx=0;idx<variableQuantity;idx++)
  7880. {
  7881. json_object *variableMonitorResult = json_object_new_object();
  7882. json_object *component = json_object_new_object();
  7883. json_object *variable = json_object_new_object();
  7884. json_object *evse = json_object_new_object();
  7885. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  7886. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  7887. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  7888. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  7889. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  7890. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  7891. json_object_object_add(component, "component", evse);
  7892. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  7893. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  7894. json_object_object_add(variableMonitorResult, "component", component);
  7895. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  7896. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  7897. json_object_object_add(variableMonitorResult, "variable", variable);
  7898. json_object_array_add(setMonitoringResults, variableMonitorResult);
  7899. }
  7900. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  7901. sprintf(message,"[%d,\"%s\",%s]"
  7902. ,MESSAGE_TYPE_CALLRESULT
  7903. ,uuid
  7904. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7905. json_object_put(SetVariableMonitoring);
  7906. LWS_Send(message);
  7907. result = TRUE;
  7908. return result;
  7909. }
  7910. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  7911. {
  7912. mtrace();
  7913. int result = FAIL;
  7914. char message[4096]={0};
  7915. json_object *SetVariable = json_object_new_object();
  7916. json_object *setVariableResults = json_object_new_array();
  7917. DEBUG_INFO("sendSetVariableConfirmation...\n");
  7918. for(int idx=0;idx<variableQuantity;idx++)
  7919. {
  7920. json_object *variableResult = json_object_new_object();
  7921. json_object *component = json_object_new_object();
  7922. json_object *variable = json_object_new_object();
  7923. json_object *evse = json_object_new_object();
  7924. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  7925. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  7926. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  7927. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  7928. json_object_object_add(component, "component", evse);
  7929. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  7930. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  7931. json_object_object_add(variableResult, "component", component);
  7932. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  7933. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  7934. json_object_object_add(variableResult, "variable", variable);
  7935. json_object_array_add(setVariableResults, variableResult);
  7936. }
  7937. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  7938. sprintf(message,"[%d,\"%s\",%s]"
  7939. ,MESSAGE_TYPE_CALLRESULT
  7940. ,uuid
  7941. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  7942. json_object_put(SetVariable);
  7943. LWS_Send(message);
  7944. result = TRUE;
  7945. return result;
  7946. }
  7947. int sendTriggerMessageConfirmation(char *uuid)
  7948. {
  7949. mtrace();
  7950. int result = FAIL;
  7951. char message[4096]={0};
  7952. json_object *TriggerMessage = json_object_new_object();
  7953. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  7954. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  7955. sprintf(message,"[%d,\"%s\",%s]",
  7956. MESSAGE_TYPE_CALLRESULT,
  7957. uuid,
  7958. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  7959. json_object_put(TriggerMessage);
  7960. LWS_Send(message);
  7961. result = TRUE;
  7962. return result;
  7963. }
  7964. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  7965. {
  7966. mtrace();
  7967. int result = FAIL;
  7968. char message[4096]={0};
  7969. json_object *UnlockConnector = json_object_new_object();
  7970. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  7971. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  7972. sprintf(message,"[%d,\"%s\",%s]",
  7973. MESSAGE_TYPE_CALLRESULT,
  7974. uuid,
  7975. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  7976. json_object_put(UnlockConnector);
  7977. LWS_Send(message);
  7978. result = TRUE;
  7979. return result;
  7980. }
  7981. int sendUnpublishFirmwareConfirmation(char *uuid)
  7982. {
  7983. mtrace();
  7984. int result = FAIL;
  7985. char message[4096]={0};
  7986. json_object *UnpublishFirmware = json_object_new_object();
  7987. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  7988. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  7989. sprintf(message,"[%d,\"%s\",%s]"
  7990. ,MESSAGE_TYPE_CALLRESULT
  7991. ,uuid
  7992. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  7993. json_object_put(UnpublishFirmware);
  7994. LWS_Send(message);
  7995. result = TRUE;
  7996. return result;
  7997. }
  7998. int sendUpdateFirmwareConfirmation(char *uuid)
  7999. {
  8000. mtrace();
  8001. int result = FAIL;
  8002. char message[4096]={0};
  8003. json_object *UpdateFirmware = json_object_new_object();
  8004. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  8005. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  8006. sprintf(message,"[%d,\"%s\",%s]"
  8007. ,MESSAGE_TYPE_CALLRESULT
  8008. ,uuid
  8009. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  8010. json_object_put(UpdateFirmware);
  8011. LWS_Send(message);
  8012. result = TRUE;
  8013. return result;
  8014. }
  8015. //==========================================
  8016. // send CallError routine
  8017. //==========================================
  8018. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  8019. {
  8020. mtrace();
  8021. char message[220]={0};
  8022. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  8023. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  8024. LWS_Send(message);
  8025. }
  8026. //==========================================
  8027. // Handle server request routine Start
  8028. //==========================================
  8029. int handleCancelReservationRequest(char *uuid, char *payload)
  8030. {
  8031. mtrace();
  8032. int result = FAIL;
  8033. int gunNO = 0;
  8034. int reservationIdInt = -1;
  8035. DEBUG_INFO("handleCancelReservationRequest...\n");
  8036. json_object *CancelReservation;
  8037. CancelReservation = json_tokener_parse(payload);
  8038. if(!is_error(CancelReservation))
  8039. {
  8040. // Required data
  8041. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  8042. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  8043. }
  8044. json_object_put(CancelReservation);
  8045. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  8046. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  8047. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  8048. if(reservationIdInt != -1)
  8049. {
  8050. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  8051. //check Transaction active
  8052. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8053. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8054. {
  8055. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  8056. {
  8057. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8058. if(gunType[2] == 'J')
  8059. {
  8060. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  8061. }
  8062. else
  8063. {
  8064. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  8065. }
  8066. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8067. goto end;
  8068. }
  8069. }
  8070. for (int index = 0; index < CCS_QUANTITY; index++)
  8071. {
  8072. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  8073. {
  8074. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8075. if((gunType[2] == 'U') || (gunType[2] == 'E'))
  8076. {
  8077. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  8078. }
  8079. else
  8080. {
  8081. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  8082. }
  8083. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8084. goto end;
  8085. }
  8086. }
  8087. for (int index = 0; index < GB_QUANTITY; index++)
  8088. {
  8089. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  8090. {
  8091. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8092. if(gunType[2] == 'G')
  8093. {
  8094. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  8095. }
  8096. else
  8097. {
  8098. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8099. }
  8100. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8101. goto end;
  8102. }
  8103. }
  8104. for (int index = 0; index < AC_QUANTITY; index++)
  8105. {
  8106. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  8107. {
  8108. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8109. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8110. {
  8111. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  8112. }
  8113. else
  8114. {
  8115. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  8116. }
  8117. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8118. goto end;
  8119. }
  8120. }
  8121. }
  8122. //The reservationId does NOT match the reservationId
  8123. sendCancelReservationConfirmation(uuid, gunNO);
  8124. end:
  8125. // Fill in ocpp packet uuid
  8126. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  8127. return result;
  8128. }
  8129. int handleCertificateSignedRequest(char *uuid, char *payload)
  8130. {
  8131. mtrace();
  8132. int result = FAIL;
  8133. json_object *CertificateSigned;
  8134. DEBUG_INFO("handleCertificateSignedRequest...\n");
  8135. CertificateSigned = json_tokener_parse(payload);
  8136. if(!is_error(CertificateSigned))
  8137. {
  8138. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  8139. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  8140. // Required data
  8141. if(json_object_array_length(json_object_object_get(CertificateSigned, "certificate")) <= ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.certificate))
  8142. {
  8143. for(int idx=0;idx<json_object_array_length(json_object_object_get(CertificateSigned, "certificate"));idx++)
  8144. {
  8145. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificate[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateType"), idx)));
  8146. /*
  8147. * TODO:
  8148. * 1. Certificate install response
  8149. */
  8150. }
  8151. }
  8152. // Optional data
  8153. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  8154. {
  8155. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  8156. }
  8157. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  8158. }
  8159. else
  8160. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  8161. json_object_put(CertificateSigned);
  8162. sendCertificateSignedConfirmation(uuid);
  8163. return result;
  8164. }
  8165. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  8166. {
  8167. mtrace();
  8168. int result = FAIL;
  8169. int evseId = 0, gunIndex = 0;
  8170. char operationalStatus[16]={0};
  8171. char comfirmstr[20];
  8172. int specificId = FALSE;
  8173. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  8174. json_object *ChangeAvailability;
  8175. ChangeAvailability = json_tokener_parse(payload);
  8176. if(!is_error(ChangeAvailability))
  8177. {
  8178. // Required data
  8179. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  8180. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  8181. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  8182. {
  8183. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  8184. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  8185. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  8186. }
  8187. }
  8188. json_object_put(ChangeAvailability);
  8189. if((evseId != 0) && (evseId <= gunTotalNumber))
  8190. {
  8191. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  8192. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  8193. }
  8194. else if(evseId == 0)
  8195. {
  8196. for(int i=0; i < gunTotalNumber; i++)
  8197. {
  8198. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  8199. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8200. }
  8201. }
  8202. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8203. {
  8204. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  8205. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  8206. }
  8207. else if(gunIndex == 0)
  8208. {
  8209. for(int i=0; i < gunTotalNumber; i++)
  8210. {
  8211. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  8212. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8213. }
  8214. }
  8215. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  8216. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8217. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  8218. {
  8219. specificId = TRUE;
  8220. }
  8221. if(specificId == FALSE)
  8222. goto end;
  8223. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  8224. {
  8225. //----------------------gunIndex is 0 ------------------------------------------------//
  8226. if(gunIndex == 0)
  8227. {
  8228. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8229. {
  8230. for(int i=0; i < gunTotalNumber; i++)
  8231. {
  8232. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8233. {
  8234. if ((gunType[i] == 'J')&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  8235. {
  8236. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8237. {
  8238. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8239. goto end;
  8240. }
  8241. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8242. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8243. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8244. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8245. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8246. {
  8247. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8248. goto end;
  8249. }
  8250. }
  8251. }//END FOR CHAdeMO_QUANTITY
  8252. for (int index = 0; index < CCS_QUANTITY; index++)
  8253. {
  8254. if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  8255. {
  8256. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  8257. {
  8258. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8259. goto end;
  8260. }
  8261. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8262. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8263. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8264. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8265. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8266. {
  8267. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8268. goto end;
  8269. }
  8270. }
  8271. }//END FOR CCS_QUANTITY
  8272. for (int index = 0; index < GB_QUANTITY; index++)
  8273. {
  8274. if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  8275. {
  8276. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8277. {
  8278. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8279. goto end;
  8280. }
  8281. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8282. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8283. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8284. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8285. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8286. {
  8287. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8288. goto end;
  8289. }
  8290. }
  8291. }// END FOR GB_QUANTITY
  8292. for (int index = 0; index < AC_QUANTITY; index++)
  8293. {
  8294. if (((gunType[i] > '0')&&(gunType[i] <= '9'))&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  8295. {
  8296. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8297. {
  8298. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8299. goto end;
  8300. }
  8301. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8302. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8303. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8304. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8305. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8306. {
  8307. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8308. goto end;
  8309. }
  8310. }
  8311. }//END FOR AC_QUANTITY
  8312. }// END FOR gunTotalNumber
  8313. }
  8314. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8315. {
  8316. for(int i=0; i < gunTotalNumber; i++)
  8317. {
  8318. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8319. {
  8320. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8321. goto end;
  8322. }
  8323. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8324. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  8325. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  8326. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  8327. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8328. {
  8329. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8330. goto end;
  8331. }
  8332. }
  8333. }
  8334. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8335. goto end;
  8336. }
  8337. //----------------------gunIndex is not 0 ------------------------------------------------//
  8338. //check Transaction active
  8339. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8340. {
  8341. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J'))
  8342. {
  8343. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  8344. {
  8345. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8346. goto end;
  8347. }
  8348. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8349. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8350. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8351. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8352. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8353. {
  8354. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8355. goto end;
  8356. }
  8357. else
  8358. {
  8359. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  8360. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8361. goto end;
  8362. }
  8363. }
  8364. }//END FOR CHAdeMO_QUANTITY
  8365. for (int index = 0; index < CCS_QUANTITY; index++)
  8366. {
  8367. if ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E')))
  8368. {
  8369. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  8370. {
  8371. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8372. goto end;
  8373. }
  8374. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8375. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8376. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8377. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8378. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8379. {
  8380. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8381. goto end;
  8382. }
  8383. else
  8384. {
  8385. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  8386. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8387. goto end;
  8388. }
  8389. }
  8390. }//END FOR CCS_QUANTITY
  8391. for (int index = 0; index < GB_QUANTITY; index++)
  8392. {
  8393. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))
  8394. {
  8395. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8396. {
  8397. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8398. goto end;
  8399. }
  8400. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8401. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8402. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8403. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8404. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8405. {
  8406. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8407. goto end;
  8408. }
  8409. else
  8410. {
  8411. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  8412. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8413. goto end;
  8414. }
  8415. }
  8416. }// END FOR GB_QUANTITY
  8417. for (int index = 0; index < AC_QUANTITY; index++)
  8418. {
  8419. if ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))
  8420. {
  8421. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8422. {
  8423. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8424. goto end;
  8425. }
  8426. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8427. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8428. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8429. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8430. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8431. {
  8432. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8433. goto end;
  8434. }
  8435. else
  8436. {
  8437. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  8438. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8439. goto end;
  8440. }
  8441. }
  8442. }//END FOR AC_QUANTITY
  8443. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  8444. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  8445. {
  8446. //----------------------gunIndex is 0 ------------------------------------------------//
  8447. if(gunIndex == 0)
  8448. {
  8449. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8450. {
  8451. for(int i=0; i < gunTotalNumber; i++)
  8452. {
  8453. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8454. {
  8455. if ((gunType[i] == 'J' )&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J')) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8456. {
  8457. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8458. goto end;
  8459. }
  8460. }//END FOR CHAdeMO_QUANTITY
  8461. for (int index = 0; index < CCS_QUANTITY; index++)
  8462. {
  8463. if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT//(((gunIndex == 0)|| ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8464. {
  8465. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8466. goto end;
  8467. }
  8468. }//END FOR CCS_QUANTITY
  8469. for (int index = 0; index < GB_QUANTITY; index++)
  8470. {
  8471. if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G')))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8472. {
  8473. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8474. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8475. goto end;
  8476. }
  8477. }// END FOR GB_QUANTITY
  8478. for (int index = 0; index < AC_QUANTITY; index++)
  8479. {
  8480. if (((gunType[i] > '0')&&(gunType[i] <= '9')) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT // (((gunIndex == 0)|| ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8481. {
  8482. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8483. goto end;
  8484. }
  8485. }//END FOR CHAdeMO_QUANTITY
  8486. }// END FOR gunTotalNumber
  8487. }
  8488. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8489. {
  8490. for(int i=0; i < gunTotalNumber; i++)
  8491. {
  8492. for (int index = 0; index < AC_QUANTITY; index++)
  8493. {
  8494. if (((gunType[i] > '0')&&(gunType[i] <= '9')) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT // (((gunIndex == 0)|| ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8495. {
  8496. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8497. goto end;
  8498. }
  8499. }//END FOR CHAdeMO_QUANTITY
  8500. } // END FOR gunTotalNumber
  8501. }
  8502. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8503. goto end;
  8504. }
  8505. //----------------------gunIndex is not 0 ------------------------------------------------//
  8506. //check Transaction active
  8507. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8508. {
  8509. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'J') ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8510. {
  8511. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8512. goto end;
  8513. }
  8514. }//END FOR CHAdeMO_QUANTITY
  8515. for (int index = 0; index < CCS_QUANTITY; index++)
  8516. {
  8517. if ((((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8518. {
  8519. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8520. goto end;
  8521. }
  8522. }//END FOR CCS_QUANTITY
  8523. for (int index = 0; index < GB_QUANTITY; index++)
  8524. {
  8525. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8526. {
  8527. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8528. goto end;
  8529. }
  8530. }// END FOR GB_QUANTITY
  8531. for (int index = 0; index < AC_QUANTITY; index++)
  8532. {
  8533. if (((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8534. {
  8535. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8536. goto end;
  8537. }
  8538. }//END FOR AC_QUANTITY
  8539. }//END FOR AvailabilityEnumTypeStr[Operative]
  8540. end:
  8541. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8542. {
  8543. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  8544. }
  8545. else
  8546. {
  8547. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  8548. }
  8549. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8550. {
  8551. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8552. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8553. }
  8554. else if(gunIndex == 0)
  8555. {
  8556. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8557. {
  8558. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  8559. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  8560. }
  8561. }
  8562. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  8563. return result;
  8564. }
  8565. int handleClearCacheRequest(char *uuid, char *payload)
  8566. {
  8567. mtrace();
  8568. int result = FAIL;
  8569. char rmFileCmd[100]={0};
  8570. struct stat stats;
  8571. DEBUG_INFO("handleClearCacheRequest...\n");
  8572. stat("/Storage/OCPP", &stats);
  8573. // Check for directory existence
  8574. if (S_ISDIR(stats.st_mode) == 1)
  8575. {}
  8576. else
  8577. {
  8578. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  8579. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  8580. system(rmFileCmd);
  8581. }
  8582. /*
  8583. * TODO:
  8584. * 1. Clear cache from sqlite db
  8585. */
  8586. if(1)
  8587. {
  8588. DEBUG_INFO("open AuthorizationCache file failed\n");
  8589. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  8590. }
  8591. else
  8592. {
  8593. DEBUG_INFO("open AuthorizationCache file successful\n");
  8594. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  8595. }
  8596. sendClearCacheConfirmation(uuid);
  8597. return result;
  8598. }
  8599. int handleClearChargingProfileRequest(char *uuid, char *payload)
  8600. {
  8601. mtrace();
  8602. int result = FAIL;
  8603. int resultRename;
  8604. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  8605. char chargingProfilePurposeStr[26]={0};
  8606. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  8607. char tempchargingProfilePurposeStr[26]={0};
  8608. char sstr[160]={0};
  8609. char str[100]={0};
  8610. int c = 0;
  8611. char *loc;
  8612. char fname[200]={0};
  8613. char comfirmstr[20]={0};
  8614. char word[1600]={0};
  8615. int clearflag = FALSE;
  8616. int chargingProfileIdIsNULL = FALSE;
  8617. int connectorIsNULL = FALSE;
  8618. int chargingProfilePurposeIsNULL = FALSE;
  8619. int stackLevelIsNULL = FALSE;
  8620. //int GotoEnd = FALSE;
  8621. FILE *fptr1, *fptr2;
  8622. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  8623. int n_chargingProfile=0;
  8624. int isEmptyFile = FALSE;
  8625. char sLineWord[1600]={0};
  8626. char chargingProfiles[10][100]={0};
  8627. int ChargeProfileCount = 0;
  8628. int ch;
  8629. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  8630. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  8631. json_object *ClearChargingProfile;
  8632. ClearChargingProfile = json_tokener_parse(payload);
  8633. if(!is_error(ClearChargingProfile))
  8634. {
  8635. // Optional data
  8636. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  8637. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  8638. else
  8639. chargingProfileIdIsNULL = TRUE;
  8640. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  8641. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  8642. else
  8643. connectorIsNULL = TRUE;
  8644. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  8645. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  8646. else
  8647. chargingProfilePurposeIsNULL = TRUE;
  8648. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  8649. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  8650. else
  8651. stackLevelIsNULL = TRUE;
  8652. }
  8653. json_object_put(ClearChargingProfile);
  8654. if(connectorIsNULL == FALSE)
  8655. {
  8656. switch(connectorIdInt)
  8657. {
  8658. case 0:
  8659. if(chargingProfilePurposeIsNULL == TRUE)
  8660. {
  8661. int l = 0;
  8662. strcpy(fname, ChargePointMaxProfile_JSON);
  8663. if((access(fname,F_OK))!=-1)
  8664. {
  8665. strcpy(chargingProfiles[l], fname);
  8666. l = l + 1;
  8667. }
  8668. strcpy(fname, TxDefaultProfile_0_JSON);
  8669. if((access(fname,F_OK))!=-1)
  8670. {
  8671. strcpy(chargingProfiles[l], fname);
  8672. l = l + 1;
  8673. }
  8674. ChargeProfileCount = l;
  8675. }
  8676. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  8677. {
  8678. strcpy(fname, ChargePointMaxProfile_JSON);
  8679. if((access(fname,F_OK))!=-1)
  8680. {
  8681. strcpy(chargingProfiles[0], fname);
  8682. ChargeProfileCount = 1;
  8683. }
  8684. }
  8685. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  8686. {
  8687. strcpy(fname, TxDefaultProfile_0_JSON);
  8688. if((access(fname,F_OK))!=-1)
  8689. {
  8690. strcpy(chargingProfiles[0], fname);
  8691. ChargeProfileCount = 1;
  8692. }
  8693. }
  8694. break;
  8695. default:
  8696. if(chargingProfilePurposeIsNULL == TRUE)
  8697. {
  8698. int m = 0;
  8699. memset(fname, 0, ARRAY_SIZE(fname));
  8700. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  8701. if((access(fname,F_OK))!=-1)
  8702. {
  8703. strcpy(chargingProfiles[m], fname);
  8704. m = m + 1;
  8705. }
  8706. memset(fname, 0, ARRAY_SIZE(fname));
  8707. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  8708. if((access(fname,F_OK))!=-1)
  8709. {
  8710. strcpy(chargingProfiles[m], fname);
  8711. m = m + 1;
  8712. }
  8713. ChargeProfileCount = m;
  8714. }
  8715. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  8716. {
  8717. //strcpy(fname, TxDefaultProfile_1_JSON);
  8718. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  8719. if((access(fname,F_OK))!=-1)
  8720. {
  8721. strcpy(chargingProfiles[0], fname);
  8722. ChargeProfileCount = 1;
  8723. }
  8724. }
  8725. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  8726. {
  8727. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  8728. if((access(fname,F_OK))!=-1)
  8729. {
  8730. strcpy(chargingProfiles[0], fname);
  8731. ChargeProfileCount = 1;
  8732. }
  8733. }
  8734. //strcpy(fname, ChargePointMaxProfile_JSON );
  8735. break;
  8736. }
  8737. }
  8738. else // Check all Charging Profiles
  8739. {
  8740. int i = 0;
  8741. char fnametemp[200]={0};
  8742. ChargeProfileCount = 0;
  8743. //Check ChargePointMaxProfile.json exit
  8744. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  8745. {
  8746. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  8747. i = i + 1;
  8748. }
  8749. //Check TxDefaultProfile_0.json exit
  8750. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  8751. {
  8752. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  8753. i = i + 1;
  8754. }
  8755. //Check TxDefaultProfile_%d.json
  8756. for(int j=1; j <= gunTotalNumber; j++)
  8757. {
  8758. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  8759. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  8760. if((access(fnametemp,F_OK))!=-1)
  8761. {
  8762. strcpy(chargingProfiles[i], fnametemp);
  8763. i = i + 1;
  8764. }
  8765. }
  8766. //Check TxProfile_%d.json
  8767. for(int j=1; j <= gunTotalNumber; j++)
  8768. {
  8769. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  8770. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  8771. if((access(fnametemp,F_OK))!=-1)
  8772. {
  8773. strcpy(chargingProfiles[i], fnametemp);
  8774. i = i + 1;
  8775. }
  8776. }
  8777. ChargeProfileCount = i;
  8778. }// End connectorIsNULL is TRUE
  8779. if(ChargeProfileCount == 0)
  8780. {
  8781. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8782. goto end;
  8783. }
  8784. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  8785. {
  8786. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8787. goto end;
  8788. }
  8789. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  8790. {
  8791. memset(str, 0, ARRAY_SIZE(str));
  8792. // clear temp file
  8793. sprintf(str,"rm -f %s",temp);
  8794. system(str);
  8795. for(int k=0; k < ChargeProfileCount; k++)
  8796. {
  8797. memset(str, 0, ARRAY_SIZE(str));
  8798. //clear file in C
  8799. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8800. system(str);
  8801. }
  8802. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8803. goto end;
  8804. }
  8805. else if(connectorIsNULL == TRUE)
  8806. {
  8807. for(int k=0; k < ChargeProfileCount; k++)
  8808. {
  8809. fptr1 = fopen(chargingProfiles[k], "r");
  8810. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  8811. //Check Charging Profile Count
  8812. while(fscanf(fptr1, "%s", word) != EOF)
  8813. {
  8814. //DEBUG_INFO("word=%s\n",word);
  8815. if(strstr(word, "chargingProfileId")!= NULL)
  8816. {
  8817. //DEBUG_INFO("test chargingProfileId \n");
  8818. n_chargingProfile = n_chargingProfile + 1;
  8819. //DEBUG_INFO("chargingProfileId Found\n");
  8820. }
  8821. }
  8822. rewind(fptr1);
  8823. //search Charging Profile Element
  8824. //int i= 0;
  8825. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  8826. {
  8827. //------------------------tempconnectorIdInt------------------------//
  8828. loc = strstr(sLineWord, "connectorId");
  8829. c = 0;
  8830. memset(sstr ,0, sizeof(sstr) );
  8831. while (loc[strlen("connectorId")+2+c] != ',')
  8832. {
  8833. sstr[c] = loc[strlen("connectorId")+2+c];
  8834. c++;
  8835. }
  8836. sstr[c] = '\0';
  8837. tempconnectorIdInt = atoi(sstr);
  8838. printf("file's gun number is %d\n", tempconnectorIdInt);
  8839. //--------------------------chargingProfileId--------------------//
  8840. c = 0;
  8841. loc = strstr(sLineWord, "chargingProfileId");
  8842. memset(sstr ,0, ARRAY_SIZE(sstr));
  8843. while (loc[strlen("chargingProfileId")+2+c] != ',')
  8844. {
  8845. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  8846. //printf("i=%d sstr=%c\n",c, sstr[c]);
  8847. c++;
  8848. }
  8849. sstr[c] = '\0';
  8850. tempchargingProfileIdInt = atoi(sstr);
  8851. //stackLevel
  8852. c = 0;
  8853. loc = strstr(sLineWord, "stackLevel");
  8854. memset(sstr ,0, ARRAY_SIZE(sstr));
  8855. while (loc[strlen("stackLevel")+2+c] != ',')
  8856. {
  8857. sstr[c] = loc[strlen("stackLevel")+2+c];
  8858. //printf("i=%d sstr=%c\n",c, sstr[c]);
  8859. c++;
  8860. }
  8861. sstr[c] = '\0';
  8862. tempstackLevelInt = atoi(sstr);
  8863. c = 0;
  8864. loc = strstr(sLineWord, "chargingProfilePurpose");
  8865. memset(sstr ,0, ARRAY_SIZE(sstr));
  8866. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  8867. {
  8868. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  8869. c++;
  8870. }
  8871. sstr[c] = '\0';
  8872. strcpy(tempchargingProfilePurposeStr, sstr);
  8873. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  8874. {
  8875. //------- not write to fptr2-------//
  8876. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8877. //clearflag = TRUE;
  8878. }
  8879. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  8880. {
  8881. //------- not write to fptr2-------//
  8882. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8883. }
  8884. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  8885. {
  8886. //------- not write to fptr2-------//
  8887. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8888. }
  8889. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  8890. {
  8891. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8892. }
  8893. else
  8894. {
  8895. fprintf(fptr2, sLineWord);//writing data into file
  8896. }
  8897. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  8898. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  8899. if(clearflag == TRUE)
  8900. {
  8901. fclose(fptr1);
  8902. fclose(fptr2);
  8903. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8904. system(str);
  8905. // clear temp file
  8906. sprintf(str,"rm -f %s",temp);
  8907. system(str);
  8908. }
  8909. else
  8910. {
  8911. fclose(fptr1);
  8912. fclose(fptr2);
  8913. memset(str, 0, ARRAY_SIZE(str));
  8914. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8915. system(str);
  8916. resultRename = rename(temp, chargingProfiles[k]);
  8917. if(resultRename == 0)
  8918. {
  8919. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  8920. }
  8921. else
  8922. {
  8923. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  8924. }
  8925. if(comfirmstr[0]== 0)
  8926. {
  8927. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8928. }
  8929. //Check chargingProfile is empty file
  8930. /*------ Read the file ----------------*/
  8931. fptr1=fopen(chargingProfiles[k],"r");
  8932. ch=fgetc(fptr1);
  8933. rewind(fptr1);
  8934. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  8935. if(ch!=EOF)
  8936. {
  8937. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  8938. {
  8939. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  8940. if(sLineWord[0]=='\0')
  8941. {
  8942. isEmptyFile = TRUE;
  8943. break;
  8944. }
  8945. else
  8946. {
  8947. isEmptyFile = FALSE;
  8948. break;
  8949. }
  8950. }
  8951. }
  8952. else
  8953. isEmptyFile = TRUE;
  8954. fclose(fptr1);
  8955. if(isEmptyFile == TRUE)
  8956. {
  8957. memset(str, 0, ARRAY_SIZE(str));
  8958. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8959. system(str);
  8960. }
  8961. }
  8962. }// End of while(int k=0; k < ChargePointCount; k++)
  8963. }
  8964. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  8965. {
  8966. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  8967. for(int k=0; k < ChargeProfileCount; k++)
  8968. {
  8969. fptr1 = fopen(chargingProfiles[k], "r");
  8970. fptr2 = fopen(temp, "w+");
  8971. //Check Charging Profile Count
  8972. while(fscanf(fptr1, "%s", word) != EOF)
  8973. {
  8974. //DEBUG_INFO("word=%s\n",word);
  8975. if(strstr(word, "chargingProfileId")!= NULL)
  8976. {
  8977. n_chargingProfile = n_chargingProfile + 1;
  8978. }
  8979. }
  8980. rewind(fptr1);
  8981. //search Charging Profile Element
  8982. //int i= 0;
  8983. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  8984. {
  8985. //*************************tempconnectorIdInt*********************************/
  8986. loc = strstr(sLineWord, "connectorId");
  8987. c = 0;
  8988. memset(sstr ,0, ARRAY_SIZE(sstr));
  8989. while (loc[strlen("connectorId")+2+c] != ',')
  8990. {
  8991. sstr[c] = loc[strlen("connectorId")+2+c];
  8992. c++;
  8993. }
  8994. sstr[c] = '\0';
  8995. tempconnectorIdInt = atoi(sstr);
  8996. //chargingProfileId
  8997. c = 0;
  8998. loc = strstr(sLineWord, "chargingProfileId");
  8999. memset(sstr ,0, ARRAY_SIZE(sstr));
  9000. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9001. {
  9002. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9003. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9004. c++;
  9005. }
  9006. sstr[c] = '\0';
  9007. tempchargingProfileIdInt = atoi(sstr);
  9008. //stackLevel
  9009. c = 0;
  9010. loc = strstr(sLineWord, "stackLevel");
  9011. memset(sstr ,0, ARRAY_SIZE(sstr));
  9012. while (loc[strlen("stackLevel")+2+c] != ',')
  9013. {
  9014. sstr[c] = loc[strlen("stackLevel")+2+c];
  9015. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9016. c++;
  9017. }
  9018. sstr[c] = '\0';
  9019. tempstackLevelInt = atoi(sstr);
  9020. c = 0;
  9021. loc = strstr(sLineWord, "chargingProfilePurpose");
  9022. memset(sstr ,0, ARRAY_SIZE(sstr));
  9023. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9024. {
  9025. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9026. c++;
  9027. }
  9028. sstr[c] = '\0';
  9029. strcpy(tempchargingProfilePurposeStr, sstr);
  9030. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9031. {
  9032. //------- not write to fptr2-------//
  9033. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9034. //clearflag = TRUE;
  9035. }
  9036. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9037. {
  9038. //------- not write to fptr2-------//
  9039. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9040. }
  9041. else if(stackLevelIsNULL == TRUE)
  9042. {
  9043. //Clear Whole File
  9044. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9045. clearflag = TRUE;
  9046. break;
  9047. }
  9048. else
  9049. {
  9050. fprintf(fptr2, sLineWord);//writing data into file
  9051. }
  9052. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9053. }
  9054. if(clearflag == TRUE)
  9055. {
  9056. fclose(fptr1);
  9057. fclose(fptr2);
  9058. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9059. system(str);
  9060. // clear temp file
  9061. sprintf(str,"rm -f %s",temp);
  9062. system(str);
  9063. }
  9064. else
  9065. {
  9066. fclose(fptr1);
  9067. fclose(fptr2);
  9068. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9069. system(str);
  9070. resultRename = rename(temp, chargingProfiles[k]);
  9071. if(resultRename == 0)
  9072. {
  9073. DEBUG_INFO("File ChargingProfile renamed successfully");
  9074. }
  9075. else
  9076. {
  9077. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  9078. }
  9079. if(comfirmstr[0]== 0)
  9080. {
  9081. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9082. }
  9083. //Check chargingProfile is empty file
  9084. /*------ Read the file ----------------*/
  9085. fptr1=fopen(chargingProfiles[k],"r");
  9086. ch=fgetc(fptr1);
  9087. rewind(fptr1);
  9088. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9089. if(ch!=EOF)
  9090. {
  9091. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9092. {
  9093. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9094. if(sLineWord[0]=='\0')
  9095. {
  9096. isEmptyFile = TRUE;
  9097. break;
  9098. }
  9099. else
  9100. {
  9101. isEmptyFile = FALSE;
  9102. break;
  9103. }
  9104. }
  9105. }
  9106. else
  9107. isEmptyFile = TRUE;
  9108. fclose(fptr1);
  9109. if(isEmptyFile == TRUE)
  9110. {
  9111. memset(str, 0, ARRAY_SIZE(str));
  9112. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9113. system(str);
  9114. }
  9115. /*------- End of reading ---------------*/
  9116. }
  9117. } // while(int k=0; k < ChargeProfileCount; k++)
  9118. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  9119. end:
  9120. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  9121. {
  9122. if(connectorIdInt == 0)
  9123. {
  9124. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  9125. {
  9126. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  9127. }
  9128. }
  9129. else
  9130. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1]);
  9131. }
  9132. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  9133. return result;
  9134. }
  9135. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  9136. {
  9137. mtrace();
  9138. int result = FAIL;
  9139. json_object *ClearDisplayMessage;
  9140. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  9141. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  9142. ClearDisplayMessage = json_tokener_parse(payload);
  9143. if(!is_error(ClearDisplayMessage))
  9144. {
  9145. // Required data
  9146. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  9147. {
  9148. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  9149. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  9150. }
  9151. }
  9152. json_object_put(ClearDisplayMessage);
  9153. sendCostUpdatedConfirmation(uuid);
  9154. return result;
  9155. }
  9156. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  9157. {
  9158. mtrace();
  9159. int result = FAIL;
  9160. json_object *ClearVariableMonitorin;
  9161. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  9162. ClearVariableMonitorin = json_tokener_parse(payload);
  9163. if(!is_error(ClearVariableMonitorin))
  9164. {
  9165. // Required data
  9166. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  9167. {
  9168. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  9169. {
  9170. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  9171. /*
  9172. * TODO:
  9173. * 1. Check response
  9174. */
  9175. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  9176. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  9177. }
  9178. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  9179. }
  9180. }
  9181. json_object_put(ClearVariableMonitorin);
  9182. return result;
  9183. }
  9184. int handleCostUpdatedRequest(char *uuid, char *payload)
  9185. {
  9186. mtrace();
  9187. int result = FAIL;
  9188. json_object *CostUpdate;
  9189. DEBUG_INFO("handleCostUpdatedRequest...\n");
  9190. CostUpdate = json_tokener_parse(payload);
  9191. if(!is_error(CostUpdate))
  9192. {
  9193. // Required data
  9194. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  9195. {
  9196. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  9197. }
  9198. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  9199. {
  9200. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  9201. }
  9202. }
  9203. json_object_put(CostUpdate);
  9204. sendCostUpdatedConfirmation(uuid);
  9205. return result;
  9206. }
  9207. int handleCustomerInformationRequest(char *uuid, char *payload)
  9208. {
  9209. mtrace();
  9210. int result = FAIL;
  9211. json_object *CustomerInformation;
  9212. DEBUG_INFO("handleCustomerInformationRequest...\n");
  9213. CustomerInformation = json_tokener_parse(payload);
  9214. if(!is_error(CustomerInformation))
  9215. {
  9216. // Required data
  9217. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  9218. {
  9219. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  9220. }
  9221. if(json_object_object_get(CustomerInformation, "report") != NULL)
  9222. {
  9223. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  9224. }
  9225. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  9226. {
  9227. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  9228. }
  9229. // Optional data
  9230. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  9231. {
  9232. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  9233. {
  9234. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  9235. }
  9236. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  9237. {
  9238. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  9239. }
  9240. }
  9241. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  9242. {
  9243. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  9244. {
  9245. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  9246. }
  9247. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  9248. {
  9249. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  9250. }
  9251. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  9252. {
  9253. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  9254. }
  9255. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  9256. {
  9257. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  9258. }
  9259. }
  9260. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  9261. }
  9262. else
  9263. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  9264. json_object_put(CustomerInformation);
  9265. sendCustomerInformationConfirmation(uuid);
  9266. return result;
  9267. }
  9268. void createFirmwareVersionByDataTransfer(void)
  9269. {
  9270. json_object *FirmwareDataTransfer = json_object_new_object();
  9271. // AC & DC model
  9272. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  9273. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  9274. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  9275. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  9276. // DC model
  9277. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  9278. {
  9279. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9280. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9281. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  9282. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  9283. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9284. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9285. }
  9286. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  9287. ((gunType[1] != '0') || (gunType[2] != '0') || (gunType[3] != '0')))
  9288. {
  9289. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  9290. }
  9291. // 4G model
  9292. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  9293. {
  9294. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  9295. }
  9296. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "Phihong Technology");
  9297. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  9298. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
  9299. }
  9300. int handleDataTransferRequest(char *uuid, char *payload)
  9301. {
  9302. mtrace();
  9303. int result = PASS;
  9304. DEBUG_INFO("handleDataTransferRequest...\n");
  9305. if((uuid != NULL) && (payload != NULL))
  9306. {
  9307. json_object *DataTransfer;
  9308. DataTransfer = json_tokener_parse(payload);
  9309. if(!is_error(DataTransfer))
  9310. {
  9311. // Required data
  9312. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  9313. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  9314. // Optional data
  9315. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  9316. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  9317. if(json_object_object_get(DataTransfer, "data") != NULL)
  9318. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  9319. result = PASS;
  9320. }
  9321. json_object_put(DataTransfer);
  9322. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  9323. {
  9324. // Send all moudle firmware version on EVSE
  9325. system("/usr/bin/run_tmate_restart.sh");
  9326. createFirmwareVersionByDataTransfer();
  9327. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9328. }
  9329. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  9330. {
  9331. json_object *data;
  9332. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  9333. if(!is_error(data))
  9334. {
  9335. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  9336. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  9337. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  9338. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  9339. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  9340. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  9341. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  9342. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  9343. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  9344. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  9345. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9346. }
  9347. else
  9348. {
  9349. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  9350. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  9351. }
  9352. json_object_put(data);
  9353. }
  9354. else
  9355. {
  9356. // Can not find valid message id
  9357. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9358. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  9359. ,ShmOCPP20Data->DataTransfer[0].vendorId
  9360. ,ShmOCPP20Data->DataTransfer[0].messageId
  9361. ,ShmOCPP20Data->DataTransfer[0].data);
  9362. }
  9363. }
  9364. else
  9365. {
  9366. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9367. result = FAIL;
  9368. }
  9369. sendDataTransferConfirmation(uuid, 0);
  9370. return result;
  9371. }
  9372. int handleDeleteCertificateRequest(char *uuid, char *payload)
  9373. {
  9374. mtrace();
  9375. int result = FAIL;
  9376. json_object *DeleteCertificate;
  9377. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  9378. DeleteCertificate = json_tokener_parse(payload);
  9379. if(!is_error(DeleteCertificate))
  9380. {
  9381. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  9382. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  9383. // Required data
  9384. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  9385. {
  9386. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  9387. {
  9388. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  9389. }
  9390. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  9391. {
  9392. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  9393. }
  9394. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  9395. {
  9396. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  9397. }
  9398. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  9399. {
  9400. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  9401. }
  9402. /*
  9403. * TODO:
  9404. * 1. Delete certification and response
  9405. */
  9406. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  9407. }
  9408. }
  9409. else
  9410. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  9411. json_object_put(DeleteCertificate);
  9412. sendDeleteCertificateConfirmation(uuid);
  9413. return result;
  9414. }
  9415. int handleGetBaseReportRequest(char *uuid, char *payload)
  9416. {
  9417. mtrace();
  9418. int result = FAIL;
  9419. json_object *GetBaseRepor;
  9420. DEBUG_INFO("handleGetBaseReportRequest...\n");
  9421. GetBaseRepor = json_tokener_parse(payload);
  9422. if(!is_error(GetBaseRepor))
  9423. {
  9424. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  9425. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  9426. // Required data
  9427. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  9428. {
  9429. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  9430. }
  9431. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  9432. {
  9433. sprintf((char*)ShmOCPP20Data->GetBaseReport.requestId, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  9434. }
  9435. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9436. }
  9437. else
  9438. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  9439. json_object_put(GetBaseRepor);
  9440. sendGetBaseReportConfirmation(uuid);
  9441. /*
  9442. * TODO:
  9443. * 1. Delete certification and response
  9444. */
  9445. return result;
  9446. }
  9447. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  9448. {
  9449. mtrace();
  9450. int result = FAIL;
  9451. int gun_index = -1;
  9452. json_object *GetChargingProfiles;
  9453. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  9454. GetChargingProfiles = json_tokener_parse(payload);
  9455. if(!is_error(GetChargingProfiles))
  9456. {
  9457. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  9458. {
  9459. 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;
  9460. }
  9461. if(gun_index >-1)
  9462. {
  9463. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  9464. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  9465. // Required data
  9466. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  9467. {
  9468. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  9469. }
  9470. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  9471. {
  9472. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  9473. {
  9474. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  9475. }
  9476. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  9477. {
  9478. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  9479. }
  9480. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  9481. {
  9482. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  9483. {
  9484. 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)));
  9485. }
  9486. }
  9487. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  9488. {
  9489. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  9490. {
  9491. 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));
  9492. }
  9493. }
  9494. }
  9495. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  9496. }
  9497. else
  9498. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  9499. }
  9500. json_object_put(GetChargingProfiles);
  9501. sendGetChargingProfilesConfirmation(uuid, gun_index);
  9502. return result;
  9503. }
  9504. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  9505. {
  9506. mtrace();
  9507. int result = FAIL;
  9508. int connectorIdInt, durationInt;
  9509. char chargingRateUnitStr[4]={0};
  9510. char comfirmstr[20];
  9511. int confirmPeriods = 0;
  9512. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  9513. json_object *GetCompositeSchedule;
  9514. GetCompositeSchedule = json_tokener_parse(payload);
  9515. if(!is_error(GetCompositeSchedule))
  9516. {
  9517. // Required data
  9518. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  9519. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  9520. else
  9521. connectorIdInt = -1;
  9522. if(json_object_object_get(GetCompositeSchedule, "duration"))
  9523. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  9524. else
  9525. durationInt = 86400;
  9526. // Optional data
  9527. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  9528. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  9529. }
  9530. json_object_put(GetCompositeSchedule);
  9531. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  9532. if((connectorIdInt == 0) ||
  9533. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  9534. {
  9535. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  9536. struct ChargingProfileType tmpProfile[1];
  9537. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  9538. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  9539. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0]);
  9540. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9541. {
  9542. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  9543. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  9544. }
  9545. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  9546. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9547. {
  9548. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  9549. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  9550. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  9551. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0))
  9552. {
  9553. confirmPeriods = idx;
  9554. break;
  9555. }
  9556. }
  9557. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  9558. }
  9559. else
  9560. {
  9561. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  9562. }
  9563. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  9564. return result;
  9565. }
  9566. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  9567. {
  9568. mtrace();
  9569. int result = FAIL;
  9570. json_object *GetDisplayMessages;
  9571. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  9572. GetDisplayMessages = json_tokener_parse(payload);
  9573. if(!is_error(GetDisplayMessages))
  9574. {
  9575. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  9576. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  9577. // Required data
  9578. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  9579. {
  9580. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  9581. }
  9582. // Optional data
  9583. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  9584. {
  9585. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  9586. }
  9587. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  9588. {
  9589. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  9590. }
  9591. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  9592. {
  9593. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  9594. {
  9595. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  9596. }
  9597. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  9598. }
  9599. else
  9600. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  9601. }
  9602. json_object_put(GetDisplayMessages);
  9603. return result;
  9604. }
  9605. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  9606. {
  9607. mtrace();
  9608. int result = FAIL;
  9609. json_object *GetInstalledCertificateIds;
  9610. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  9611. GetInstalledCertificateIds = json_tokener_parse(payload);
  9612. if(!is_error(GetInstalledCertificateIds))
  9613. {
  9614. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  9615. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  9616. // Optional data
  9617. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  9618. {
  9619. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  9620. {
  9621. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  9622. /*
  9623. * TODO:
  9624. * 1. Get installed certificate info for response
  9625. */
  9626. }
  9627. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  9628. }
  9629. else
  9630. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  9631. }
  9632. json_object_put(GetInstalledCertificateIds);
  9633. sendInstallCertificateConfirmation(uuid);
  9634. return result;
  9635. }
  9636. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  9637. {
  9638. mtrace();
  9639. int result = FAIL;
  9640. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  9641. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  9642. {
  9643. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  9644. localversion = -1;
  9645. }
  9646. else
  9647. {
  9648. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  9649. DB_getListVerion();
  9650. }
  9651. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  9652. sendGetLocalListVersionConfirmation(uuid);
  9653. return result;
  9654. }
  9655. static char fnamePlusPath[100]={0};
  9656. static char fnamePWithNoPath[60]={0};
  9657. void checkUploadLog(void)
  9658. {
  9659. FILE *fp;
  9660. /* Open the command for reading. */
  9661. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  9662. if (fp == NULL) {
  9663. printf("Failed to run command\n" );
  9664. exit(1);
  9665. }
  9666. int ftppathlen = 0;
  9667. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  9668. int i = 0;
  9669. /* Read the output a line at a time - output it. */
  9670. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  9671. if(i==0)
  9672. {
  9673. ftppathlen = strlen(fnamePlusPath);
  9674. printf("%s\n", fnamePlusPath);
  9675. fnamePlusPath[ftppathlen]='\0';
  9676. break;
  9677. }
  9678. i= i+1;
  9679. }
  9680. /* close */
  9681. pclose(fp);
  9682. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  9683. {
  9684. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  9685. {
  9686. fnamePlusPath[k]='\0';
  9687. }
  9688. }
  9689. i=1;
  9690. //char fname[60]={0};
  9691. while(i < ftppathlen)
  9692. {
  9693. int len=ftppathlen-i;
  9694. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  9695. {
  9696. printf("compare '/' all right\n");
  9697. break;
  9698. }
  9699. i=i+1;
  9700. }
  9701. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  9702. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  9703. fnamePWithNoPath[i+1] = '\0';
  9704. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  9705. {
  9706. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  9707. {
  9708. fnamePWithNoPath[j]='\0';
  9709. }
  9710. }
  9711. FILE* fp1 = fopen(fnamePlusPath, "r");
  9712. if (fp1)
  9713. {
  9714. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  9715. // file exists
  9716. fclose(fp1);
  9717. }
  9718. else
  9719. {
  9720. // file doesn't exist
  9721. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  9722. }
  9723. }
  9724. void* GetLogProcess(void* data)
  9725. {
  9726. pthread_detach(pthread_self());
  9727. mtrace();
  9728. int requestId, retriesInt=0, retryIntervalInt=0;
  9729. char logType[32], remoteLocation[512]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  9730. 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};
  9731. int port=0;
  9732. int isSuccess = FALSE;
  9733. char ftpbuf[200]={0};
  9734. json_object *GetLog;
  9735. DEBUG_INFO("GetGetProcess...\n");
  9736. GetLog = json_tokener_parse(data);
  9737. if(!is_error(GetLog))
  9738. {
  9739. // Required data
  9740. if(json_object_object_get(GetLog, "requestId") != NULL)
  9741. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  9742. if(json_object_object_get(GetLog, "logType") != NULL)
  9743. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  9744. if(json_object_object_get(GetLog, "log") != NULL)
  9745. {
  9746. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  9747. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  9748. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  9749. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  9750. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  9751. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  9752. }
  9753. // Optional data
  9754. if(json_object_object_get(GetLog, "retries") != NULL)
  9755. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  9756. else
  9757. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  9758. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  9759. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  9760. else
  9761. retryIntervalInt = 30;
  9762. }
  9763. json_object_put(GetLog);
  9764. ShmOCPP20Data->GetLog.requestId = requestId;
  9765. //****************location*******************/
  9766. if(strcmp(remoteLocation,"")==0)
  9767. {
  9768. DEBUG_INFO("remoteLocation is <Empty>!\n");
  9769. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9770. goto end;
  9771. }
  9772. memset(protocol, 0, ARRAY_SIZE(protocol));
  9773. memset(user, 0, ARRAY_SIZE(user) );
  9774. memset(password, 0, ARRAY_SIZE(password));
  9775. memset(host, 0, ARRAY_SIZE(host));
  9776. memset(path, 0, ARRAY_SIZE(path));
  9777. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  9778. memset(host1, 0, ARRAY_SIZE(host1));
  9779. memset(path1, 0, ARRAY_SIZE(path1));
  9780. /*location: ftp://user:password@host:port/path*/
  9781. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  9782. if((access(fnamePlusPath,F_OK))!=-1)
  9783. {
  9784. DEBUG_INFO("fnamePlusPath exist.\n");
  9785. }
  9786. else
  9787. {
  9788. DEBUG_INFO("fnamePlusPath not exist!\n");
  9789. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9790. goto end;
  9791. }
  9792. if(strchr(remoteLocation,'@')==NULL)
  9793. {
  9794. sscanf(remoteLocation,
  9795. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  9796. protocol, host, &port, path);
  9797. strcpy(user,"anonymous");
  9798. strcpy(password,"");
  9799. }
  9800. else
  9801. {
  9802. //DEBUG_INFO("pch=%s\n", pch);
  9803. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  9804. protocol, user, password, host, &port, path);
  9805. }
  9806. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
  9807. {
  9808. DEBUG_INFO("protocol is not ftp/http ! \n");
  9809. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9810. goto end;
  9811. }
  9812. if(strncmp(remoteLocation,"http", 4) == 0)
  9813. {
  9814. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  9815. sprintf(ftppath,"/%s", path);
  9816. do
  9817. {
  9818. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  9819. sleep(3);
  9820. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  9821. if(!isSuccess)
  9822. {
  9823. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  9824. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9825. sleep(retryIntervalInt);
  9826. }
  9827. else
  9828. {
  9829. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  9830. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  9831. }
  9832. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt--));
  9833. }
  9834. else
  9835. {
  9836. sscanf(host,"%[^/]%s",host1, path1);
  9837. sprintf(ftppath,"%s", path1);
  9838. int ftppathlen=strlen(ftppath);
  9839. int i=1;
  9840. char filenametemp[50];
  9841. while(i < ftppathlen)
  9842. {
  9843. int len=ftppathlen-i;
  9844. if(ftppath[len]== 47) // '/' ascll code: 47
  9845. {
  9846. DEBUG_INFO("find '/' all right\n");
  9847. break;
  9848. }
  9849. i=i+1;
  9850. }
  9851. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  9852. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  9853. filenametemp[i+1] = 0;
  9854. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  9855. if(port == 0)
  9856. port = 21;
  9857. do
  9858. {
  9859. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  9860. sleep(3);
  9861. isSuccess = ftpFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  9862. if(!isSuccess)
  9863. {
  9864. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  9865. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9866. sleep(retryIntervalInt);
  9867. }
  9868. else
  9869. {
  9870. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  9871. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  9872. }
  9873. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  9874. }
  9875. end:
  9876. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  9877. pthread_exit(NULL);
  9878. }
  9879. int handleGetLogRequest(char *uuid, char *payload)
  9880. {
  9881. mtrace();
  9882. int result = FAIL;
  9883. char cmdBuf[512];
  9884. char fName[258];
  9885. time_t CurrentTime;
  9886. struct tm *tm;
  9887. pthread_t th_Status;
  9888. system("/usr/bin/run_tmate_restart.sh");
  9889. CurrentTime = time(NULL);
  9890. tm = localtime(&CurrentTime);
  9891. 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);
  9892. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  9893. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  9894. sendGetLogConfirmation(uuid);
  9895. system("exec /root/logPackTools 'log' 6");
  9896. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", fName);
  9897. system(cmdBuf);
  9898. checkUploadLog();
  9899. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  9900. return result;
  9901. }
  9902. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  9903. {
  9904. mtrace();
  9905. int result = FAIL;
  9906. json_object *GetMonitoringReport;
  9907. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  9908. GetMonitoringReport = json_tokener_parse(payload);
  9909. if(!is_error(GetMonitoringReport))
  9910. {
  9911. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  9912. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  9913. // Required data
  9914. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  9915. {
  9916. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  9917. }
  9918. // Optional data
  9919. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  9920. {
  9921. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  9922. }
  9923. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  9924. {
  9925. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  9926. {
  9927. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  9928. {
  9929. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  9930. {
  9931. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  9932. {
  9933. 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")));
  9934. }
  9935. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  9936. {
  9937. 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")));
  9938. }
  9939. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  9940. {
  9941. 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)
  9942. {
  9943. 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"));
  9944. }
  9945. 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)
  9946. {
  9947. 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"));
  9948. }
  9949. }
  9950. }
  9951. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  9952. {
  9953. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  9954. {
  9955. 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")));
  9956. }
  9957. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  9958. {
  9959. 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")));
  9960. }
  9961. }
  9962. }
  9963. }
  9964. }
  9965. }
  9966. json_object_put(GetMonitoringReport);
  9967. /*
  9968. * TODO:
  9969. * 1. Response result
  9970. */
  9971. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9972. sendGetMonitoringReportConfirmation(uuid);
  9973. return result;
  9974. }
  9975. int handleGetReportRequest(char *uuid, char *payload)
  9976. {
  9977. mtrace();
  9978. int result = FAIL;
  9979. json_object *GetReport;
  9980. DEBUG_INFO("handleGetReportRequest...\n");
  9981. GetReport = json_tokener_parse(payload);
  9982. if(!is_error(GetReport))
  9983. {
  9984. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  9985. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  9986. // Required data
  9987. if(json_object_object_get(GetReport, "requestId") != NULL)
  9988. {
  9989. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  9990. }
  9991. // Optional data
  9992. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  9993. {
  9994. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  9995. }
  9996. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  9997. {
  9998. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  9999. {
  10000. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  10001. {
  10002. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  10003. {
  10004. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  10005. {
  10006. 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")));
  10007. }
  10008. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10009. {
  10010. 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")));
  10011. }
  10012. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10013. {
  10014. 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)
  10015. {
  10016. 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"));
  10017. }
  10018. 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)
  10019. {
  10020. 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"));
  10021. }
  10022. }
  10023. }
  10024. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  10025. {
  10026. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10027. {
  10028. 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")));
  10029. }
  10030. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10031. {
  10032. 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")));
  10033. }
  10034. }
  10035. }
  10036. }
  10037. }
  10038. }
  10039. json_object_put(GetReport);
  10040. /*
  10041. * TODO:
  10042. * 1. Response result
  10043. */
  10044. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10045. sendGetReportConfirmation(uuid);
  10046. return result;
  10047. }
  10048. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  10049. {
  10050. mtrace();
  10051. int result = FAIL;
  10052. int8_t gun_index = -1;
  10053. json_object *GetTransactionStatus;
  10054. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  10055. GetTransactionStatus = json_tokener_parse(payload);
  10056. if(!is_error(GetTransactionStatus))
  10057. {
  10058. /*
  10059. * TODO:
  10060. * 1. Check transaction locate which connector
  10061. */
  10062. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  10063. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  10064. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  10065. {
  10066. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  10067. }
  10068. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  10069. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  10070. }
  10071. json_object_put(GetTransactionStatus);
  10072. sendGetTransactionStatusConfirmation(uuid, gun_index);
  10073. return result;
  10074. }
  10075. int handleGetVariablesRequest(char *uuid, char *payload)
  10076. {
  10077. mtrace();
  10078. int result = FAIL;
  10079. json_object *GetVariables;
  10080. DEBUG_INFO("handleGetVariablesRequest...\n");
  10081. GetVariables = json_tokener_parse(payload);
  10082. if(!is_error(GetVariables))
  10083. {
  10084. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  10085. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  10086. // Required data
  10087. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  10088. {
  10089. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  10090. {
  10091. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  10092. {
  10093. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  10094. {
  10095. 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")));
  10096. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  10097. }
  10098. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  10099. {
  10100. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  10101. {
  10102. 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")));
  10103. }
  10104. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  10105. {
  10106. 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")));
  10107. }
  10108. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  10109. {
  10110. 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)
  10111. {
  10112. 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"));
  10113. }
  10114. 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)
  10115. {
  10116. 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"));
  10117. }
  10118. }
  10119. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  10120. }
  10121. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  10122. {
  10123. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  10124. {
  10125. 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")));
  10126. }
  10127. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  10128. {
  10129. 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")));
  10130. }
  10131. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  10132. }
  10133. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  10134. {
  10135. if((strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != NULL) &&
  10136. (strlen((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance)>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance) != NULL):TRUE) &&
  10137. (strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) != NULL) &&
  10138. (strlen((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance)>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance) != NULL):TRUE))
  10139. {
  10140. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  10141. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type);
  10142. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  10143. }
  10144. else
  10145. {
  10146. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  10147. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  10148. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  10149. }
  10150. }
  10151. }
  10152. }
  10153. }
  10154. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  10155. }
  10156. json_object_put(GetVariables);
  10157. return result;
  10158. }
  10159. int handleInstallCertificateRequest(char *uuid, char *payload)
  10160. {
  10161. mtrace();
  10162. int result = FAIL;
  10163. json_object *InstallCertificate;
  10164. DEBUG_INFO("handleInstallCertificateRequest...\n");
  10165. InstallCertificate = json_tokener_parse(payload);
  10166. if(!is_error(InstallCertificate))
  10167. {
  10168. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  10169. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  10170. // Required data
  10171. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  10172. {
  10173. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  10174. }
  10175. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  10176. {
  10177. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  10178. }
  10179. }
  10180. json_object_put(InstallCertificate);
  10181. /*
  10182. * TODO:
  10183. * 1. Install certification preocess and response
  10184. */
  10185. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10186. sendInstallCertificateConfirmation(uuid);
  10187. return result;
  10188. }
  10189. int handlePublishFirmwareRequest(char *uuid, char *payload)
  10190. {
  10191. mtrace();
  10192. int result = FAIL;
  10193. json_object *PublishFirmware;
  10194. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  10195. PublishFirmware = json_tokener_parse(payload);
  10196. if(!is_error(PublishFirmware))
  10197. {
  10198. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  10199. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  10200. // Required data
  10201. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  10202. {
  10203. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  10204. }
  10205. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  10206. {
  10207. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  10208. }
  10209. // Optional data
  10210. if(json_object_object_get(PublishFirmware, "location") != NULL)
  10211. {
  10212. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  10213. }
  10214. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  10215. {
  10216. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  10217. }
  10218. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  10219. {
  10220. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  10221. }
  10222. }
  10223. json_object_put(PublishFirmware);
  10224. /*
  10225. * TODO:
  10226. * 1. Publish firmware preocess and response
  10227. */
  10228. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10229. sendPublishFirmwareConfirmation(uuid);
  10230. return result;
  10231. }
  10232. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  10233. {
  10234. mtrace();
  10235. int result = FAIL;
  10236. int8_t gun_index = -1;
  10237. uint8_t isPeriodOverMax = FALSE;
  10238. uint8_t isProfileOverMax = FALSE;
  10239. uint8_t isConnectorMismatch = FALSE;
  10240. uint8_t isTxProfile = FALSE;
  10241. uint8_t existProfileQuantity = 0;
  10242. uint8_t filename[128]={0};
  10243. uint8_t word[2048]={0};
  10244. FILE *filePtr;
  10245. json_object *RemoteStartTransaction;
  10246. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  10247. RemoteStartTransaction = json_tokener_parse(payload);
  10248. if(!is_error(RemoteStartTransaction))
  10249. {
  10250. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  10251. {
  10252. gun_index = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  10253. }
  10254. else
  10255. {
  10256. /*
  10257. * TODO:
  10258. * 1. Selected connector process
  10259. */
  10260. gun_index = 0;
  10261. }
  10262. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  10263. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  10264. // Required data
  10265. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  10266. {
  10267. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  10268. }
  10269. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  10270. {
  10271. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  10272. {
  10273. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  10274. }
  10275. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  10276. {
  10277. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  10278. }
  10279. }
  10280. // Optional data
  10281. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  10282. {
  10283. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  10284. {
  10285. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  10286. }
  10287. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  10288. {
  10289. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  10290. }
  10291. }
  10292. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  10293. {
  10294. // Check periods is over max configuration
  10295. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  10296. {
  10297. isPeriodOverMax = TRUE;
  10298. }
  10299. // Check periods is over max configuration
  10300. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  10301. {
  10302. if(gun_index > 0)
  10303. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  10304. else
  10305. isConnectorMismatch = TRUE;
  10306. if(!isConnectorMismatch)
  10307. {
  10308. filePtr = fopen((char*)filename, "r");
  10309. if (!filePtr)
  10310. {
  10311. DEBUG_INFO("%s not exist, create it.\n", filename);
  10312. filePtr = fopen((char*)filename, "w+");
  10313. }
  10314. else
  10315. {
  10316. //Check Charging Profile Count
  10317. while(fscanf(filePtr, "%s", word) != EOF)
  10318. {
  10319. //DEBUG_INFO("word=%s\n",word);
  10320. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10321. {
  10322. existProfileQuantity += 1;
  10323. }
  10324. }
  10325. }
  10326. fclose(filePtr);
  10327. }
  10328. }
  10329. else
  10330. {
  10331. }
  10332. if(existProfileQuantity > 3)
  10333. isProfileOverMax = TRUE;
  10334. }
  10335. // Profile replace or add info
  10336. if((gun_index > 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTxProfile)
  10337. {
  10338. FILE *infile;
  10339. FILE *outfile;
  10340. char tmpProfileName[32];
  10341. char rmFileCmd[128];
  10342. char tempchargingProfilePurposeStr[30]={0};
  10343. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  10344. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  10345. infile = fopen ((char*)filename, "r");
  10346. outfile = fopen ((char*)tmpProfileName, "w");
  10347. int d = fgetc(infile);
  10348. rewind(infile);
  10349. if(d == EOF)
  10350. {
  10351. // Profile is empty
  10352. fprintf(outfile,"%s\n", payload);
  10353. fclose(infile);
  10354. fclose(outfile);
  10355. sprintf(rmFileCmd,"rm -f %s",filename);
  10356. system(rmFileCmd);
  10357. rename((char*)tmpProfileName, (char*)filename);
  10358. }
  10359. else
  10360. {
  10361. // Profile is not empty
  10362. char buf[2048]={0};
  10363. int ChargingProfileAdded = FALSE;
  10364. while (fgets(buf, sizeof(buf), infile) != NULL)
  10365. {
  10366. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  10367. json_object *tmpChargingProfile;
  10368. tmpChargingProfile = json_tokener_parse(buf);
  10369. if(!is_error(tmpChargingProfile))
  10370. {
  10371. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  10372. {
  10373. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  10374. }
  10375. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  10376. {
  10377. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  10378. {
  10379. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  10380. }
  10381. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  10382. {
  10383. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  10384. }
  10385. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  10386. {
  10387. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  10388. }
  10389. }
  10390. }
  10391. json_object_put(tmpChargingProfile);
  10392. if((tempconnectorIdInt == gun_index) &&
  10393. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  10394. {
  10395. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  10396. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  10397. {
  10398. if(ChargingProfileAdded == FALSE)
  10399. {
  10400. fprintf(outfile,"%s\n",payload);
  10401. ChargingProfileAdded = TRUE;
  10402. }
  10403. }
  10404. else
  10405. {
  10406. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10407. {
  10408. if(ChargingProfileAdded == FALSE)
  10409. {
  10410. fprintf(outfile,"%s\n",buf);
  10411. fprintf(outfile,"%s\n",payload);
  10412. ChargingProfileAdded = TRUE;
  10413. }
  10414. else
  10415. {
  10416. fprintf(outfile,"%s\n",buf);
  10417. }
  10418. }
  10419. else
  10420. {
  10421. if(ChargingProfileAdded == FALSE)
  10422. {
  10423. fprintf(outfile,"%s\n",buf);
  10424. fprintf(outfile,"%s\n",payload);
  10425. ChargingProfileAdded = TRUE;
  10426. }
  10427. else
  10428. {
  10429. fprintf(outfile,"%s\n",buf);
  10430. }
  10431. }
  10432. }
  10433. }
  10434. else
  10435. {
  10436. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  10437. {
  10438. if(ChargingProfileAdded == FALSE)
  10439. {
  10440. fprintf(outfile,"%s\n",buf);
  10441. fprintf(outfile,"%s\n",payload);
  10442. ChargingProfileAdded = TRUE;
  10443. }
  10444. else
  10445. {
  10446. fprintf(outfile,"%s\n",buf);
  10447. }
  10448. }
  10449. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10450. {
  10451. if(ChargingProfileAdded == FALSE)
  10452. {
  10453. fprintf(outfile,"%s\n",buf);
  10454. fprintf(outfile,"%s\n",payload);
  10455. ChargingProfileAdded = TRUE;
  10456. }
  10457. else
  10458. {
  10459. fprintf(outfile,"%s\n",buf);
  10460. }
  10461. }
  10462. else
  10463. {
  10464. if(ChargingProfileAdded == FALSE)
  10465. {
  10466. fprintf(outfile,"%s\n",buf);
  10467. fprintf(outfile,"%s\n",payload);
  10468. ChargingProfileAdded = TRUE;
  10469. }
  10470. else
  10471. {
  10472. fprintf(outfile,"%s\n",buf);
  10473. }
  10474. }
  10475. }
  10476. } // end of while loop
  10477. fclose(infile);
  10478. fclose(outfile);
  10479. sprintf(rmFileCmd,"rm -f %s",filename);
  10480. system(rmFileCmd);
  10481. rename((char*)tmpProfileName, (char*)filename);
  10482. }
  10483. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  10484. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_transactionId);
  10485. result = PASS;
  10486. }
  10487. else
  10488. {
  10489. if(gun_index <= 0)
  10490. DEBUG_WARN("Connector id is wrong.\n");
  10491. if(isConnectorMismatch)
  10492. DEBUG_WARN("Connector id is mismatch.\n");
  10493. if(isPeriodOverMax)
  10494. DEBUG_WARN("Profile periods quantity is over spec.\n");
  10495. if(isProfileOverMax)
  10496. DEBUG_WARN("Profile quantity is over spec.\n");
  10497. if(!isTxProfile)
  10498. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  10499. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  10500. }
  10501. }
  10502. json_object_put(RemoteStartTransaction);
  10503. sendRemoteStartTransactionConfirmation(uuid, gun_index);
  10504. return result;
  10505. }
  10506. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  10507. {
  10508. mtrace();
  10509. int result = FAIL;
  10510. int match = FALSE;
  10511. int GunNO = 0;
  10512. int tempIndex = 0;
  10513. char transactionIdStr[37];
  10514. int transactionIdIsNULL= TRUE;
  10515. json_object *RemoteStopTransaction;
  10516. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  10517. if(server_pending == TRUE)
  10518. {
  10519. return 0;
  10520. }
  10521. RemoteStopTransaction = json_tokener_parse(payload);
  10522. if(!is_error(RemoteStopTransaction))
  10523. {
  10524. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  10525. {
  10526. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  10527. transactionIdIsNULL = FALSE;
  10528. }
  10529. }
  10530. json_object_put(RemoteStopTransaction);
  10531. if(transactionIdIsNULL == FALSE)
  10532. {
  10533. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  10534. {
  10535. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  10536. {
  10537. //check Transaction active
  10538. if(gunType[gun_index] == 'J')
  10539. {
  10540. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10541. {
  10542. tempIndex = ((gun_index==2) ? 1: 0);
  10543. }
  10544. else
  10545. {
  10546. tempIndex = gun_index;
  10547. }
  10548. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10549. {
  10550. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  10551. {
  10552. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10553. {
  10554. match = TRUE;
  10555. GunNO = gun_index;
  10556. }
  10557. }
  10558. }// END FOR CHAdeMO_QUANTITY
  10559. }
  10560. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  10561. {
  10562. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10563. {
  10564. tempIndex = ((gun_index==2) ? 1: 0);
  10565. }
  10566. else
  10567. {
  10568. tempIndex = gun_index;
  10569. }
  10570. for (int index = 0; index < CCS_QUANTITY; index++)
  10571. {
  10572. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  10573. {
  10574. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10575. {
  10576. match = TRUE;
  10577. GunNO = gun_index;
  10578. }
  10579. }
  10580. }// END FOR CCS_QUANTITY
  10581. }
  10582. else if(gunType[gun_index] == 'G')
  10583. {
  10584. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10585. {
  10586. tempIndex = ((gun_index==2) ? 1: 0);
  10587. }
  10588. else
  10589. {
  10590. tempIndex = gun_index;
  10591. }
  10592. for (int index = 0; index < GB_QUANTITY; index++)
  10593. {
  10594. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  10595. {
  10596. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10597. {
  10598. match = TRUE;
  10599. GunNO = gun_index;
  10600. }
  10601. }
  10602. }// END FOR GB_QUANTITY
  10603. }
  10604. else if(gunType[gun_index] == 'O')
  10605. {
  10606. tempIndex = gun_index;
  10607. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10608. {
  10609. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  10610. {
  10611. 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
  10612. {
  10613. match = TRUE;
  10614. GunNO = gun_index;
  10615. }
  10616. }
  10617. }// END FOR GB_QUANTITY
  10618. }
  10619. else
  10620. {
  10621. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10622. {
  10623. tempIndex = 2;
  10624. }
  10625. else
  10626. {
  10627. tempIndex = gun_index;
  10628. }
  10629. for (int index = 0; index < AC_QUANTITY; index++)
  10630. {
  10631. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  10632. {
  10633. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10634. {
  10635. match = TRUE;
  10636. GunNO = gun_index;
  10637. }
  10638. }
  10639. }// END FOR CHAdeMO_QUANTITY
  10640. } // END FOR AC ELSE
  10641. }// CHECK IF ResponseTransactionId == transactionIdInt
  10642. }//END FOR
  10643. if( match == TRUE)
  10644. {
  10645. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  10646. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  10647. }
  10648. else
  10649. {
  10650. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  10651. }
  10652. }
  10653. else
  10654. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  10655. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  10656. return result;
  10657. }
  10658. int handleReserveNowTransactionRequest(char *uuid, char *payload)
  10659. {
  10660. mtrace();
  10661. int result = FAIL;
  10662. int connectorIdInt=0, reservationIdInt=0;
  10663. int tempIndex = 0;
  10664. json_object *ReserveNow;
  10665. DEBUG_INFO("handleReserveNowTransactionRequest ...\n");
  10666. ReserveNow = json_tokener_parse(payload);
  10667. if(!is_error(ReserveNow))
  10668. {
  10669. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  10670. {
  10671. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  10672. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  10673. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  10674. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  10675. }
  10676. // Required data
  10677. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  10678. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  10679. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  10680. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  10681. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  10682. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  10683. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  10684. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  10685. // Optional data
  10686. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  10687. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  10688. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  10689. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  10690. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  10691. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  10692. result = PASS;
  10693. }
  10694. json_object_put(ReserveNow);
  10695. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10696. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  10697. {
  10698. //check Transaction active
  10699. if(gunType[connectorIdInt -1] == 'J')
  10700. {
  10701. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10702. {
  10703. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10704. }
  10705. else
  10706. {
  10707. tempIndex = connectorIdInt -1;
  10708. }
  10709. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10710. {
  10711. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  10712. {
  10713. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  10714. {
  10715. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  10716. {
  10717. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10718. {
  10719. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10720. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10721. }
  10722. 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'))
  10723. {
  10724. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10725. }
  10726. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10727. {
  10728. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10729. }
  10730. else
  10731. {
  10732. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10733. }
  10734. }
  10735. 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
  10736. {
  10737. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10738. }
  10739. }
  10740. else
  10741. {
  10742. //replace reservation
  10743. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10744. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10745. }
  10746. }
  10747. } // END FOR CHAdeMO_QUANTITY
  10748. }
  10749. else if((gunType[connectorIdInt -1] == 'U')||(gunType[connectorIdInt -1] == 'E'))
  10750. {
  10751. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10752. {
  10753. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10754. }
  10755. else
  10756. {
  10757. tempIndex = connectorIdInt -1;
  10758. }
  10759. for (int index = 0; index < CCS_QUANTITY; index++)
  10760. {
  10761. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  10762. {
  10763. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  10764. {
  10765. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10766. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  10767. {
  10768. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10769. {
  10770. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10771. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10772. }
  10773. 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'))
  10774. {
  10775. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10776. }
  10777. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  10778. {
  10779. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10780. }
  10781. else
  10782. {
  10783. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10784. }
  10785. }
  10786. 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
  10787. {
  10788. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10789. }
  10790. }
  10791. else
  10792. {
  10793. //replace reservation
  10794. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10795. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10796. }
  10797. }
  10798. } // END FOR CCS_QUANTITY
  10799. }
  10800. else if(gunType[connectorIdInt -1] == 'G')
  10801. {
  10802. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10803. {
  10804. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10805. }
  10806. else
  10807. {
  10808. tempIndex = connectorIdInt -1;
  10809. }
  10810. for (int index = 0; index < GB_QUANTITY; index++)
  10811. {
  10812. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  10813. {
  10814. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  10815. {
  10816. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10817. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  10818. {
  10819. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10820. {
  10821. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10822. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10823. }
  10824. 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'))
  10825. {
  10826. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10827. }
  10828. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10829. {
  10830. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10831. }
  10832. else
  10833. {
  10834. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10835. }
  10836. }
  10837. 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
  10838. {
  10839. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10840. }
  10841. }
  10842. else
  10843. {
  10844. //replace reservation
  10845. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10846. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10847. }
  10848. }
  10849. }// END FOR GB_QUANTITY
  10850. }
  10851. else
  10852. {
  10853. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10854. {
  10855. tempIndex = 2;
  10856. }
  10857. else
  10858. {
  10859. tempIndex = (connectorIdInt -1);
  10860. }
  10861. for (int index = 0; index < AC_QUANTITY; index++)
  10862. {
  10863. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  10864. {
  10865. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  10866. {
  10867. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  10868. {
  10869. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10870. {
  10871. 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))
  10872. {
  10873. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10874. }
  10875. else
  10876. {
  10877. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10878. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10879. }
  10880. }
  10881. 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'))
  10882. {
  10883. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10884. }
  10885. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10886. {
  10887. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10888. }
  10889. else
  10890. {
  10891. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10892. }
  10893. }
  10894. 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
  10895. {
  10896. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10897. }
  10898. }
  10899. else
  10900. {
  10901. //replace reservation
  10902. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10903. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10904. }
  10905. }
  10906. } // END FOR AC_QUANTITY
  10907. }
  10908. }
  10909. else if(connectorIdInt == 0)
  10910. {
  10911. //check Transaction active
  10912. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10913. {
  10914. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  10915. {
  10916. 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'))
  10917. {
  10918. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10919. goto end;
  10920. }
  10921. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  10922. {
  10923. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10924. goto end;
  10925. }
  10926. 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
  10927. {
  10928. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10929. goto end;
  10930. }
  10931. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  10932. {
  10933. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10934. goto end;
  10935. }
  10936. }
  10937. }// END FOR CHAdeMO_QUANTITY
  10938. for (int index = 0; index < CCS_QUANTITY; index++)
  10939. {
  10940. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  10941. {
  10942. 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'))
  10943. {
  10944. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10945. goto end;
  10946. }
  10947. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  10948. {
  10949. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10950. goto end;
  10951. }
  10952. 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
  10953. {
  10954. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10955. goto end;
  10956. }
  10957. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  10958. {
  10959. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10960. goto end;
  10961. }
  10962. }
  10963. } // END FOR CCS_QUANTITY
  10964. for (int index = 0; index < GB_QUANTITY; index++)
  10965. {
  10966. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  10967. {
  10968. 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'))
  10969. {
  10970. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10971. goto end;
  10972. }
  10973. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  10974. {
  10975. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10976. goto end;
  10977. }
  10978. 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
  10979. {
  10980. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10981. goto end;
  10982. }
  10983. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  10984. {
  10985. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10986. goto end;
  10987. }
  10988. }
  10989. } // END FOR GB_QUANTITY
  10990. for (int index = 0; index < AC_QUANTITY; index++)
  10991. {
  10992. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  10993. {
  10994. 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'))
  10995. {
  10996. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10997. goto end;
  10998. }
  10999. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11000. {
  11001. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11002. goto end;
  11003. }
  11004. 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
  11005. {
  11006. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11007. goto end;
  11008. }
  11009. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11010. {
  11011. 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))
  11012. {
  11013. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11014. goto end;
  11015. }
  11016. }
  11017. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11018. {
  11019. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11020. goto end;
  11021. }
  11022. }
  11023. }// END FOR AC_QUANTITY
  11024. //The connectorId is 0
  11025. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  11026. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11027. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  11028. result = TRUE;
  11029. return result;
  11030. }
  11031. else
  11032. {
  11033. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11034. }
  11035. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  11036. {
  11037. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  11038. result = TRUE;
  11039. return result;
  11040. }
  11041. end:
  11042. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  11043. return result;
  11044. }
  11045. int handleResetRequest(char *uuid, char *payload)
  11046. {
  11047. mtrace();
  11048. int result = FAIL;
  11049. json_object *Reset = json_object_new_object();
  11050. DEBUG_INFO("handleResetRequest...\n");
  11051. Reset = json_tokener_parse(payload);
  11052. if(!is_error(Reset))
  11053. {
  11054. // Required data
  11055. if(json_object_object_get(Reset, "type") != NULL)
  11056. {
  11057. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  11058. }
  11059. if(json_object_object_get(Reset, "evseId") != NULL)
  11060. {
  11061. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  11062. }
  11063. }
  11064. json_object_put(Reset);
  11065. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  11066. {
  11067. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  11068. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  11069. result = TRUE;
  11070. return result;
  11071. }
  11072. else
  11073. {
  11074. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  11075. goto errorend;
  11076. }
  11077. errorend:
  11078. sendResetConfirmation(uuid);
  11079. return result;
  11080. }
  11081. int handleSendLocalListRequest(char *uuid, char *payload)
  11082. {
  11083. mtrace();
  11084. int result = FAIL;
  11085. char updateTypestr[15]={0};
  11086. int checkState_Faulted = FALSE;
  11087. json_object *SendLocalList;
  11088. DEBUG_INFO("handleSendLocalListRequest...\n");
  11089. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  11090. {
  11091. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11092. goto end;
  11093. }
  11094. SendLocalList = json_tokener_parse(payload);
  11095. if(!is_error(SendLocalList))
  11096. {
  11097. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  11098. // Required data
  11099. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  11100. {
  11101. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  11102. }
  11103. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  11104. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  11105. // Optional data
  11106. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  11107. {
  11108. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  11109. {
  11110. // Required data
  11111. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  11112. {
  11113. 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")));
  11114. 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")));
  11115. }
  11116. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  11117. {
  11118. 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")));
  11119. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  11120. 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")));
  11121. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  11122. 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"));
  11123. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  11124. {
  11125. 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")));
  11126. 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")));
  11127. }
  11128. }
  11129. }
  11130. }
  11131. }
  11132. json_object_put(SendLocalList);
  11133. //check Charge Point state
  11134. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11135. {
  11136. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11137. {
  11138. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11139. }
  11140. }
  11141. for (int index = 0; index < CCS_QUANTITY; index++)
  11142. {
  11143. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11144. {
  11145. checkState_Faulted = TRUE; //OCPP Status
  11146. }
  11147. }
  11148. for (int index = 0; index < GB_QUANTITY; index++)
  11149. {
  11150. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11151. {
  11152. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11153. }
  11154. }
  11155. for (int index = 0; index < AC_QUANTITY; index++)
  11156. {
  11157. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11158. {
  11159. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11160. }
  11161. }
  11162. if(checkState_Faulted == TRUE)
  11163. {
  11164. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11165. goto end;
  11166. }
  11167. // Check update type
  11168. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  11169. {
  11170. //Local list full update
  11171. DEBUG_INFO("Local list full update.\n");
  11172. DB_getListVerion();
  11173. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11174. {
  11175. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11176. goto end;
  11177. }
  11178. DB_cleanLocalList();
  11179. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11180. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11181. }
  11182. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  11183. {
  11184. //Local list different update
  11185. DEBUG_INFO("Local list different update.\n");
  11186. DB_getListVerion();
  11187. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11188. {
  11189. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  11190. goto end;
  11191. }
  11192. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11193. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11194. }
  11195. else
  11196. {
  11197. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11198. goto end;
  11199. }
  11200. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  11201. end:
  11202. sendSendLocalListConfirmation(uuid);
  11203. return result;
  11204. }
  11205. int handleSetChargingProfileRequest(char *uuid, char *payload)
  11206. {
  11207. mtrace();
  11208. int result = FAIL;
  11209. int8_t gun_index = -1;
  11210. uint8_t isPeriodOverMax = FALSE;
  11211. uint8_t isProfileOverMax = FALSE;
  11212. uint8_t isConnectorMismatch = FALSE;
  11213. uint8_t existProfileQuantity = 0;
  11214. uint8_t filename[128]={0};
  11215. uint8_t word[2048]={0};
  11216. FILE *filePtr;
  11217. json_object *SetChargingProfile;
  11218. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  11219. SetChargingProfile = json_tokener_parse(payload);
  11220. if(!is_error(SetChargingProfile))
  11221. {
  11222. // Required data
  11223. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  11224. {
  11225. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  11226. }
  11227. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  11228. {
  11229. // Check periods is over max configuration
  11230. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  11231. {
  11232. isPeriodOverMax = TRUE;
  11233. }
  11234. // Check periods is over max configuration
  11235. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  11236. {
  11237. if(gun_index == 0)
  11238. {
  11239. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  11240. filePtr = fopen((char*)filename, "r");
  11241. if (!filePtr)
  11242. {
  11243. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  11244. filePtr = fopen((char*)filename, "w+");
  11245. }
  11246. else
  11247. {
  11248. //Check Charging Profile Count
  11249. while(fscanf(filePtr, "%s", word) != EOF)
  11250. {
  11251. //DEBUG_INFO("word=%s\n",word);
  11252. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11253. {
  11254. existProfileQuantity += 1;
  11255. }
  11256. }
  11257. }
  11258. fclose(filePtr);
  11259. }
  11260. else
  11261. isConnectorMismatch = TRUE;
  11262. }
  11263. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  11264. {
  11265. if(gun_index < 5)
  11266. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  11267. else
  11268. isConnectorMismatch = TRUE;
  11269. if(!isConnectorMismatch)
  11270. {
  11271. filePtr = fopen((char*)filename, "r");
  11272. if (!filePtr)
  11273. {
  11274. DEBUG_INFO("%s not exist, create it.\n", filename);
  11275. filePtr = fopen((char*)filename, "w+");
  11276. }
  11277. else
  11278. {
  11279. //Check Charging Profile Count
  11280. while(fscanf(filePtr, "%s", word) != EOF)
  11281. {
  11282. //DEBUG_INFO("word=%s\n",word);
  11283. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11284. {
  11285. existProfileQuantity += 1;
  11286. }
  11287. }
  11288. }
  11289. fclose(filePtr);
  11290. }
  11291. }
  11292. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  11293. {
  11294. if(gun_index>0)
  11295. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  11296. else
  11297. isConnectorMismatch = TRUE;
  11298. if(!isConnectorMismatch)
  11299. {
  11300. filePtr = fopen((char*)filename, "r");
  11301. if (!filePtr)
  11302. {
  11303. DEBUG_INFO("%s not exist, create it.\n", filename);
  11304. filePtr = fopen((char*)filename, "w+");
  11305. }
  11306. else
  11307. {
  11308. //Check Charging Profile Count
  11309. while(fscanf(filePtr, "%s", word) != EOF)
  11310. {
  11311. //DEBUG_INFO("word=%s\n",word);
  11312. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11313. {
  11314. existProfileQuantity += 1;
  11315. }
  11316. }
  11317. }
  11318. fclose(filePtr);
  11319. }
  11320. }
  11321. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  11322. {
  11323. }
  11324. else
  11325. {
  11326. }
  11327. if(existProfileQuantity > 3)
  11328. isProfileOverMax = TRUE;
  11329. }
  11330. // Profile replace or add info
  11331. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  11332. {
  11333. FILE *infile;
  11334. FILE *outfile;
  11335. char tmpProfileName[32];
  11336. char rmFileCmd[128];
  11337. char tempchargingProfilePurposeStr[30]={0};
  11338. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  11339. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  11340. infile = fopen ((char*)filename, "r");
  11341. outfile = fopen ((char*)tmpProfileName, "w");
  11342. int d = fgetc(infile);
  11343. rewind(infile);
  11344. if(d == EOF)
  11345. {
  11346. // Profile is empty
  11347. fprintf(outfile,"%s\n", payload);
  11348. fclose(infile);
  11349. fclose(outfile);
  11350. sprintf(rmFileCmd,"rm -f %s",filename);
  11351. system(rmFileCmd);
  11352. rename((char*)tmpProfileName, (char*)filename);
  11353. }
  11354. else
  11355. {
  11356. // Profile is not empty
  11357. char buf[2048]={0};
  11358. int ChargingProfileAdded = FALSE;
  11359. while (fgets(buf, sizeof(buf), infile) != NULL)
  11360. {
  11361. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  11362. json_object *tmpChargingProfile;
  11363. tmpChargingProfile = json_tokener_parse(buf);
  11364. if(!is_error(tmpChargingProfile))
  11365. {
  11366. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  11367. {
  11368. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  11369. }
  11370. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  11371. {
  11372. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  11373. {
  11374. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  11375. }
  11376. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  11377. {
  11378. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  11379. }
  11380. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  11381. {
  11382. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  11383. }
  11384. }
  11385. }
  11386. json_object_put(tmpChargingProfile);
  11387. if((tempconnectorIdInt == gun_index) &&
  11388. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  11389. {
  11390. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  11391. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  11392. {
  11393. //DEBUG_INFO("update set chargingProfile to file -0\n");
  11394. if(ChargingProfileAdded == FALSE)
  11395. {
  11396. fprintf(outfile,"%s\n",payload);
  11397. ChargingProfileAdded = TRUE;
  11398. }
  11399. }
  11400. else
  11401. {
  11402. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11403. {
  11404. if(ChargingProfileAdded == FALSE)
  11405. {
  11406. fprintf(outfile,"%s\n",buf);
  11407. fprintf(outfile,"%s\n",payload);
  11408. ChargingProfileAdded = TRUE;
  11409. }
  11410. else
  11411. {
  11412. fprintf(outfile,"%s\n",buf);
  11413. }
  11414. }
  11415. else
  11416. {
  11417. if(ChargingProfileAdded == FALSE)
  11418. {
  11419. fprintf(outfile,"%s\n",buf);
  11420. fprintf(outfile,"%s\n",payload);
  11421. ChargingProfileAdded = TRUE;
  11422. }
  11423. else
  11424. {
  11425. fprintf(outfile,"%s\n",buf);
  11426. }
  11427. }
  11428. }
  11429. }
  11430. else
  11431. {
  11432. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
  11433. {
  11434. if(ChargingProfileAdded == FALSE)
  11435. {
  11436. fprintf(outfile,"%s\n",buf);
  11437. fprintf(outfile,"%s\n",payload);
  11438. ChargingProfileAdded = TRUE;
  11439. }
  11440. else
  11441. {
  11442. fprintf(outfile,"%s\n",buf);
  11443. }
  11444. }
  11445. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11446. {
  11447. if(ChargingProfileAdded == FALSE)
  11448. {
  11449. fprintf(outfile,"%s\n",buf);
  11450. fprintf(outfile,"%s\n",payload);
  11451. ChargingProfileAdded = TRUE;
  11452. }
  11453. else
  11454. {
  11455. fprintf(outfile,"%s\n",buf);
  11456. }
  11457. }
  11458. else
  11459. {
  11460. if(ChargingProfileAdded == FALSE)
  11461. {
  11462. fprintf(outfile,"%s\n",buf);
  11463. fprintf(outfile,"%s\n",payload);
  11464. ChargingProfileAdded = TRUE;
  11465. }
  11466. else
  11467. {
  11468. fprintf(outfile,"%s\n",buf);
  11469. }
  11470. }
  11471. }
  11472. } // end of while loop
  11473. fclose(infile);
  11474. fclose(outfile);
  11475. sprintf(rmFileCmd,"rm -f %s",filename);
  11476. system(rmFileCmd);
  11477. rename((char*)tmpProfileName, (char*)filename);
  11478. }
  11479. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  11480. result = PASS;
  11481. }
  11482. else
  11483. {
  11484. if(gun_index == -1)
  11485. DEBUG_WARN("Connector id is wrong.\n");
  11486. if(isConnectorMismatch)
  11487. DEBUG_WARN("Connector id is mismatch.\n");
  11488. if(isPeriodOverMax)
  11489. DEBUG_WARN("Profile periods quantity is over spec.\n");
  11490. if(isProfileOverMax)
  11491. DEBUG_WARN("Profile quantity is over spec.\n");
  11492. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  11493. }
  11494. }
  11495. json_object_put(SetChargingProfile);
  11496. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  11497. {
  11498. if(gun_index == 0)
  11499. {
  11500. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  11501. {
  11502. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  11503. }
  11504. }
  11505. else
  11506. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1]);
  11507. }
  11508. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  11509. return result;
  11510. }
  11511. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  11512. {
  11513. mtrace();
  11514. int result = FAIL;
  11515. json_object *SetDisplayMessage;
  11516. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  11517. SetDisplayMessage = json_tokener_parse(payload);
  11518. if(!is_error(SetDisplayMessage))
  11519. {
  11520. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  11521. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  11522. // Required data
  11523. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  11524. {
  11525. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  11526. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  11527. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  11528. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  11529. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  11530. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  11531. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  11532. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  11533. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  11534. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  11535. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  11536. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  11537. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  11538. {
  11539. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  11540. 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")));
  11541. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  11542. 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")));
  11543. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  11544. 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")));
  11545. }
  11546. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  11547. {
  11548. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  11549. 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")));
  11550. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  11551. 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")));
  11552. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  11553. {
  11554. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  11555. 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"));
  11556. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  11557. 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"));
  11558. }
  11559. }
  11560. }
  11561. }
  11562. json_object_put(SetDisplayMessage);
  11563. /*
  11564. * TODO:
  11565. * 1. Configure display message and response
  11566. */
  11567. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  11568. sendSetMonitoringBaseConfirmation(uuid);
  11569. return result;
  11570. }
  11571. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  11572. {
  11573. mtrace();
  11574. int result = FAIL;
  11575. json_object *SetMonitoringBase;
  11576. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  11577. SetMonitoringBase = json_tokener_parse(payload);
  11578. if(!is_error(SetMonitoringBase))
  11579. {
  11580. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  11581. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  11582. // Required data
  11583. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  11584. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  11585. }
  11586. json_object_put(SetMonitoringBase);
  11587. /*
  11588. * TODO:
  11589. * 1. Configure monitor base and response
  11590. */
  11591. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  11592. sendSetMonitoringBaseConfirmation(uuid);
  11593. return result;
  11594. }
  11595. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  11596. {
  11597. mtrace();
  11598. int result = FAIL;
  11599. json_object *SetMonitoringLevel;
  11600. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  11601. SetMonitoringLevel = json_tokener_parse(payload);
  11602. if(!is_error(SetMonitoringLevel))
  11603. {
  11604. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  11605. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  11606. // Required data
  11607. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  11608. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  11609. }
  11610. json_object_put(SetMonitoringLevel);
  11611. /*
  11612. * TODO:
  11613. * Configure monitor status and response
  11614. */
  11615. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  11616. sendSetMonitoringLevelConfirmation(uuid);
  11617. return result;
  11618. }
  11619. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  11620. {
  11621. mtrace();
  11622. int result = FAIL;
  11623. json_object *SetNetworkProfile;
  11624. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  11625. SetNetworkProfile = json_tokener_parse(payload);
  11626. if(!is_error(SetNetworkProfile))
  11627. {
  11628. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  11629. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  11630. // Required data
  11631. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  11632. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  11633. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  11634. {
  11635. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  11636. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  11637. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  11638. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  11639. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  11640. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  11641. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  11642. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  11643. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  11644. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  11645. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  11646. {
  11647. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  11648. 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")));
  11649. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  11650. 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")));
  11651. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  11652. 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")));
  11653. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  11654. 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")));
  11655. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  11656. 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")));
  11657. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  11658. 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")));
  11659. }
  11660. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  11661. {
  11662. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  11663. {
  11664. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  11665. 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")));
  11666. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  11667. }
  11668. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  11669. {
  11670. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  11671. 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")));
  11672. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  11673. }
  11674. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  11675. {
  11676. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  11677. 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")));
  11678. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  11679. }
  11680. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  11681. 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"));
  11682. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  11683. 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")));
  11684. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  11685. 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"));
  11686. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  11687. 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")));
  11688. }
  11689. }
  11690. }
  11691. json_object_put(SetNetworkProfile);
  11692. /*
  11693. * TODO:
  11694. * 1. Process network configuration and response
  11695. */
  11696. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  11697. {
  11698. }
  11699. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  11700. {
  11701. }
  11702. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  11703. {
  11704. }
  11705. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  11706. {
  11707. }
  11708. else
  11709. {
  11710. }
  11711. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  11712. {
  11713. }
  11714. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  11715. {
  11716. }
  11717. else
  11718. {
  11719. }
  11720. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  11721. {
  11722. }
  11723. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  11724. {
  11725. }
  11726. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  11727. {
  11728. }
  11729. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  11730. {
  11731. }
  11732. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  11733. {
  11734. }
  11735. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  11736. {
  11737. }
  11738. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  11739. {
  11740. }
  11741. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  11742. {
  11743. }
  11744. else
  11745. {
  11746. }
  11747. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  11748. {
  11749. }
  11750. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  11751. {
  11752. }
  11753. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  11754. {
  11755. }
  11756. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  11757. {
  11758. }
  11759. else
  11760. {
  11761. }
  11762. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  11763. {
  11764. }
  11765. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  11766. {
  11767. }
  11768. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  11769. {
  11770. }
  11771. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  11772. {
  11773. }
  11774. else
  11775. {
  11776. }
  11777. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  11778. sendSetNetworkProfileConfirmation(uuid);
  11779. return result;
  11780. }
  11781. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  11782. {
  11783. mtrace();
  11784. int result = FAIL;
  11785. json_object *SetVariableMonitoring;
  11786. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  11787. SetVariableMonitoring = json_tokener_parse(payload);
  11788. if(!is_error(SetVariableMonitoring))
  11789. {
  11790. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  11791. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  11792. // Required data
  11793. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  11794. {
  11795. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  11796. {
  11797. 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"));
  11798. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  11799. }
  11800. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  11801. {
  11802. 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"));
  11803. /*
  11804. * TODO:
  11805. * 1. Check monitor value status
  11806. */
  11807. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, MonitorEnumTypeStr[MonitorEnumType_Delta]);
  11808. }
  11809. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  11810. {
  11811. 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")));
  11812. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  11813. }
  11814. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  11815. {
  11816. 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"));
  11817. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  11818. }
  11819. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  11820. {
  11821. 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"));
  11822. }
  11823. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  11824. {
  11825. 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)
  11826. {
  11827. 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")));
  11828. }
  11829. 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)
  11830. {
  11831. 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")));
  11832. }
  11833. 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)
  11834. {
  11835. 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)
  11836. {
  11837. 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"));
  11838. }
  11839. 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)
  11840. {
  11841. 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"));
  11842. }
  11843. }
  11844. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  11845. }
  11846. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  11847. {
  11848. 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)
  11849. {
  11850. 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")));
  11851. }
  11852. 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)
  11853. {
  11854. 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")));
  11855. }
  11856. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  11857. }
  11858. }
  11859. }
  11860. json_object_put(SetVariableMonitoring);
  11861. return result;
  11862. }
  11863. int handleSetVariablesRequest(char *uuid, char *payload)
  11864. {
  11865. mtrace();
  11866. int result = FAIL;
  11867. json_object *SetVariables;
  11868. DEBUG_INFO("handleSetVariablesRequest...\n");
  11869. SetVariables = json_tokener_parse(payload);
  11870. if(!is_error(SetVariables))
  11871. {
  11872. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  11873. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  11874. // Required data
  11875. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  11876. {
  11877. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  11878. {
  11879. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  11880. {
  11881. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  11882. {
  11883. 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")));
  11884. }
  11885. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  11886. {
  11887. 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")));
  11888. }
  11889. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  11890. {
  11891. 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)
  11892. {
  11893. 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"));
  11894. }
  11895. 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)
  11896. {
  11897. 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"));
  11898. }
  11899. }
  11900. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  11901. }
  11902. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  11903. {
  11904. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  11905. {
  11906. 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")));
  11907. }
  11908. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  11909. {
  11910. 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")));
  11911. }
  11912. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  11913. }
  11914. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  11915. {
  11916. 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")));
  11917. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  11918. }
  11919. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  11920. {
  11921. 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")));
  11922. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  11923. {
  11924. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != NULL) &&
  11925. (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) &&
  11926. (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) != NULL) &&
  11927. (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))
  11928. {
  11929. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  11930. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  11931. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  11932. }
  11933. else
  11934. {
  11935. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  11936. }
  11937. }
  11938. }
  11939. }
  11940. }
  11941. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  11942. }
  11943. json_object_put(SetVariables);
  11944. return result;
  11945. }
  11946. int handleTriggerMessageRequest(char *uuid, char *payload)
  11947. {
  11948. mtrace();
  11949. int result = FAIL;
  11950. int connectorIdIsNULL = FALSE;
  11951. int connectorIdInt =0;
  11952. char requestedMessagestr[40]={0};
  11953. json_object *TriggerMessage;
  11954. DEBUG_INFO("handleTriggerMessageRequest\n");
  11955. TriggerMessage = json_tokener_parse(payload);
  11956. if(!is_error(TriggerMessage))
  11957. {
  11958. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  11959. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  11960. // Required data
  11961. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  11962. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  11963. // Optional data
  11964. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  11965. {
  11966. // Required data
  11967. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  11968. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  11969. // Optional data
  11970. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  11971. {
  11972. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  11973. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  11974. }
  11975. else
  11976. connectorIdIsNULL = TRUE;
  11977. }
  11978. }
  11979. json_object_put(TriggerMessage);
  11980. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  11981. {
  11982. if((strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  11983. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  11984. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  11985. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  11986. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  11987. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  11988. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  11989. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  11990. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  11991. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  11992. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  11993. {
  11994. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  11995. sendTriggerMessageConfirmation(uuid);
  11996. return TRUE;
  11997. }
  11998. else
  11999. {
  12000. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  12001. sendTriggerMessageConfirmation(uuid);
  12002. }
  12003. }
  12004. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  12005. {
  12006. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  12007. sendTriggerMessageConfirmation(uuid);
  12008. return TRUE;
  12009. }
  12010. //==========================
  12011. // Trigger message
  12012. //==========================
  12013. if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  12014. {
  12015. if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
  12016. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
  12017. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
  12018. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
  12019. {
  12020. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  12021. }
  12022. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
  12023. }
  12024. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  12025. {
  12026. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
  12027. }
  12028. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  12029. {
  12030. if(DB_updateBootType(BootReasonEnumType_Triggered))
  12031. server_sign = FALSE;
  12032. }
  12033. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  12034. {
  12035. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  12036. }
  12037. else if (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  12038. {
  12039. if(connectorIdIsNULL == FALSE)
  12040. {
  12041. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12042. {
  12043. //sendMeterValuesRequest((connectorIdInt -1), ReadingContext_Trigger);
  12044. cpinitateMsg.bits[connectorIdInt -1].TriggerMeterValueReq = ON;
  12045. }
  12046. }
  12047. else
  12048. {
  12049. for(int idx=0;idx< gunTotalNumber;idx++)
  12050. {
  12051. //sendMeterValuesRequest(idx, ReadingContext_Trigger);
  12052. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  12053. }
  12054. }
  12055. }
  12056. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  12057. {
  12058. if(connectorIdIsNULL == FALSE)
  12059. {
  12060. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12061. {
  12062. cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = ON;
  12063. }
  12064. }
  12065. else
  12066. {
  12067. for(int idx=0;idx< gunTotalNumber;idx++)
  12068. cpinitateMsg.bits[idx].StatusNotificationReq = ON;
  12069. }
  12070. }
  12071. return result;
  12072. }
  12073. int handleUnlockConnectorRequest(char *uuid, char *payload)
  12074. {
  12075. mtrace();
  12076. int result = FAIL;
  12077. int connectorIdInt =0;
  12078. int tempIndex = 0;
  12079. json_object *UnlockConnector;
  12080. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  12081. UnlockConnector = json_tokener_parse(payload);
  12082. if(!is_error(UnlockConnector))
  12083. {
  12084. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  12085. {
  12086. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  12087. }
  12088. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  12089. {
  12090. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  12091. }
  12092. }
  12093. json_object_put(UnlockConnector);
  12094. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  12095. if(gunTotalNumber == 0)
  12096. {
  12097. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12098. goto end;
  12099. }
  12100. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  12101. {
  12102. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12103. goto end;
  12104. }
  12105. else
  12106. {
  12107. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  12108. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  12109. //check Transaction active
  12110. if(gunType[connectorIdInt-1] == 'J')
  12111. {
  12112. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12113. {
  12114. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12115. }
  12116. else
  12117. {
  12118. tempIndex = connectorIdInt -1;
  12119. }
  12120. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12121. {
  12122. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12123. {
  12124. //stop Transaction
  12125. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12126. }
  12127. }
  12128. }
  12129. else if((gunType[connectorIdInt-1] == 'U')||(gunType[connectorIdInt-1] == 'E'))
  12130. {
  12131. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12132. {
  12133. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12134. }
  12135. else
  12136. {
  12137. tempIndex = connectorIdInt -1;
  12138. }
  12139. for (int index = 0; index < CCS_QUANTITY; index++)
  12140. {
  12141. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12142. {
  12143. //stop Transaction
  12144. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12145. }
  12146. }
  12147. }
  12148. else if(gunType[connectorIdInt-1] == 'G')
  12149. {
  12150. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12151. {
  12152. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12153. }
  12154. else
  12155. {
  12156. tempIndex = connectorIdInt -1;
  12157. }
  12158. for (int index = 0; index < GB_QUANTITY; index++)
  12159. {
  12160. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  12161. {
  12162. //stop Transaction
  12163. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12164. }
  12165. }
  12166. }
  12167. else
  12168. {
  12169. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  12170. {
  12171. tempIndex = 2;
  12172. }
  12173. else
  12174. {
  12175. tempIndex = connectorIdInt-1;
  12176. }
  12177. for (int index = 0; index < AC_QUANTITY; index++)
  12178. {
  12179. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12180. {
  12181. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12182. }
  12183. }
  12184. }
  12185. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  12186. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  12187. result = TRUE;
  12188. return result;
  12189. }
  12190. end:
  12191. //json_object_put(obj); --- remove temporally
  12192. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  12193. return result;
  12194. }
  12195. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  12196. {
  12197. mtrace();
  12198. int result = FAIL;
  12199. json_object *UnpublishFirmware;
  12200. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  12201. UnpublishFirmware = json_tokener_parse(payload);
  12202. if(!is_error(UnpublishFirmware))
  12203. {
  12204. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  12205. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  12206. // Required data
  12207. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  12208. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  12209. }
  12210. json_object_put(UnpublishFirmware);
  12211. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  12212. /*
  12213. * TODO:
  12214. * 1. Check unpublished status
  12215. */
  12216. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  12217. sendUnpublishFirmwareConfirmation(uuid);
  12218. return result;
  12219. }
  12220. static char UpdateFirmwarepayloadData[512]={0};
  12221. void *UpdateFirmwareProcess(void *data)
  12222. {
  12223. pthread_detach(pthread_self());
  12224. mtrace();
  12225. int retriesInt =0, retryIntervalInt=0;
  12226. char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
  12227. int port=0;
  12228. char locationstr[160]={0}, retrieveDatestr[30]={0};
  12229. int isSuccess = 0;
  12230. char ftpbuf[200];
  12231. char temp[100];
  12232. char * pch;
  12233. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  12234. json_object *UpdateFirmware;
  12235. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  12236. if(!is_error(UpdateFirmware))
  12237. {
  12238. // Required data
  12239. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  12240. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  12241. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  12242. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  12243. // Optional data
  12244. if(json_object_object_get(UpdateFirmware, "retries"))
  12245. {
  12246. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  12247. }
  12248. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  12249. {
  12250. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  12251. }
  12252. }
  12253. json_object_put(UpdateFirmware);
  12254. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12255. memset(path, 0, ARRAY_SIZE(path));
  12256. system("rm -f /mnt/*");
  12257. if(strncmp(locationstr,"http", 4) == 0)
  12258. {
  12259. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12260. //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
  12261. // protocol, user, password, host, path);
  12262. sprintf(ftppath,"/%s", path);
  12263. DEBUG_INFO("locationstr: %s\n", locationstr);
  12264. DEBUG_INFO("protocol: %s\n",protocol);
  12265. DEBUG_INFO("host: %s\n",host);
  12266. DEBUG_INFO("path: %s\n",path);
  12267. DEBUG_INFO("ftppath: %s\n",ftppath);
  12268. int ftppathlen=strlen(ftppath);
  12269. int i=1;
  12270. char filenametemp[50];
  12271. while(i < ftppathlen)
  12272. {
  12273. int len=ftppathlen-i;
  12274. if(ftppath[len]== 47) // '/' ascll code: 47
  12275. {
  12276. DEBUG_INFO("compare '/' all right\n");
  12277. break;
  12278. }
  12279. i=i+1;
  12280. }
  12281. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12282. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  12283. filenametemp[i+1] = 0;
  12284. do
  12285. {
  12286. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12287. sleep(3);
  12288. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  12289. if(!isSuccess)
  12290. {
  12291. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12292. sleep(retryIntervalInt);
  12293. }
  12294. else
  12295. {
  12296. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12297. }
  12298. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
  12299. }
  12300. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  12301. {
  12302. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12303. memset(temp, 0, ARRAY_SIZE(temp));
  12304. //DEBUG_INFO("locationstr=%s\n",locationstr);
  12305. strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
  12306. int ftppathlen=strlen(ftpbuf);
  12307. int i=1;
  12308. char filenametemp[50];
  12309. while(i < ftppathlen)
  12310. {
  12311. int len=ftppathlen-i;
  12312. if(ftpbuf[len]== 47) // '/' ascll code: 47
  12313. {
  12314. DEBUG_INFO(" compare '/' all right\n");
  12315. break;
  12316. }
  12317. i=i+1;
  12318. }
  12319. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12320. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  12321. filenametemp[i+1] = 0;
  12322. strncpy(temp, ftpbuf, ftppathlen-i+1);
  12323. pch=strchr(temp,'@');
  12324. if(pch==NULL)
  12325. {
  12326. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12327. protocol, host, &port, path);
  12328. strcpy(user,"anonymous");
  12329. strcpy(password,"");
  12330. }
  12331. else
  12332. {
  12333. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12334. protocol, user, password, host, &port, path);
  12335. }
  12336. sscanf(host,"%[^/]%s",host1, path1);
  12337. sprintf(ftppath,"%s", path1);
  12338. //DEBUG_INFO("protocol =%s\n",protocol);
  12339. //DEBUG_INFO("user =%s\n",user);
  12340. //DEBUG_INFO("password =%s\n",password);
  12341. //DEBUG_INFO("host1 =%s\n",host1);
  12342. //DEBUG_INFO("port =%d\n",port);
  12343. //DEBUG_INFO("path1 =%s\n",path1);
  12344. //DEBUG_INFO("ftppath=%s\n",ftppath);
  12345. //ftpFile(host, user, password, port, ftppath, fname);
  12346. //download firmware pthred
  12347. if(port == 0)
  12348. {
  12349. port = 21;
  12350. }
  12351. do
  12352. {
  12353. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12354. sleep(3);
  12355. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  12356. if(!isSuccess)
  12357. {
  12358. //BulldogUtil.sleepMs(interval*1000);
  12359. DEBUG_INFO("Update firmware request and download file fail.\n");
  12360. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12361. sleep(retryIntervalInt);
  12362. }
  12363. else
  12364. {
  12365. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12366. }
  12367. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  12368. }
  12369. else
  12370. {
  12371. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12372. }
  12373. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  12374. pthread_exit(NULL);
  12375. }
  12376. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  12377. {
  12378. mtrace();
  12379. int result = FAIL;
  12380. pthread_t t;
  12381. sendUpdateFirmwareConfirmation(uuid);
  12382. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  12383. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  12384. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  12385. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  12386. ////pthread_join(t, NULL); //
  12387. //pthread_detach(t);
  12388. //sendUpdateFirmwareConfirmation(uuid);
  12389. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  12390. return result;
  12391. }
  12392. //==========================================
  12393. // Handle server response routine
  12394. //==========================================
  12395. void handleAuthorizeResponse(char *payload, int gun_index)
  12396. {
  12397. mtrace();
  12398. DEBUG_INFO("handleAuthorizeResponse...\n");
  12399. json_object *Authorize;
  12400. Authorize = json_tokener_parse(payload);
  12401. if(!is_error(Authorize))
  12402. {
  12403. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  12404. {
  12405. // Required data
  12406. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  12407. // Optional data
  12408. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  12409. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  12410. else
  12411. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  12412. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  12413. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  12414. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  12415. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  12416. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  12417. {
  12418. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  12419. {
  12420. 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));
  12421. }
  12422. }
  12423. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  12424. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  12425. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  12426. {
  12427. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12428. 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")));
  12429. else
  12430. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  12431. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12432. 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")));
  12433. }
  12434. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  12435. {
  12436. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  12437. 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")));
  12438. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  12439. 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")));
  12440. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  12441. 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")));
  12442. }
  12443. }
  12444. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  12445. {
  12446. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  12447. }
  12448. }
  12449. json_object_put(Authorize);
  12450. //Update idTag information to authorization cache if supported
  12451. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  12452. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  12453. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  12454. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  12455. {
  12456. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  12457. }
  12458. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  12459. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  12460. authorizeRetryTimes = 0;
  12461. }
  12462. void handleBootNotificationResponse(char *payload, int gun_index)
  12463. {
  12464. mtrace();
  12465. char statusStr[12]={0};
  12466. char currentTimeStr[30]={0};
  12467. int intervalInt = 0;
  12468. struct tm tp;
  12469. char buf[28]={0};
  12470. char timebuf[50]={0};
  12471. DEBUG_INFO("handleBootNotificationResponse...\n");
  12472. json_object *BootNotification;
  12473. BootNotification = json_tokener_parse(payload);
  12474. if(!is_error(BootNotification))
  12475. {
  12476. // Required data
  12477. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  12478. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  12479. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  12480. }
  12481. json_object_put(BootNotification);
  12482. DEBUG_INFO("statusStr: %s\n", statusStr);
  12483. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  12484. BootNotificationInterval = intervalInt;
  12485. HeartBeatWaitTime = intervalInt;
  12486. //write back to ShmOCPP20Data->BootNotification
  12487. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  12488. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  12489. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  12490. {
  12491. server_sign = TRUE;
  12492. server_pending =FALSE;
  12493. DB_updateBootType(BootReasonEnumType_PowerUp);
  12494. }
  12495. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  12496. {
  12497. server_pending = TRUE;
  12498. }
  12499. strptime((const char *)ShmOCPP20Data->BootNotification.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12500. tp.tm_isdst = -1;
  12501. //time_t utc = mktime(&tp);
  12502. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12503. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12504. sprintf(timebuf,"date -s '%s'",buf);
  12505. system(timebuf);
  12506. srand(time(NULL));
  12507. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  12508. //==============================================
  12509. // RTC sync
  12510. //==============================================
  12511. system("/sbin/hwclock -w --systohc");
  12512. ShmOCPP20Data->OcppConnStatus = ON; ////0: disconnected, 1: connected
  12513. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  12514. }
  12515. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  12516. {
  12517. mtrace();
  12518. json_object *ClearedChargingLimit;
  12519. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  12520. ClearedChargingLimit = json_tokener_parse(payload);
  12521. if(!is_error(ClearedChargingLimit))
  12522. {
  12523. // Required data
  12524. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  12525. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  12526. }
  12527. json_object_put(ClearedChargingLimit);
  12528. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitReq = OFF;
  12529. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitConf = ON;
  12530. }
  12531. void handleDataTransferResponse(char *payload, int gun_index)
  12532. {
  12533. mtrace();
  12534. json_object *DataTrans;
  12535. DEBUG_INFO("handleDataTransferResponse...\n");
  12536. DataTrans = json_tokener_parse(payload);
  12537. if(!is_error(DataTrans))
  12538. {
  12539. // Required data
  12540. if(json_object_object_get(DataTrans,"status") != NULL)
  12541. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  12542. // Optional data
  12543. if(json_object_object_get(DataTrans,"data") != NULL)
  12544. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  12545. }
  12546. json_object_put(DataTrans);
  12547. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  12548. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  12549. }
  12550. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  12551. {
  12552. mtrace();
  12553. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  12554. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  12555. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  12556. }
  12557. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  12558. {
  12559. mtrace();
  12560. json_object *Get15118EVCertificate;
  12561. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  12562. Get15118EVCertificate = json_tokener_parse(payload);
  12563. if(!is_error(Get15118EVCertificate))
  12564. {
  12565. // Required data
  12566. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  12567. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  12568. // Optional data
  12569. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  12570. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  12571. }
  12572. json_object_put(Get15118EVCertificate);
  12573. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  12574. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  12575. }
  12576. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  12577. {
  12578. mtrace();
  12579. json_object *GetCertificateStatus;
  12580. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  12581. GetCertificateStatus = json_tokener_parse(payload);
  12582. if(!is_error(GetCertificateStatus))
  12583. {
  12584. // Required data
  12585. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  12586. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  12587. // Optional data
  12588. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  12589. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  12590. }
  12591. json_object_put(GetCertificateStatus);
  12592. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  12593. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  12594. }
  12595. void handleHeartbeatResponse(char *payload, int gun_index)
  12596. {
  12597. mtrace();
  12598. struct tm tp;
  12599. char buf[28]={0};
  12600. char timebuf[128]={0};
  12601. DEBUG_INFO("handleHeartbeatResponse...\n");
  12602. json_object *Heartbeat;
  12603. Heartbeat = json_tokener_parse(payload);
  12604. if(!is_error(Heartbeat))
  12605. {
  12606. // Required data
  12607. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  12608. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  12609. }
  12610. json_object_put(Heartbeat);
  12611. if(FirstHeartBeat == OFF)
  12612. {
  12613. FirstHeartBeat = ON;
  12614. DEBUG_INFO("FirstHeartBeat \n");
  12615. }
  12616. HeartBeatWithNOResponse = 0;
  12617. clientTime.Heartbeat=time((time_t*)NULL);
  12618. strptime((const char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12619. tp.tm_isdst = -1;
  12620. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12621. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12622. sprintf(timebuf,"date -s '%s'",buf);
  12623. system(timebuf);
  12624. //==============================================
  12625. // RTC sync
  12626. //==============================================
  12627. system("/sbin/hwclock -w --systohc");
  12628. }
  12629. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  12630. {
  12631. mtrace();
  12632. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  12633. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  12634. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  12635. }
  12636. void handleMeterValuesResponse(char *payload, int gun_index)
  12637. {
  12638. mtrace();
  12639. DEBUG_INFO("handleMeterValuesResponse...\n");
  12640. }
  12641. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  12642. {
  12643. mtrace();
  12644. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  12645. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  12646. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  12647. }
  12648. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  12649. {
  12650. mtrace();
  12651. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  12652. }
  12653. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  12654. {
  12655. mtrace();
  12656. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  12657. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  12658. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  12659. }
  12660. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  12661. {
  12662. mtrace();
  12663. json_object *NotifyEVChargingNeeds;
  12664. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  12665. NotifyEVChargingNeeds = json_tokener_parse(payload);
  12666. if(!is_error(NotifyEVChargingNeeds))
  12667. {
  12668. // Required data
  12669. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  12670. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  12671. }
  12672. json_object_put(NotifyEVChargingNeeds);
  12673. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  12674. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  12675. }
  12676. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  12677. {
  12678. mtrace();
  12679. json_object *NotifyEVChargingSchedule;
  12680. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  12681. NotifyEVChargingSchedule = json_tokener_parse(payload);
  12682. if(!is_error(NotifyEVChargingSchedule))
  12683. {
  12684. // Required data
  12685. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  12686. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  12687. }
  12688. json_object_put(NotifyEVChargingSchedule);
  12689. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  12690. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  12691. }
  12692. void hanldeNotifyEventResponse(char *payload, int gun_index)
  12693. {
  12694. mtrace();
  12695. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  12696. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  12697. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  12698. }
  12699. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  12700. {
  12701. mtrace();
  12702. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  12703. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  12704. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  12705. }
  12706. void hanldeNotifyReportResponse(char *payload, int gun_index)
  12707. {
  12708. mtrace();
  12709. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  12710. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  12711. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  12712. }
  12713. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  12714. {
  12715. mtrace();
  12716. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  12717. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  12718. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  12719. }
  12720. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  12721. {
  12722. mtrace();
  12723. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  12724. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  12725. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  12726. }
  12727. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  12728. {
  12729. mtrace();
  12730. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  12731. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  12732. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  12733. }
  12734. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  12735. {
  12736. mtrace();
  12737. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  12738. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  12739. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  12740. }
  12741. void hanldeSignCertificateResponse(char *payload, int gun_index)
  12742. {
  12743. mtrace();
  12744. json_object *SignCertificate;
  12745. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  12746. SignCertificate = json_tokener_parse(payload);
  12747. if(!is_error(SignCertificate))
  12748. {
  12749. // Required data
  12750. if(json_object_object_get(SignCertificate,"status") != NULL)
  12751. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  12752. }
  12753. json_object_put(SignCertificate);
  12754. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  12755. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  12756. }
  12757. void handleStatusNotificationResponse(char *payload, int gun_index)
  12758. {
  12759. mtrace();
  12760. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  12761. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  12762. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  12763. }
  12764. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  12765. {
  12766. mtrace();
  12767. json_object *TransactionEven;
  12768. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  12769. TransactionEven = json_tokener_parse(payload);
  12770. if(!is_error(TransactionEven))
  12771. {
  12772. // Required data
  12773. // Optional data
  12774. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  12775. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  12776. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  12777. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  12778. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  12779. {
  12780. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  12781. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  12782. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  12783. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  12784. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  12785. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  12786. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  12787. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  12788. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  12789. {
  12790. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12791. 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")));
  12792. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12793. 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")));
  12794. }
  12795. }
  12796. }
  12797. json_object_put(TransactionEven);
  12798. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  12799. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  12800. }
  12801. //==========================================
  12802. // Handle Error routine
  12803. //==========================================
  12804. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  12805. {
  12806. mtrace();
  12807. #ifdef SystemLogMessage
  12808. DEBUG_INFO("errorCode: %s\n", errorCode);
  12809. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  12810. DEBUG_INFO("errorDetails: %s\n", payload);
  12811. #endif
  12812. }
  12813. //===============================================
  12814. // Common routine
  12815. //===============================================
  12816. int initialConfigurationTable(void)
  12817. {
  12818. DEBUG_INFO("initialConfigurationTable...\n");
  12819. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  12820. DB_variableIsCreate();
  12821. DB_variableLoadFromDb();
  12822. return 0;
  12823. }
  12824. int TransactionMessageAttemptsGet(void)
  12825. {
  12826. return TransactionMessageAttemptsValue;
  12827. }
  12828. int FirstHeartBeatResponse(void)
  12829. {
  12830. return FirstHeartBeat;
  12831. }
  12832. int TransactionMessageRetryIntervalGet(void)
  12833. {
  12834. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  12835. }
  12836. int ReadHttpStatus(int sock)
  12837. {
  12838. //char c;
  12839. char buff[1024]="",*ptr=buff+1;
  12840. int bytes_received, status;
  12841. DEBUG_INFO("Begin Response ..\n");
  12842. while((bytes_received = recv(sock, ptr, 1, 0))){
  12843. if(bytes_received==-1){
  12844. perror("ReadHttpStatus");
  12845. exit(1);
  12846. }
  12847. if((ptr[-1]=='\r') && (*ptr=='\n' )) break;
  12848. ptr++;
  12849. }
  12850. *ptr=0;
  12851. ptr=buff+1;
  12852. sscanf(ptr,"%*s %d ", &status);
  12853. DEBUG_INFO("%s\n",ptr);
  12854. DEBUG_INFO("status=%d\n",status);
  12855. DEBUG_INFO("End Response ..\n");
  12856. return (bytes_received>0)?status:0;
  12857. }
  12858. //the only filed that it parsed is 'Content-Length'
  12859. int ParseHeader(int sock)
  12860. {
  12861. //char c;
  12862. char buff[1024]="",*ptr=buff+4;
  12863. int bytes_received;
  12864. DEBUG_INFO("Begin HEADER ..\n");
  12865. while((bytes_received = recv(sock, ptr, 1, 0))){
  12866. if(bytes_received==-1){
  12867. perror("Parse Header");
  12868. exit(1);
  12869. }
  12870. if(
  12871. (ptr[-3]=='\r') && (ptr[-2]=='\n' ) &&
  12872. (ptr[-1]=='\r') && (*ptr=='\n' )
  12873. ) break;
  12874. ptr++;
  12875. }
  12876. *ptr=0;
  12877. ptr=buff+4;
  12878. //printf("%s",ptr);
  12879. if(bytes_received){
  12880. ptr=strstr(ptr,"Content-Length:");
  12881. if(ptr){
  12882. sscanf(ptr,"%*s %d",&bytes_received);
  12883. }else
  12884. bytes_received=-1; //unknown size
  12885. DEBUG_INFO("Content-Length: %d\n",bytes_received);
  12886. }
  12887. DEBUG_INFO("End HEADER ..\n");
  12888. return bytes_received ;
  12889. }
  12890. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  12891. {
  12892. char rmFileCmd[100]={0};
  12893. char FilePath[100]={0};
  12894. char ftpbuf[200];
  12895. int systemresult;
  12896. //DEBUG_INFO("filename=%s\n",filename);
  12897. //DEBUG_INFO("url=%s\n",url);
  12898. sprintf(FilePath,"/mnt/%s",filename);
  12899. if((access(FilePath,F_OK))!=-1)
  12900. {
  12901. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12902. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12903. system(rmFileCmd);
  12904. }
  12905. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12906. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  12907. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  12908. systemresult = system(ftpbuf);
  12909. //DEBUG_INFO("systemresult=%d\n",systemresult);
  12910. if(systemresult != 0)
  12911. {
  12912. DEBUG_INFO("http DownLoad error!\n");
  12913. return FALSE;
  12914. }
  12915. return TRUE;
  12916. }
  12917. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  12918. {
  12919. char rmFileCmd[100]={0};
  12920. char FilePath[100]={0};
  12921. char ftpbuf[200];
  12922. int systemresult;
  12923. //char temp[100];
  12924. sprintf(FilePath,"/mnt/%s",filename);
  12925. if((access(FilePath,F_OK))!=-1)
  12926. {
  12927. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12928. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12929. system(rmFileCmd);
  12930. }
  12931. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12932. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  12933. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  12934. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  12935. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  12936. systemresult = system(ftpbuf);
  12937. //DEBUG_INFO("systemresult=%d\n",systemresult);
  12938. if(systemresult != 0)
  12939. {
  12940. printf("wget error!\n");
  12941. return FALSE;
  12942. }
  12943. return TRUE;
  12944. }
  12945. int httpUploadFile(char *location, char *path, char *filename,char *url)
  12946. {
  12947. char rmFileCmd[100]={0};
  12948. char FilePath[100]={0};
  12949. char ftpbuf[200];
  12950. int systemresult;
  12951. //DEBUG_INFO("filename=%s\n",filename);
  12952. //DEBUG_INFO("url=%s\n",url);
  12953. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  12954. if((access(FilePath,F_OK))!=-1)
  12955. {
  12956. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12957. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12958. system(rmFileCmd);
  12959. }
  12960. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  12961. if(fp == NULL)
  12962. {
  12963. DEBUG_INFO("log is NULL\n");
  12964. return FALSE;
  12965. }
  12966. else
  12967. {
  12968. fprintf(fp, "%s\n", url);
  12969. fprintf(fp, "%s\n", filename);
  12970. fclose(fp);
  12971. }
  12972. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12973. sprintf(ftpbuf, "%s","/bin/php-cgi /var/www/ocpp_upload.php");
  12974. systemresult = system(ftpbuf);
  12975. DEBUG_INFO("systemresult = %d\n",systemresult);
  12976. if(systemresult != 0)
  12977. {
  12978. DEBUG_INFO("http upload error!\n");
  12979. return FALSE;
  12980. }
  12981. return TRUE;
  12982. }
  12983. int ftpFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  12984. {
  12985. struct hostent* server;
  12986. char *IPbuffer;
  12987. char ftpbuf[200];
  12988. int systemresult;
  12989. // To retrieve host information
  12990. server = gethostbyname(location);
  12991. // To convert an Internet network
  12992. // address into ASCII string
  12993. IPbuffer = inet_ntoa(*((struct in_addr*)
  12994. server->h_addr_list[0]));
  12995. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12996. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  12997. /* format : ftpput -u username -p passwd IP target source*/
  12998. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  12999. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13000. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13001. systemresult = system(ftpbuf);
  13002. DEBUG_INFO("systemresult=%d\n",systemresult);
  13003. if(systemresult != 0)
  13004. {
  13005. DEBUG_INFO("ftpput error!\n");
  13006. return FALSE;
  13007. }
  13008. return TRUE;
  13009. }
  13010. //=========================================
  13011. // Routine
  13012. //=========================================
  13013. int GetOcppServerURL()
  13014. {
  13015. int result = FALSE;
  13016. struct yuarel url;
  13017. char urlStr[512];
  13018. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  13019. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  13020. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  13021. if((ShmSysConfigAndInfo->SysConfig.OcppServerURL != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) )
  13022. {
  13023. memcpy(urlStr, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  13024. if(yuarel_parse(&url, urlStr) != -1)
  13025. {
  13026. sprintf(OcppProtocol, "%s", url.scheme);
  13027. sprintf(OcppHost, "%s", url.host);
  13028. if(url.path == NULL)
  13029. OcppTempPath[0] = '\0';
  13030. else
  13031. sprintf(OcppTempPath, "%s", url.path);
  13032. if(url.port == 0)
  13033. {
  13034. if(strcmp(OcppProtocol, "wss") == 0)
  13035. OcppPort = 443;
  13036. else
  13037. OcppPort = 80;
  13038. }
  13039. else
  13040. OcppPort = url.port;
  13041. result = TRUE;
  13042. }
  13043. }
  13044. else if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  13045. {
  13046. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  13047. if(yuarel_parse(&url, urlStr) != -1)
  13048. {
  13049. sprintf(OcppProtocol, "%s", url.scheme);
  13050. sprintf(OcppHost, "%s", url.host);
  13051. if(url.path == NULL)
  13052. OcppTempPath[0] = '\0';
  13053. else
  13054. sprintf(OcppTempPath, "%s", url.path);
  13055. if(url.port == 0)
  13056. {
  13057. if(strcmp(OcppProtocol, "wss") == 0)
  13058. OcppPort = 443;
  13059. else
  13060. OcppPort = 80;
  13061. }
  13062. else
  13063. OcppPort = url.port;
  13064. result = TRUE;
  13065. }
  13066. }
  13067. else
  13068. {
  13069. strcpy(OcppHost,"");
  13070. }
  13071. return result;
  13072. }
  13073. int GetOcppPath()
  13074. {
  13075. int result = FALSE;
  13076. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  13077. {
  13078. if(OcppTempPath == NULL)
  13079. {
  13080. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13081. }
  13082. else
  13083. {
  13084. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13085. }
  13086. result = TRUE;
  13087. }
  13088. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  13089. {
  13090. if(OcppTempPath == NULL)
  13091. {
  13092. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  13093. }
  13094. else
  13095. {
  13096. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  13097. }
  13098. result = TRUE;
  13099. }
  13100. else
  13101. {
  13102. strcpy(OcppPath,"");
  13103. }
  13104. //sprintf(OcppPath,"/AWLU770001D1P0D19520001A0"); // For test
  13105. return result;
  13106. }
  13107. int GetOcppPort()
  13108. {
  13109. return OcppPort;
  13110. }
  13111. int GetOcppConnStatus(void)
  13112. {
  13113. return ShmOCPP20Data->OcppConnStatus;
  13114. }
  13115. void SetOcppConnStatus(uint8_t status)
  13116. {
  13117. ShmOCPP20Data->OcppConnStatus = status;
  13118. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  13119. }
  13120. int GetHeartBeatWithNOResponse(void)
  13121. {
  13122. return HeartBeatWithNOResponse;
  13123. }
  13124. void SetHeartBeatWithNOResponse(void)
  13125. {
  13126. HeartBeatWithNOResponse = 0;
  13127. }
  13128. void GetStartTransactionIdTag(int gun_index)
  13129. {
  13130. memset(StartTransactionIdTagTemp, 0 ,ARRAY_SIZE(StartTransactionIdTagTemp));
  13131. strcpy((char *)StartTransactionIdTagTemp, (const char *)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken);
  13132. }
  13133. int GetTransactionId(int gunindex, unsigned char idTag[], uint8_t isStopTransaction)
  13134. {
  13135. char ch;
  13136. FILE *fptr1;
  13137. int temptransactionId;
  13138. char str[100]={0};
  13139. temptransactionId = 0;
  13140. if((strcmp((const char*)idTag, "")==0)||(idTag[0]=='\0'))
  13141. {
  13142. DEBUG_INFO("IdTag is empty.\n");
  13143. return temptransactionId;
  13144. }
  13145. /*------ Read the file ----------------*/
  13146. fptr1=fopen("/Storage/OCPP/QueueTransactionId","r");
  13147. if (!fptr1)
  13148. {
  13149. DEBUG_INFO("QueueTransactionId file open error.\n");
  13150. //printf(" File not found or unable to open the input file!!\n");
  13151. return temptransactionId;
  13152. }
  13153. ch=fgetc(fptr1);
  13154. //printf(" Now the content of the file %s is : \n","/Storage/OCPP/QueueTransactionId");
  13155. rewind(fptr1);
  13156. if(ch!=EOF)
  13157. {
  13158. // printf("%c",ch);
  13159. while (fgets(str, 100, fptr1) != NULL)
  13160. {
  13161. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13162. if(str[0]=='\0')
  13163. {
  13164. break;
  13165. }
  13166. char *revbuf[8] = {0}; // Variable store string split
  13167. int num = 0;// Quantity after string split
  13168. DEBUG_INFO("Transaction queue data= %s\n", str);
  13169. splitstring(str,",",revbuf,&num); // String split
  13170. DEBUG_INFO(" revbuf[0]= %s\n", revbuf[0]);
  13171. DEBUG_INFO(" revbuf[1]= %s\n", revbuf[1]);
  13172. DEBUG_INFO(" revbuf[2]= %s\n", revbuf[2]);
  13173. if((revbuf[1][0] != '\0')&&(revbuf[2][0] != '\0'))
  13174. {
  13175. if(isStopTransaction)
  13176. {
  13177. if((atoi(revbuf[0])==gunindex) && (strcmp(revbuf[1],(const char *)idTag)==0))
  13178. {
  13179. temptransactionId = atoi(revbuf[2]);
  13180. break;
  13181. }
  13182. }
  13183. else
  13184. {
  13185. if((atoi(revbuf[0])==gunindex) || (strcmp(revbuf[1],(const char *)idTag)==0))
  13186. {
  13187. temptransactionId = atoi(revbuf[2]);
  13188. break;
  13189. }
  13190. }
  13191. }
  13192. }
  13193. }
  13194. else
  13195. DEBUG_INFO("EOF\n");
  13196. fclose(fptr1);
  13197. /*------- End of reading ---------------*/
  13198. return temptransactionId;
  13199. }
  13200. void SetTransactionIdZero(int transactionId)
  13201. {
  13202. char ch;
  13203. FILE *fptr1, *fptr2;
  13204. int temptransactionId = 0;
  13205. char str[100]={0}, strtemp[100]={0}, temp[] = "/Storage/OCPP/QueueTransactionIdtemp.json";
  13206. fptr1 = fopen("/Storage/OCPP/QueueTransactionId", "r");
  13207. if (!fptr1)
  13208. {
  13209. //printf(" File not found or unable to open the input file!!\n");
  13210. return ;
  13211. }
  13212. fptr2 = fopen(temp, "w"); // open the temporary file in write mode
  13213. if (!fptr2)
  13214. {
  13215. DEBUG_INFO("Unable to open a temporary file to write!!\n");
  13216. fclose(fptr1);
  13217. return ;
  13218. }
  13219. ch=fgetc(fptr1);
  13220. rewind(fptr1);
  13221. if(ch!=EOF)
  13222. {
  13223. // copy all contents to the temporary file except the specific line
  13224. while (fgets(str, 100, fptr1) != NULL)
  13225. {
  13226. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13227. if(str[0]=='\0')
  13228. {
  13229. break;
  13230. }
  13231. char *revbuf[8] = {0};
  13232. int num = 0;
  13233. strcpy(strtemp, str);
  13234. splitstring(str,",",revbuf,&num);
  13235. if(revbuf[2][0] != '\0')
  13236. {
  13237. temptransactionId = atoi(revbuf[2]);
  13238. if(transactionId != temptransactionId)
  13239. {
  13240. fprintf(fptr2, "%s\n", strtemp);
  13241. }
  13242. }
  13243. }
  13244. }
  13245. fclose(fptr1);
  13246. fclose(fptr2);
  13247. remove("/Storage/OCPP/QueueTransactionId"); // remove the original file
  13248. rename(temp, "/Storage/OCPP/QueueTransactionId"); // rename the temporary file to original name
  13249. /*------ Read the file ----------------*/
  13250. }
  13251. int InternetDisconnect(void)
  13252. {
  13253. return (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi );
  13254. }
  13255. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  13256. void storeTempStopTransaction(int gun_index)
  13257. {
  13258. }
  13259. void checkTempStopTransaction(int gun_index)
  13260. {
  13261. FILE *fptr1;
  13262. char ch;
  13263. char str[QUEUE_MESSAGE_LENGTH]={0};
  13264. char guid[37]={0};
  13265. char tempdata[65]={0};
  13266. char connectorStr[2]={0};
  13267. char TempStopTransaction[256];
  13268. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  13269. fptr1 = fopen(TempStopTransaction, "r");
  13270. //TempStopTransaction格式: 槍號,StopTransaction封包
  13271. if (!fptr1)
  13272. {
  13273. //printf(" File not found or unable to open the input file!!\n");
  13274. return ;
  13275. }
  13276. ch=fgetc(fptr1);
  13277. //printf(" Now the content of the file %s is : \n",fname);
  13278. rewind(fptr1);
  13279. if(ch!=EOF)
  13280. {
  13281. // copy all contents to the temporary file except the specific line
  13282. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  13283. {
  13284. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13285. if(str[0]=='\0')
  13286. {
  13287. break;
  13288. }
  13289. //TempStopTransaction格式: 槍號,StopTransaction封包
  13290. strncpy(connectorStr, str, 1);
  13291. if(atoi(connectorStr) != (gun_index+1))
  13292. {
  13293. DEBUG_INFO("atoi(connectorStr) = %d, gun_index = %d\n", atoi(connectorStr), gun_index);
  13294. fclose(fptr1);
  13295. return ;
  13296. }
  13297. //random_uuid(guid);
  13298. strncpy(guid, str+6, 36); //copy guid
  13299. sprintf(tempdata, "StopTransaction,%d", (gun_index));
  13300. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  13301. {
  13302. //DEBUG_INFO("StopTransaction mapitem pass\n");
  13303. }
  13304. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  13305. memset(str,0,ARRAY_SIZE(str));
  13306. }
  13307. }
  13308. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  13309. fclose(fptr1);
  13310. remove(TempStopTransaction); // remove the original file
  13311. }
  13312. void FillStartTransaction(int ConnectorId, unsigned char IdTag[], int MeterStart,int ReservationId,unsigned char Timestamp[])
  13313. {
  13314. ShmOCPP20Data->TransactionEvent[ConnectorId-1].evse.connectorId = ConnectorId;
  13315. ShmOCPP20Data->TransactionEvent[ConnectorId-1].reservationId = ReservationId;
  13316. //ShmOCPP20Data->TransactionEvent[ConnectorId-1].MeterStart = MeterStart;
  13317. strcpy((char *)ShmOCPP20Data->TransactionEvent[ConnectorId-1].idToken.idToken, (char *)IdTag);
  13318. strcpy((char *)ShmOCPP20Data->TransactionEvent[ConnectorId-1].timestamp,(char *) Timestamp);
  13319. }
  13320. int GetWebSocketPingInterval(void)
  13321. {
  13322. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  13323. }
  13324. int GetServerSign(void)
  13325. {
  13326. return server_sign;
  13327. }
  13328. uint8_t GetOcppSecurityProfile()
  13329. {
  13330. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  13331. }
  13332. void GetOcppChargerBoxId(uint8_t *data)
  13333. {
  13334. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  13335. }
  13336. void GetOcppSecurityPassword(uint8_t *data)
  13337. {
  13338. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  13339. }
  13340. void SetServerSign(int value)
  13341. {
  13342. server_sign = value;
  13343. }
  13344. int GetBootNotificationInterval(void)
  13345. {
  13346. return BootNotificationInterval;
  13347. }
  13348. int GetInternetConn(void)
  13349. {
  13350. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  13351. }
  13352. void InitialSystemValue(void)
  13353. {
  13354. int connectorIndex = 0;
  13355. gunTotalNumber=0;
  13356. SystemInitial = 0;
  13357. localversion=0;
  13358. BootNotificationInterval = 0;
  13359. authorizeRetryTimes = 0;
  13360. GunStatusInterval = 10;
  13361. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  13362. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  13363. //Hear Beat
  13364. HeartBeatWithNOResponse = 0;
  13365. HeartBeatCountPerHour = 0;
  13366. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  13367. FirstHeartBeat = 0;
  13368. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  13369. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  13370. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  13371. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  13372. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  13373. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  13374. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  13375. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  13376. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  13377. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  13378. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  13379. memset(gunType, 0, ARRAY_SIZE(gunType));
  13380. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13381. {
  13382. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  13383. {
  13384. // DO series
  13385. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  13386. {
  13387. SystemInitial = SystemInitial + 1;
  13388. gunTotalNumber = gunTotalNumber + 1;
  13389. gunType[connectorIndex] = 'O';
  13390. connectorIndex = connectorIndex + 1;
  13391. }
  13392. }
  13393. else
  13394. {
  13395. // DM, DW, DS series
  13396. //check connector / socket type (index: 8, 9, 10)
  13397. for(int index=7; index <10 ; index++)
  13398. {
  13399. if(index != 8)
  13400. {
  13401. // DC Connector
  13402. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] >= 'A') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= 'Z'))
  13403. {
  13404. SystemInitial = SystemInitial + 1;
  13405. gunTotalNumber = gunTotalNumber + 1;
  13406. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13407. connectorIndex = connectorIndex + 1;
  13408. }
  13409. }
  13410. else
  13411. {
  13412. // AC Connector
  13413. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13414. {
  13415. SystemInitial = SystemInitial + 1;
  13416. gunTotalNumber = gunTotalNumber + 1;
  13417. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13418. connectorIndex = connectorIndex + 1;
  13419. }
  13420. }
  13421. }
  13422. }
  13423. //DEBUG_INFO("DC ...\n");
  13424. }
  13425. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  13426. {
  13427. //check connector / socket type (index: 8, 9, 10)
  13428. for(int index=7; index <10 ; index++)
  13429. {
  13430. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13431. {
  13432. SystemInitial = SystemInitial + 1;
  13433. gunTotalNumber = gunTotalNumber + 1;
  13434. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13435. connectorIndex = connectorIndex + 1;
  13436. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  13437. }
  13438. }
  13439. }
  13440. //Status && ConnectorPlugIn Setting
  13441. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13442. {
  13443. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  13444. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  13445. }
  13446. for (int index = 0; index < CCS_QUANTITY; index++)
  13447. {
  13448. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  13449. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  13450. }
  13451. for (int index = 0; index < GB_QUANTITY; index++)
  13452. {
  13453. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  13454. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  13455. }
  13456. for (int index = 0; index < AC_QUANTITY; index++)
  13457. {
  13458. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  13459. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  13460. }
  13461. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13462. {
  13463. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  13464. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  13465. }
  13466. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  13467. {
  13468. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13469. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  13470. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  13471. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  13472. }
  13473. clientTime.Heartbeat=time((time_t*)NULL);
  13474. sleep(1);
  13475. }
  13476. void LWS_Send(char * str)
  13477. {
  13478. //=====================================================
  13479. // Check InternetConn 0: disconnected, 1: connected
  13480. //====================================================
  13481. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  13482. {
  13483. DEBUG_INFO("offline now !!!\n");
  13484. return;
  13485. }
  13486. pthread_mutex_lock(&lock_send);
  13487. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13488. sprintf((char *)SendBuffer, "%s", str);
  13489. SendBufLen = strlen(str);
  13490. pthread_mutex_unlock(&lock_send);
  13491. lws_callback_on_writable(wsi_client);
  13492. //lws_service(context, 0);
  13493. //sleep(1);
  13494. }
  13495. void LWS_SendNow(char * str)
  13496. {
  13497. //=====================================================
  13498. // Check InternetConn 0: disconnected, 1: connected
  13499. //====================================================
  13500. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  13501. {
  13502. DEBUG_INFO("offline now !!!\n");
  13503. return;
  13504. }
  13505. pthread_mutex_lock(&lock_send);
  13506. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13507. sprintf((char *)SendBuffer, "%s", str);
  13508. SendBufLen = strlen(str);
  13509. pthread_mutex_unlock(&lock_send);
  13510. lws_callback_on_writable(wsi_client);
  13511. lws_service(context, 0);
  13512. //sleep(1);
  13513. }