MessageHandler.c 874 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113
  1. #include "Module_OcppBackend20.h"
  2. #include "define.h"
  3. static char *APNAuthenticationEnumTypeStr[] = {
  4. MACROSTR(CHAP),
  5. MACROSTR(NONE),
  6. MACROSTR(PAP),
  7. MACROSTR(AUTO)
  8. };
  9. static char *AttributeEnumTypeStr[] = {
  10. MACROSTR(Actual),
  11. MACROSTR(Target),
  12. MACROSTR(MinSet),
  13. MACROSTR(MaxSet)
  14. };
  15. static char *AuthorizationStatusEnumTypeStr[] = {
  16. MACROSTR(Accepted),
  17. MACROSTR(Blocked),
  18. MACROSTR(ConcurrentTx),
  19. MACROSTR(Expired),
  20. MACROSTR(Invalid),
  21. MACROSTR(NoCredit),
  22. MACROSTR(NotAllowedTypeEVSE),
  23. MACROSTR(NotAtThisLocation),
  24. MACROSTR(NotAtThisTime),
  25. MACROSTR(Unknown)
  26. };
  27. #if 0
  28. static char *AuthorizeCertificateStatusEnumTypeStr[] = {
  29. MACROSTR(Accepted),
  30. MACROSTR(SignatureError),
  31. MACROSTR(CertificateExpired),
  32. MACROSTR(CertificateRevoked),
  33. MACROSTR(NoCertificateAvailable),
  34. MACROSTR(CertChainError),
  35. MACROSTR(ContractCancelled)
  36. };
  37. #endif
  38. static char *BootReasonEnumTypeStr[] = {
  39. MACROSTR(ApplicationReset),
  40. MACROSTR(FirmwareUpdate),
  41. MACROSTR(LocalReset),
  42. MACROSTR(PowerUp),
  43. MACROSTR(RemoteReset),
  44. MACROSTR(ScheduledReset),
  45. MACROSTR(Triggered),
  46. MACROSTR(Unknown),
  47. MACROSTR(Watchdog)
  48. };
  49. static char *CancelReservationStatusEnumTypeStr[] = {
  50. MACROSTR(Accepted),
  51. MACROSTR(Rejected)
  52. };
  53. static char *CertificateActionEnumTypeStr[] = {
  54. MACROSTR(Install),
  55. MACROSTR(Update)
  56. };
  57. static char *CertificateSignedStatusEnumTypeStr[] = {
  58. MACROSTR(Accepted),
  59. MACROSTR(Rejected)
  60. };
  61. static char *CertificateSigningUseEnumTypeStr[] = {
  62. MACROSTR(ChargingStationCertificate),
  63. MACROSTR(V2GCertificate)
  64. };
  65. static char *ChangeAvailabilityStatusEnumTypeStr[] = {
  66. MACROSTR(Accepted),
  67. MACROSTR(Rejected),
  68. MACROSTR(Scheduled)
  69. };
  70. #if 0
  71. static char *ChargingLimitSourceEnumTypeStr[] = {
  72. MACROSTR(EMS),
  73. MACROSTR(Other),
  74. MACROSTR(SO),
  75. MACROSTR(CSO)
  76. };
  77. #endif
  78. static char *ChargingProfileKindEnumTypeStr[] = {
  79. MACROSTR(Absolute),
  80. MACROSTR(Recurring),
  81. MACROSTR(Relative)
  82. };
  83. static char *ChargingProfilePurposeEnumTypeStr[] = {
  84. MACROSTR(ChargingStationExternalConstraints),
  85. MACROSTR(ChargingStationMaxProfile),
  86. MACROSTR(TxDefaultProfile),
  87. MACROSTR(TxProfile)
  88. };
  89. static char *ChargingProfileStatusEnumTypeStr[] = {
  90. MACROSTR(Accepted),
  91. MACROSTR(Rejected)
  92. };
  93. static char *ChargingRateUnitEnumTypeStr[] = {
  94. MACROSTR(W),
  95. MACROSTR(A)
  96. };
  97. static char *ChargingStateEnumTypeStr[] = {
  98. MACROSTR(Charging),
  99. MACROSTR(EVConnected),
  100. MACROSTR(SuspendedEV),
  101. MACROSTR(SuspendedEVSE),
  102. MACROSTR(Idle)
  103. };
  104. static char *ClearCacheStatusEnumTypeStr[] = {
  105. MACROSTR(Accepted),
  106. MACROSTR(Rejected)
  107. };
  108. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  109. MACROSTR(Accepted),
  110. MACROSTR(Unknown)
  111. };
  112. static char *ClearMessageStatusEnumTypeStr[] = {
  113. MACROSTR(Accepted),
  114. MACROSTR(Unknown)
  115. };
  116. static char *ClearMonitoringStatusEnumTypeStr[] = {
  117. MACROSTR(Accepted),
  118. MACROSTR(Rejected),
  119. MACROSTR(NotFound)
  120. };
  121. static char *ComponentCriterionEnumTypeStr[] = {
  122. MACROSTR(Active),
  123. MACROSTR(Available),
  124. MACROSTR(Enabled),
  125. MACROSTR(Problem)
  126. };
  127. #if 0
  128. static char *ConnectorEnumTypeStr[] = {
  129. MACROSTR(cCCS1),
  130. MACROSTR(cCCS2),
  131. MACROSTR(cG105),
  132. MACROSTR(cTesla),
  133. MACROSTR(cType1),
  134. MACROSTR(cType2),
  135. MACROSTR(s309-1P-16A),
  136. MACROSTR(s309-1P-32A),
  137. MACROSTR(s309-3P-16A),
  138. MACROSTR(s309-3P-32A),
  139. MACROSTR(sBS1361),
  140. MACROSTR(sCEE-7-7),
  141. MACROSTR(sType2),
  142. MACROSTR(sType3),
  143. MACROSTR(Other1PhMax16A),
  144. MACROSTR(Other1PhOver16A),
  145. MACROSTR(Other3Ph),
  146. MACROSTR(Pan),
  147. MACROSTR(wInductive),
  148. MACROSTR(wResonant),
  149. MACROSTR(Undetermined),
  150. MACROSTR(Unknown)
  151. };
  152. #endif
  153. static char *ConnectorStatusEnumTypeStr[] = {
  154. MACROSTR(Available),
  155. MACROSTR(Occupied),
  156. MACROSTR(Reserved),
  157. MACROSTR(Unavailable),
  158. MACROSTR(Faulted)
  159. };
  160. #if 0
  161. static char *CostKindEnumTypeStr[] = {
  162. MACROSTR(CarbonDioxideEmission),
  163. MACROSTR(RelativePricePercentage),
  164. MACROSTR(RenewableGenerationPercentage)
  165. };
  166. #endif
  167. static char *CustomerInformationStatusEnumTypeStr[] = {
  168. MACROSTR(Accepted),
  169. MACROSTR(Rejected),
  170. MACROSTR(Invalid)
  171. };
  172. static char *DataEnumTypeStr[] = {
  173. MACROSTR(string),
  174. MACROSTR(decimal),
  175. MACROSTR(integer),
  176. MACROSTR(dateTime),
  177. MACROSTR(boolean),
  178. MACROSTR(OptionList),
  179. MACROSTR(SequenceList),
  180. MACROSTR(MemberList)
  181. };
  182. static char *DataTransferStatusEnumTypeStr[] = {
  183. MACROSTR(Accepted),
  184. MACROSTR(Rejected),
  185. MACROSTR(UnknownMessageId),
  186. MACROSTR(UnknownVendorId)
  187. };
  188. static char *DeleteCertificateStatusEnumTypeStr[] = {
  189. MACROSTR(Accepted),
  190. MACROSTR(Failed),
  191. MACROSTR(NotFound)
  192. };
  193. static char *DisplayMessageStatusEnumTypeStr[] = {
  194. MACROSTR(Accepted),
  195. MACROSTR(NotSupportedMessageFormat),
  196. MACROSTR(Rejected),
  197. MACROSTR(NotSupportedPriority),
  198. MACROSTR(NotSupportedState),
  199. MACROSTR(UnknownTransaction)
  200. };
  201. #if 0
  202. static char *EnergyTransferModeEnumTypeStr[] = {
  203. MACROSTR(DC),
  204. MACROSTR(AC_single_phase),
  205. MACROSTR(AC_two_phase),
  206. MACROSTR(AC_three_phase)
  207. };
  208. #endif
  209. static char *EventNotificationEnumTypeStr[] = {
  210. MACROSTR(HardWiredNotification),
  211. MACROSTR(HardWiredMonitor),
  212. MACROSTR(PreconfiguredMonitor),
  213. MACROSTR(CustomMonitor)
  214. };
  215. static char *EventTriggerEnumTypeStr[] = {
  216. MACROSTR(Alerting),
  217. MACROSTR(Delta),
  218. MACROSTR(Periodic)
  219. };
  220. static char *FirmwareStatusEnumTypeStr[] = {
  221. MACROSTR(Downloaded),
  222. MACROSTR(DownloadFailed),
  223. MACROSTR(Downloading),
  224. MACROSTR(DownloadScheduled),
  225. MACROSTR(DownloadPaused),
  226. MACROSTR(Idle),
  227. MACROSTR(InstallationFailed),
  228. MACROSTR(Installing),
  229. MACROSTR(Installed),
  230. MACROSTR(InstallRebooting),
  231. MACROSTR(InstallScheduled),
  232. MACROSTR(InstallVerificationFailed),
  233. MACROSTR(InvalidSignature),
  234. MACROSTR(SignatureVerified)
  235. };
  236. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  237. MACROSTR(Accepted),
  238. MACROSTR(Rejected),
  239. MACROSTR(NotSupported),
  240. MACROSTR(EmptyResultSet)
  241. };
  242. static char *GenericStatusEnumTypeStr[] = {
  243. MACROSTR(Accepted),
  244. MACROSTR(Rejected)
  245. };
  246. static char *GetCertificateIdUseEnumTypeStr[] = {
  247. MACROSTR(V2GRootCertificate),
  248. MACROSTR(MORootCertificate),
  249. MACROSTR(CSMSRootCertificate),
  250. MACROSTR(V2GCertificateChain),
  251. MACROSTR(ManufacturerRootCertificate)
  252. };
  253. static char *GetCertificateStatusEnumTypeStr[] = {
  254. MACROSTR(Accepted),
  255. MACROSTR(Failed)
  256. };
  257. static char *GetChargingProfileStatusEnumTypeStr[] = {
  258. MACROSTR(Accepted),
  259. MACROSTR(NoProfiles)
  260. };
  261. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  262. MACROSTR(Accepted),
  263. MACROSTR(Unknown)
  264. };
  265. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  266. MACROSTR(Accepted),
  267. MACROSTR(NotFound)
  268. };
  269. static char *GetVariableStatusEnumTypeStr[] = {
  270. MACROSTR(Accepted),
  271. MACROSTR(Rejected),
  272. MACROSTR(UnknownComponent),
  273. MACROSTR(UnknownVariable),
  274. MACROSTR(NotSupportedAttributeType)
  275. };
  276. static char *HashAlgorithmEnumTypeStr[] = {
  277. MACROSTR(SHA256),
  278. MACROSTR(SHA384),
  279. MACROSTR(SHA512)
  280. };
  281. static char *IdTokenEnumTypeStr[] = {
  282. MACROSTR(Central),
  283. MACROSTR(eMAID),
  284. MACROSTR(ISO14443),
  285. MACROSTR(KeyCode),
  286. MACROSTR(Local),
  287. MACROSTR(NoAuthorization),
  288. MACROSTR(ISO15693)
  289. };
  290. static char *InstallCertificateUseEnumTypeStr[] = {
  291. MACROSTR(V2GRootCertificate),
  292. MACROSTR(MORootCertificate),
  293. MACROSTR(CSMSRootCertificate),
  294. MACROSTR(ManufacturerRootCertificate)
  295. };
  296. static char *InstallCertificateStatusEnumTypeStr[]={
  297. MACROSTR(Accepted),
  298. MACROSTR(Failed),
  299. MACROSTR(Rejected)
  300. };
  301. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  302. MACROSTR(Accepted),
  303. MACROSTR(Failed)
  304. };
  305. static char *LocationEnumTypeStr[] = {
  306. MACROSTR(Body),
  307. MACROSTR(Cable),
  308. MACROSTR(EV),
  309. MACROSTR(Inlet),
  310. MACROSTR(Outlet)
  311. };
  312. static char *LogEnumTypeStr[] = {
  313. MACROSTR(DiagnosticsLog),
  314. MACROSTR(SecurityLog)
  315. };
  316. static char *LogStatusEnumTypeStr[] = {
  317. MACROSTR(Accepted),
  318. MACROSTR(Rejected),
  319. MACROSTR(AcceptedCanceled)
  320. };
  321. static char *MeasurandEnumTypeStr[] = {
  322. MACROSTR(Current.Export),
  323. MACROSTR(Current.Import),
  324. MACROSTR(Current.Offered),
  325. MACROSTR(Energy.Active.Export.Register),
  326. MACROSTR(Energy.Active.Import.Register),
  327. MACROSTR(Energy.Reactive.Export.Register),
  328. MACROSTR(Energy.Reactive.Import.Register),
  329. MACROSTR(Energy.Active.Export.Interval),
  330. MACROSTR(Energy.Active.Import.Interval),
  331. MACROSTR(Energy.Active.Net),
  332. MACROSTR(Energy.Reactive.Export.Interval),
  333. MACROSTR(Energy.Reactive.Import.Interval),
  334. MACROSTR(Energy.Reactive.Net),
  335. MACROSTR(Energy.Apparent.Net),
  336. MACROSTR(Energy.Apparent.Import),
  337. MACROSTR(Energy.Apparent.Export),
  338. MACROSTR(Frequency),
  339. MACROSTR(Power.Active.Export),
  340. MACROSTR(Power.Active.Import),
  341. MACROSTR(Power.Factor),
  342. MACROSTR(Power.Offered),
  343. MACROSTR(Power.Reactive.Export),
  344. MACROSTR(Power.Reactive.Import),
  345. MACROSTR(SoC),
  346. MACROSTR(Voltage)
  347. };
  348. static char *MessageFormatEnumTypeStr[] = {
  349. MACROSTR(ASCII),
  350. MACROSTR(HTML),
  351. MACROSTR(URI),
  352. MACROSTR(UTF8)
  353. };
  354. static char *MessagePriorityEnumTypeStr[] = {
  355. MACROSTR(AlwaysFront),
  356. MACROSTR(InFront),
  357. MACROSTR(NormalCycle)
  358. };
  359. static char *MessageStateEnumTypeStr[] = {
  360. MACROSTR(Charging),
  361. MACROSTR(Faulted),
  362. MACROSTR(Idle),
  363. MACROSTR(Unavailable)
  364. };
  365. static char *MessageTriggerEnumTypeStr[] = {
  366. MACROSTR(BootNotification),
  367. MACROSTR(LogStatusNotification),
  368. MACROSTR(FirmwareStatusNotification),
  369. MACROSTR(Heartbeat),
  370. MACROSTR(MeterValues),
  371. MACROSTR(SignChargingStationCertificate),
  372. MACROSTR(SignV2GCertificate),
  373. MACROSTR(StatusNotification),
  374. MACROSTR(TransactionEvent),
  375. MACROSTR(SignCombinedCertificate),
  376. MACROSTR(PublishFirmwareStatusNotification)
  377. };
  378. static char *MonitorEnumTypeStr[] = {
  379. MACROSTR(UpperThreshold),
  380. MACROSTR(LowerThreshold),
  381. MACROSTR(Delta),
  382. MACROSTR(Periodic),
  383. MACROSTR(PeriodicClockAligned)
  384. };
  385. static char *MonitoringBaseEnumTypeStr[] = {
  386. MACROSTR(All),
  387. MACROSTR(FactoryDefault),
  388. MACROSTR(HardWiredOnly)
  389. };
  390. static char *MonitoringCriterionEnumTypeStr[] = {
  391. MACROSTR(ThresholdMonitoring),
  392. MACROSTR(DeltaMonitoring),
  393. MACROSTR(PeriodicMonitoring)
  394. };
  395. static char *MutabilityEnumTypeStr[] = {
  396. MACROSTR(ReadOnly),
  397. MACROSTR(WriteOnly),
  398. MACROSTR(ReadWrite)
  399. };
  400. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  401. MACROSTR(Accepted),
  402. MACROSTR(Rejected),
  403. MACROSTR(Processing)
  404. };
  405. static char *OCPPInterfaceEnumTypeStr[] = {
  406. MACROSTR(Wired0),
  407. MACROSTR(Wired1),
  408. MACROSTR(Wired2),
  409. MACROSTR(Wired3),
  410. MACROSTR(Wireless0),
  411. MACROSTR(Wireless1),
  412. MACROSTR(Wireless2),
  413. MACROSTR(Wireless3)
  414. };
  415. static char *OCPPTransportEnumTypeStr[] = {
  416. MACROSTR(JSON),
  417. MACROSTR(SOAP)
  418. };
  419. static char *OCPPVersionEnumTypeStr[] = {
  420. MACROSTR(OCPP12),
  421. MACROSTR(OCPP15),
  422. MACROSTR(OCPP16),
  423. MACROSTR(OCPP20)
  424. };
  425. static char *OperationalStatusEnumTypeStr[] = {
  426. MACROSTR(Inoperative),
  427. MACROSTR(Operative)
  428. };
  429. static char *PhaseEnumTypeStr[] = {
  430. MACROSTR(L1),
  431. MACROSTR(L2),
  432. MACROSTR(L3),
  433. MACROSTR(N),
  434. MACROSTR(L1-N),
  435. MACROSTR(L2-N),
  436. MACROSTR(L3-N),
  437. MACROSTR(L1-L2),
  438. MACROSTR(L2-L3),
  439. MACROSTR(L3-L1)
  440. };
  441. static char *PublishFirmwareStatusEnumTypeStr[] = {
  442. MACROSTR(Downloaded),
  443. MACROSTR(DownloadFailed),
  444. MACROSTR(Downloading),
  445. MACROSTR(DownloadScheduled),
  446. MACROSTR(DownloadPaused),
  447. MACROSTR(PublishFailed),
  448. MACROSTR(Published),
  449. MACROSTR(InvalidChecksum),
  450. MACROSTR(ChecksumVerified)
  451. };
  452. static char *ReadingContextEnumTypeStr[] = {
  453. MACROSTR(Interruption.Begin),
  454. MACROSTR(Interruption.End),
  455. MACROSTR(Other),
  456. MACROSTR(Sample.Clock),
  457. MACROSTR(Sample.Periodic),
  458. MACROSTR(Transaction.Begin),
  459. MACROSTR(Transaction.End),
  460. MACROSTR(Trigger)
  461. };
  462. #if 0
  463. static char *ReasonEnumTypeStr[] = {
  464. MACROSTR(DeAuthorized),
  465. MACROSTR(EmergencyStop),
  466. MACROSTR(EnergyLimitReached),
  467. MACROSTR(EVDisconnected),
  468. MACROSTR(GroundFault),
  469. MACROSTR(ImmediateReset),
  470. MACROSTR(Local),
  471. MACROSTR(LocalOutOfCredit),
  472. MACROSTR(MasterPass),
  473. MACROSTR(Other),
  474. MACROSTR(OvercurrentFault),
  475. MACROSTR(PowerLoss),
  476. MACROSTR(PowerQuality),
  477. MACROSTR(Reboot),
  478. MACROSTR(Remote),
  479. MACROSTR(SOCLimitReached),
  480. MACROSTR(StoppedByEV),
  481. MACROSTR(TimeLimitReached),
  482. MACROSTR(TimeLimitReached)
  483. };
  484. #endif
  485. static char *RecurrencyKindEnumTypeStr[] = {
  486. MACROSTR(Daily),
  487. MACROSTR(Weekly)
  488. };
  489. static char *RegistrationStatusEnumTypeStr[] = {
  490. MACROSTR(Accepted),
  491. MACROSTR(Pending),
  492. MACROSTR(Rejected)
  493. };
  494. static char *ReportBaseEnumTypeStr[] = {
  495. MACROSTR(ConfigurationInventory),
  496. MACROSTR(FullInventory),
  497. MACROSTR(SummaryInventory)
  498. };
  499. static char *RequestStartStopStatusEnumTypeStr[] = {
  500. MACROSTR(Accepted),
  501. MACROSTR(Rejected)
  502. };
  503. static char *ReservationUpdateStatusEnumTypeStr[] = {
  504. MACROSTR(Expired),
  505. MACROSTR(Removed)
  506. };
  507. static char *ReserveNowStatusEnumTypeStr[] = {
  508. MACROSTR(Accepted),
  509. MACROSTR(Faulted),
  510. MACROSTR(Occupied),
  511. MACROSTR(Rejected),
  512. MACROSTR(Unavailable)
  513. };
  514. static char *ResetEnumTypeStr[] = {
  515. MACROSTR(Immediate),
  516. MACROSTR(OnIdle)
  517. };
  518. static char *ResetStatusEnumTypeStr[] = {
  519. MACROSTR(Accepted),
  520. MACROSTR(Rejected),
  521. MACROSTR(Scheduled)
  522. };
  523. static char *SetMonitoringStatusEnumTypeStr[] = {
  524. MACROSTR(Accepted),
  525. MACROSTR(UnknownComponent),
  526. MACROSTR(UnknownVariable),
  527. MACROSTR(UnsupportedMonitorType),
  528. MACROSTR(Rejected),
  529. MACROSTR(OutOfRange),
  530. MACROSTR(Duplicate)
  531. };
  532. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  533. MACROSTR(Accepted),
  534. MACROSTR(Rejected),
  535. MACROSTR(Failed)
  536. };
  537. static char *SetVariableStatusEnumTypeStr[] = {
  538. MACROSTR(Accepted),
  539. MACROSTR(Rejected),
  540. MACROSTR(InvalidValue),
  541. MACROSTR(UnknownComponent),
  542. MACROSTR(UnknownVariable),
  543. MACROSTR(NotSupportedAttributeType),
  544. MACROSTR(OutOfRange),
  545. MACROSTR(RebootRequired)
  546. };
  547. static char *TransactionEventEnumTypeStr[] = {
  548. MACROSTR(Ended),
  549. MACROSTR(Started),
  550. MACROSTR(Updated)
  551. };
  552. static char *TriggerMessageStatusEnumTypeStr[] = {
  553. MACROSTR(Accepted),
  554. MACROSTR(Rejected),
  555. MACROSTR(NotImplemented)
  556. };
  557. static char *TriggerReasonEnumTypeStr[] = {
  558. MACROSTR(Authorized),
  559. MACROSTR(CablePluggedIn),
  560. MACROSTR(ChargingRateChanged),
  561. MACROSTR(ChargingStateChanged),
  562. MACROSTR(Deauthorized),
  563. MACROSTR(EnergyLimitReached),
  564. MACROSTR(EVCommunicationLost),
  565. MACROSTR(EVConnectTimeout),
  566. MACROSTR(MeterValueClock),
  567. MACROSTR(MeterValuePeriodic),
  568. MACROSTR(TimeLimitReached),
  569. MACROSTR(Trigger),
  570. MACROSTR(UnlockCommand),
  571. MACROSTR(StopAuthorized),
  572. MACROSTR(EVDeparted),
  573. MACROSTR(EVDetected),
  574. MACROSTR(RemoteStop),
  575. MACROSTR(RemoteStart),
  576. MACROSTR(AbnormalCondition),
  577. MACROSTR(SignedDataReceived),
  578. MACROSTR(ResetCommand)
  579. };
  580. static char *UnlockStatusEnumTypeStr[] = {
  581. MACROSTR(Unlocked),
  582. MACROSTR(UnlockFailed),
  583. MACROSTR(OngoingAuthorizedTransaction),
  584. MACROSTR(UnknownConnector)
  585. };
  586. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  587. MACROSTR(DownloadOngoing),
  588. MACROSTR(NoFirmware),
  589. MACROSTR(Unpublished)
  590. };
  591. static char *UpdateEnumTypeStr[] = {
  592. MACROSTR(Differential),
  593. MACROSTR(Full)
  594. };
  595. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  596. MACROSTR(Accepted),
  597. MACROSTR(Rejected),
  598. MACROSTR(AcceptedCanceled),
  599. MACROSTR(InvalidCertificate),
  600. MACROSTR(RevokedCertificate)
  601. };
  602. static char *UpdateStatusEnumTypeStr[] = {
  603. MACROSTR(Accepted),
  604. MACROSTR(Failed),
  605. MACROSTR(VersionMismatch)
  606. };
  607. static char *UploadLogStatusEnumTypeStr[] = {
  608. MACROSTR(BadMessage),
  609. MACROSTR(Idle),
  610. MACROSTR(NotSupportedOperation),
  611. MACROSTR(PermissionDenied),
  612. MACROSTR(Uploaded),
  613. MACROSTR(UploadFailure),
  614. MACROSTR(Uploading)
  615. };
  616. static char *VPNEnumTypeStr[] = {
  617. MACROSTR(IKEv2),
  618. MACROSTR(IPSec),
  619. MACROSTR(L2TP),
  620. MACROSTR(PPTP)
  621. };
  622. #if 0
  623. static char *ChargePointErrorCodeEnumTypeStr[] = {
  624. MACROSTR(ConnectorLockFailure),
  625. MACROSTR(EVCommunicationError),
  626. MACROSTR(GroundFailure),
  627. MACROSTR(HighTemperature),
  628. MACROSTR(InternalError),
  629. MACROSTR(LocalListConflict),
  630. MACROSTR(NoError),
  631. MACROSTR(OtherError),
  632. MACROSTR(OverCurrentFailure),
  633. MACROSTR(OverVoltage),
  634. MACROSTR(PowerMeterFailure),
  635. MACROSTR(PowerSwitchFailure),
  636. MACROSTR(ReaderFailure),
  637. MACROSTR(ResetFailure),
  638. MACROSTR(UnderVoltage),
  639. MACROSTR(WeakSignal)
  640. };
  641. #endif
  642. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  643. MACROSTR(Accepted),
  644. MACROSTR(Rejected)
  645. };
  646. static char *RemoteStartStopStatusEnumTypeStr[] = {
  647. MACROSTR(Accepted),
  648. MACROSTR(Rejected)
  649. };
  650. #if 0
  651. static char * StopTransactionReasonEnumTypeStr[] = {
  652. MACROSTR(EmergencyStop),
  653. MACROSTR(EVDisconnected),
  654. MACROSTR(HardReset),
  655. MACROSTR(Local),
  656. MACROSTR(Other),
  657. MACROSTR(PowerLoss),
  658. MACROSTR(Reboot),
  659. MACROSTR(Remote),
  660. MACROSTR(SoftReset),
  661. MACROSTR(UnlockCommand),
  662. MACROSTR(DeAuthorized)
  663. };
  664. #endif
  665. //ChargePointMaxProfile
  666. #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile_OCPP20.json"
  667. //TxDefaultProfile
  668. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  669. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  670. struct StatusCodeData *ShmStatusCodeData;
  671. struct PsuData *ShmPsuData ;
  672. struct OCPP20Data *ShmOCPP20Data;
  673. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  674. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  675. //===============================
  676. // Gun Total Numbers
  677. //===============================
  678. static int gunTotalNumber = 0;
  679. static uint8_t gunType[4] = {0};
  680. //===============================
  681. // Local List Version
  682. //===============================
  683. static int localversion=0;
  684. //===============================
  685. // OCPP sign variable
  686. //===============================
  687. static int server_sign = FALSE;
  688. int server_pending = FALSE;
  689. static int BootNotificationInterval = 10;
  690. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  691. //===============================
  692. // OCPP auth variable
  693. //===============================
  694. static int authorizeRetryTimes = 0; //number of Retry times
  695. //===============================
  696. // OCPP other variables
  697. //===============================
  698. static int HeartBeatWaitTime = 10;
  699. static int FirstHeartBeat = 0;
  700. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  701. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  702. static char CurrentChargingProfileScheduleStr[30] = {0};
  703. //========================================
  704. // OCPP status/previous related variables
  705. //========================================
  706. static int GunStatusInterval = 10;
  707. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  708. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  709. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  710. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  711. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  712. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  713. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  714. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  715. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  716. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  717. static int TransactionMessageAttemptsValue = 0;
  718. static int TransactionMessageRetryIntervalValue = 0;
  719. static struct AuthorizationData idTagQuery;
  720. //=============================================
  721. // OCPP HeartBeat Response Not Receive Counts
  722. //============================================
  723. static int HeartBeatWithNOResponse = 0;
  724. static int HeartBeatCountPerHour = 0;
  725. sqlite3 *db;
  726. int TransactionMessageAttemptsGet(void);
  727. int TransactionMessageRetryIntervalGet(void);
  728. int GetOcppConnStatus(void);
  729. void SetOcppConnStatus(uint8_t status);
  730. int setKeyValue(char *key, char *value);
  731. void OCPP_get_TableAuthlocalAllData(void);
  732. void processUnkownKey(void);
  733. struct StructOCPPMeterValue
  734. {
  735. unsigned char TimeStamp[28];
  736. struct StructSampledValue SampledValue[10];
  737. };
  738. struct ClientTime
  739. {
  740. unsigned int Heartbeat;
  741. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  742. unsigned int StartTransaction;
  743. unsigned int StopTransaction;
  744. unsigned int MeterValues[CONNECTOR_QUANTITY];
  745. }clientTime;
  746. typedef union
  747. {
  748. //Operations Initiated by Central System
  749. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  750. struct
  751. {
  752. //CsMsgValue[0]
  753. unsigned char StatusNotificationReq:1; //bit 0,
  754. unsigned char StatusNotificationConf:1; //bit 1,
  755. unsigned char TriggerMeterValueReq:1; //bit 2,
  756. unsigned char TransactionEventReq:1; //bit 3,
  757. unsigned char SampleMeterReq:1; //bit 4,
  758. unsigned char ClockAlignMeterReq:1; //bit 5,
  759. unsigned char :2;
  760. }bits[CONNECTOR_QUANTITY];
  761. }CpinitiateMsg;
  762. CpinitiateMsg cpinitateMsg;
  763. //=========================================
  764. // Date time related function
  765. //=========================================
  766. void getNowDatetime(uint8_t *data)
  767. {
  768. time_t t = time(NULL);
  769. struct tm tm = *localtime(&t);
  770. sprintf((char*)data, "%04d-%02d-%02dT%02d:%02d:%02dZ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  771. }
  772. //=========================================
  773. // Sqlite3 related function
  774. //=========================================
  775. int DB_Initial()
  776. {
  777. int result = PASS;
  778. char* errMsg = NULL;
  779. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  780. "idToken text UNIQUE,"
  781. "type text,"
  782. "status text,"
  783. "cacheExpiryDateTime text,"
  784. "chargingPriority integer,"
  785. "language1 text,"
  786. "evseId text,"
  787. "language2 text,"
  788. "groupIdToken_idToken text,"
  789. "groupIdToken_type text,"
  790. "personalMessage text);";
  791. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  792. "idToken text UNIQUE,"
  793. "type text,"
  794. "status text,"
  795. "cacheExpiryDateTime text,"
  796. "chargingPriority integer,"
  797. "language1 text,"
  798. "evseId text,"
  799. "language2 text,"
  800. "groupIdToken_idToken text,"
  801. "groupIdToken_type text,"
  802. "personalMessage text,"
  803. "version text);";
  804. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  805. "componentName text NOT NULL ,"
  806. "componentInstance text, "
  807. "variableName text NOT NULL, "
  808. "variableInstance text, "
  809. "variableCharacteristicsDataType integer, "
  810. "variableCharacteristicsUnit text, "
  811. "variableCharacteristicsMaxLimit real,"
  812. "variableAttributesType text, "
  813. "variableAttributesTypeMutability text, "
  814. "variableAttributesTypeValue text, "
  815. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  816. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  817. "type text);";
  818. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  819. "slot integer UNIQUE, connectionData text);";
  820. char *sqlTransaction = "create table if not exists ocpp20_transaction_record (idx integer primary key,"
  821. "occurDatetime text,"
  822. "message_type text,"
  823. "message_content text)";
  824. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  825. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  826. {
  827. result = FAIL;
  828. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  829. sqlite3_close(db);
  830. }
  831. else
  832. {
  833. DEBUG_INFO( "OCPP local database open successfully.\n");
  834. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  835. {
  836. result = FAIL;
  837. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  838. }
  839. else
  840. {
  841. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  842. }
  843. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  844. {
  845. result = FAIL;
  846. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  847. }
  848. else
  849. {
  850. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  851. }
  852. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  853. {
  854. result = FAIL;
  855. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  856. }
  857. else
  858. {
  859. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  860. }
  861. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  862. {
  863. result = FAIL;
  864. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  865. }
  866. else
  867. {
  868. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  869. }
  870. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  871. {
  872. result = FAIL;
  873. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  874. }
  875. else
  876. {
  877. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  878. }
  879. if (sqlite3_exec(db, sqlTransaction, 0, 0, &errMsg) != SQLITE_OK)
  880. {
  881. result = FAIL;
  882. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_transaction_record table error message: %s\n", errMsg);
  883. }
  884. else
  885. {
  886. DEBUG_INFO( "Create OCPP 2.0 ocpp20_transaction_record table successfully\n");
  887. }
  888. //sqlite3_close(db);
  889. }
  890. return result;
  891. }
  892. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  893. {
  894. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  895. return 0;
  896. }
  897. void DB_getListVerion()
  898. {
  899. char sql[256];
  900. char* errMsg = NULL;
  901. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  902. /* Execute SQL statement */
  903. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  904. {
  905. DEBUG_INFO("SQL error: %s", errMsg);
  906. }
  907. }
  908. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  909. {
  910. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  911. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  912. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  913. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  914. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  915. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  916. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  917. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  918. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  919. return 0;
  920. }
  921. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  922. {
  923. char sql[256];
  924. char* errMsg = NULL;
  925. memset(&idTagQuery, 0, sizeof(idTagQuery));
  926. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  927. if(isQueryFromCache)
  928. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  929. else
  930. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  931. /* Execute SQL statement */
  932. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  933. {
  934. DEBUG_INFO("SQL error: %s", errMsg);
  935. }
  936. }
  937. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  938. {
  939. for (int i = 0; i < columnCount; i++)
  940. {
  941. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  942. }
  943. return 0;
  944. }
  945. void DB_get_TableAuthlocalAllData(void)
  946. {
  947. char sql[256];
  948. char* errMsg = NULL;
  949. sprintf(sql,"select * from ocpp20_auth_local;");
  950. /* Execute SQL statement */
  951. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  952. {
  953. DEBUG_INFO("SQL error: %s", errMsg);
  954. }
  955. }
  956. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  957. {
  958. for(int i = 0; i<columnCount; i++)
  959. {
  960. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  961. }
  962. return 0;
  963. }
  964. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  965. {
  966. int result = PASS;
  967. char sql[512];
  968. char* errMsg = NULL;
  969. 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;",
  970. data->idToken.idToken,
  971. data->idToken.type,
  972. data->idTokenInfo.status,
  973. data->idTokenInfo.cacheExpiryDateTime,
  974. data->idTokenInfo.chargingPriority,
  975. data->idTokenInfo.language1,
  976. data->idTokenInfo.language2,
  977. data->idTokenInfo.groupIdToken.idToken,
  978. data->idTokenInfo.groupIdToken.type,
  979. listVersion);
  980. //* Execute SQL statement */
  981. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  982. {
  983. DEBUG_INFO("SQL error: %s\n", errMsg);
  984. result = FAIL;
  985. }
  986. else
  987. {
  988. memset(sql, 0, ARRAY_SIZE(sql));
  989. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  990. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  991. {
  992. DEBUG_INFO("SQL error: %s\n", errMsg);
  993. result = FAIL;
  994. }
  995. }
  996. return result;
  997. }
  998. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  999. {
  1000. int result = PASS;
  1001. char sql[512];
  1002. char* errMsg = NULL;
  1003. 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;",
  1004. idToken->idToken,
  1005. idToken->type,
  1006. idTokenInfo->status,
  1007. idTokenInfo->cacheExpiryDateTime,
  1008. idTokenInfo->chargingPriority,
  1009. idTokenInfo->language1,
  1010. idTokenInfo->language2,
  1011. idTokenInfo->groupIdToken.idToken,
  1012. idTokenInfo->groupIdToken.type);
  1013. //* Execute SQL statement */
  1014. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1015. {
  1016. DEBUG_INFO("SQL error: %s\n", errMsg);
  1017. result = FAIL;
  1018. }
  1019. return result;
  1020. }
  1021. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1022. {
  1023. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1024. // printf("localversion=%d\n", localversion);
  1025. return 0;
  1026. }
  1027. void DB_deleteIdTag(char idTag[])
  1028. {
  1029. char sql[512];
  1030. char* errMsg = NULL;
  1031. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1032. //* Execute SQL statement */
  1033. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1034. {
  1035. DEBUG_INFO("SQL error: %s", errMsg);
  1036. }
  1037. }
  1038. int DB_cleanLocalList()
  1039. {
  1040. int result = PASS;
  1041. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1042. char *errMsg = 0;
  1043. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1044. {
  1045. DEBUG_INFO("%s\n", errMsg);
  1046. result = FAIL;
  1047. }
  1048. return result;
  1049. }
  1050. int DB_cleanLocalCache()
  1051. {
  1052. int result = PASS;
  1053. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1054. char *errMsg = 0;
  1055. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1056. {
  1057. DEBUG_INFO("%s\n", errMsg);
  1058. result = FAIL;
  1059. }
  1060. return result;
  1061. }
  1062. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1063. {
  1064. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1065. return 0;
  1066. }
  1067. void DB_getBooType()
  1068. {
  1069. char sql[256];
  1070. char* errMsg = NULL;
  1071. sprintf(sql,"select * from ocpp20_boot_type;");
  1072. /* Execute SQL statement */
  1073. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1074. {
  1075. DEBUG_INFO("SQL error: %s\n", errMsg);
  1076. }
  1077. }
  1078. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1079. {
  1080. for(int i = 0; i<columnCount; i++)
  1081. {
  1082. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1083. }
  1084. return 0;
  1085. }
  1086. int DB_updateBootType(BootReasonEnumType reason)
  1087. {
  1088. int result = PASS;
  1089. char sql[512];
  1090. char* errMsg = NULL;
  1091. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1092. //* Execute SQL statement */
  1093. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1094. {
  1095. DEBUG_INFO("SQL error: %s\n", errMsg);
  1096. result = FAIL;
  1097. }
  1098. return result;
  1099. }
  1100. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1101. {
  1102. for(int i = 0; i<columnCount; i++)
  1103. {
  1104. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1105. }
  1106. return 0;
  1107. }
  1108. int DB_variableSaveToDb(struct ReportDataType *variable)
  1109. {
  1110. int result = FAIL;
  1111. char sql[4096];
  1112. char* errMsg = NULL;
  1113. 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;",
  1114. variable->component.name,
  1115. variable->component.instance,
  1116. variable->variable.name,
  1117. variable->variable.instance,
  1118. variable->variableCharacteristics.dataType,
  1119. variable->variableCharacteristics.unit,
  1120. variable->variableCharacteristics.maxLimit,
  1121. variable->variableAttribute[0].type,
  1122. variable->variableAttribute[0].mutability,
  1123. variable->variableAttribute[0].value);
  1124. //* Execute SQL statement */
  1125. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1126. {
  1127. DEBUG_INFO("SQL error: %s\n", errMsg);
  1128. result = FAIL;
  1129. }
  1130. return result;
  1131. }
  1132. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1133. {
  1134. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1135. if(atoi(columnValue[0]) == 0)
  1136. {
  1137. DB_updateBootType(BootReasonEnumType_PowerUp);
  1138. // Create variable table content
  1139. /* AlignedDataCtrlr Required item */
  1140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1146. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1153. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1159. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1161. else
  1162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1163. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1168. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 10;
  1169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1172. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1179. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1186. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1192. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1194. else
  1195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1196. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1204. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1205. /* AuthCtrlrVariable Required item */
  1206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1212. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1219. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1226. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1233. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1240. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1247. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1251. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1255. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1256. /* AuthCacheCtrlr Variable Required item*/
  1257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1263. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1270. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1278. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1282. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*100);
  1283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1286. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1293. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1294. /* ClockCtrlr Variable Required item */
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1300. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1301. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1308. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1316. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1323. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1330. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1338. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1345. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1352. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1353. /* ChargingStation Required item */
  1354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1360. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1367. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1374. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1375. /* Connector Required item */
  1376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1382. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1389. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1396. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1397. /* CustomizationCtrlr Required item */
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1404. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1405. /* DeviceDataCtrlr Required item */
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1413. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1421. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1429. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1437. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1440. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1445. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1448. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1453. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1461. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1469. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1470. /* DisplayMessageCtrlr Required item */
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1477. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1484. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "0");
  1491. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1498. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1505. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1506. /* EVSE Required item */
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1513. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1520. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1527. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1534. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1535. /* LocalAuthListCtrlr Required item */
  1536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1542. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1549. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1556. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "50");
  1564. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "2048");
  1572. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1576. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = 1024*1024;
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "5000");
  1580. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1581. /* MonitoringCtrlr Required item */
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1583. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1588. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1591. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1595. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1603. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1611. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1619. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1622. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1627. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1634. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1635. /* OCPPCommCtrlr Required item */
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1642. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1651. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1658. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1659. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1660. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1666. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1673. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1675. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1680. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1688. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1695. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1704. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1713. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1720. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1728. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1730. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1735. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1742. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1743. /* ReservationCtrlr Required item */
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1750. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1752. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1757. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1764. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1765. /* SampledDataCtrlr Required item */
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1772. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1779. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1786. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1788. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, " ");
  1793. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1796. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1801. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1807. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1808. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, " ");
  1815. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1820. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 10;
  1821. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
  1824. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1825. /* SecurityCtrlr Required item */
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1829. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
  1833. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1836. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1837. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
  1841. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1843. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
  1848. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1850. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1855. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1857. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
  1862. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1865. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1869. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1870. /* SmartChargingCtrlr Required item */
  1871. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1877. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1878. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1884. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1891. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1892. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1898. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1899. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  1905. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  1912. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  1913. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  1919. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  1920. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  1926. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  1927. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  1928. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  1929. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  1933. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "3");
  1940. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1944. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  1947. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  1948. /* TariffCostCtrlr Required item */
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  1952. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  1956. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  1958. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  1959. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  1960. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  1964. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  1966. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  1967. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1968. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  1972. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  1980. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  1988. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1992. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  1996. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2000. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  2004. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  2005. /* TxCtrlr Required item */
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2012. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2019. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2020. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2021. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2027. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2028. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2034. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2036. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2041. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2043. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2044. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2045. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2046. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2047. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2048. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2051. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "0");
  2056. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2063. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2064. }
  2065. else
  2066. {
  2067. // Variable name init
  2068. /* AlignedDataCtrlr Required item */
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2085. /* AuthCtrlrVariable Required item */
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2088. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2100. /* AuthCacheCtrlr Variable Required item */
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2111. /* ClockCtrlr Variable Required item */
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2130. /* ChargingStation Required item */
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2137. /* Connector Required item */
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2144. /* CustomizationCtrlr Required item */
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  2147. /* DeviceDataCtrlr Required item */
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2170. /* DisplayMessageCtrlr Required item */
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2181. /* EVSE Required item */
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2190. /* LocalAuthListCtrlr Required item */
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2205. /* MonitoringCtrlr Required item */
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2224. /* OCPPCommCtrlr Required item */
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2256. /* ReservationCtrlr Required item */
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2263. /* SampledDataCtrlr Required item */
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2280. /* SecurityCtrlr Required item */
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2293. /* SmartChargingCtrlr Required item */
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2316. /* TariffCostCtrlr Required item */
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2335. /* TxCtrlr Required item */
  2336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2352. }
  2353. return 0;
  2354. }
  2355. void DB_variableIsCreate()
  2356. {
  2357. char sql[512];
  2358. char* errMsg = NULL;
  2359. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2360. /* Execute SQL statement */
  2361. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2362. {
  2363. DEBUG_INFO("SQL error: %s\n", errMsg);
  2364. }
  2365. }
  2366. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2367. {
  2368. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2369. {
  2370. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) == 0) &&
  2371. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) == 0) &&
  2372. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) == 0) &&
  2373. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) == 0))
  2374. {
  2375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2377. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2381. }
  2382. }
  2383. return 0;
  2384. }
  2385. void DB_variableLoadFromDb()
  2386. {
  2387. char sql[512];
  2388. char* errMsg = NULL;
  2389. sprintf(sql,"select * from ocpp20_variable order by idx;");
  2390. /* Execute SQL statement */
  2391. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2392. {
  2393. DEBUG_INFO("SQL error: %s\n", errMsg);
  2394. }
  2395. }
  2396. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2397. {
  2398. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2399. if(columnCount > 0)
  2400. {
  2401. for(int idx=0;idx<columnCount;idx++)
  2402. {
  2403. json_object *SetNetworkProfile;
  2404. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2405. if(!is_error(SetNetworkProfile))
  2406. {
  2407. // Required data
  2408. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2409. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2410. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2411. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2412. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2413. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2414. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2415. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2416. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2417. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2418. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2419. {
  2420. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2421. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2422. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2423. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2424. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2425. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2426. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2427. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2428. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2429. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2430. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2431. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2432. }
  2433. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2434. {
  2435. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2436. {
  2437. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2438. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2439. }
  2440. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2441. {
  2442. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2443. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2444. }
  2445. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2446. {
  2447. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2448. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2449. }
  2450. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2451. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2452. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2453. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2454. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2455. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2456. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2457. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2458. }
  2459. }
  2460. json_object_put(SetNetworkProfile);
  2461. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2462. }
  2463. }
  2464. return 0;
  2465. }
  2466. void DB_getNetworkProfileFromDb()
  2467. {
  2468. char sql[512];
  2469. char* errMsg = NULL;
  2470. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2471. /* Execute SQL statement */
  2472. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2473. {
  2474. DEBUG_INFO("SQL error: %s\n", errMsg);
  2475. }
  2476. }
  2477. int DB_addNetworkProfile(int slot, char *data)
  2478. {
  2479. int result = PASS;
  2480. char sql[512];
  2481. char* errMsg = NULL;
  2482. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2483. slot,
  2484. data);
  2485. //* Execute SQL statement */
  2486. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2487. {
  2488. DEBUG_INFO("SQL error: %s\n", errMsg);
  2489. result = FAIL;
  2490. }
  2491. return result;
  2492. }
  2493. int DB_deleteNetworkProfile(int slot)
  2494. {
  2495. int result = PASS;
  2496. char sql[512];
  2497. char* errMsg = NULL;
  2498. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2499. //* Execute SQL statement */
  2500. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2501. {
  2502. DEBUG_INFO("SQL error: %s", errMsg);
  2503. result = FAIL;
  2504. }
  2505. return result;
  2506. }
  2507. int getCurrentYear()
  2508. {
  2509. int result = 0;
  2510. time_t CurrentTime;
  2511. struct tm *tm;
  2512. CurrentTime = time(NULL);
  2513. tm=localtime(&CurrentTime);
  2514. result = (tm->tm_year + 1900);
  2515. return result;
  2516. }
  2517. int OCPP_insert_transaction_msg(uint8_t isStartTransaction, char *transactionMsg)
  2518. {
  2519. int result = PASS;
  2520. char* errMsg = NULL;
  2521. char sqlStr[8192];
  2522. sprintf(sqlStr, "insert into ocpp20_transaction_record(occurDatetime, message_type, message_content) values(CURRENT_TIMESTAMP, '%s', '%s');", (isStartTransaction?"startTransaction":"stopTransaction"), transactionMsg);
  2523. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2524. {
  2525. result = FAIL;
  2526. DEBUG_INFO( "Insert local transaction record error message: %s\n", errMsg);
  2527. }
  2528. sprintf(sqlStr, "delete from ocpp20_transaction_record where (idx < (select idx from ocpp_transaction_record order by idx desc limit 1)-2000) and (occurDatetime < '%04d-01-01 00:00:00');", (getCurrentYear()-3));
  2529. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2530. {
  2531. result = FAIL;
  2532. DEBUG_INFO( "delete local transaction record error message: %s\n", errMsg);
  2533. }
  2534. return result;
  2535. }
  2536. //==========================================
  2537. // Check time passed since today
  2538. //==========================================
  2539. long long DiffTimebWithNow(struct timeb ST)
  2540. {
  2541. //return milli-second
  2542. struct timeb ET;
  2543. long long StartTime,StopTime;
  2544. ftime(&ET);
  2545. StartTime=(long long)ST.time;
  2546. StopTime=(long long)ET.time;
  2547. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2548. }
  2549. int getTimePassSinceToday()
  2550. {
  2551. int result = -1;
  2552. time_t t;
  2553. struct tm *tmStartToday;
  2554. struct timeb tbStartToday;
  2555. t=time(NULL);
  2556. tmStartToday=localtime(&t);
  2557. tmStartToday->tm_hour = 0;
  2558. tmStartToday->tm_min = 0;
  2559. tmStartToday->tm_sec = 0;
  2560. tbStartToday.time = mktime(tmStartToday);
  2561. tbStartToday.millitm = 0;
  2562. result = DiffTimebWithNow(tbStartToday)/1000;
  2563. return result;
  2564. }
  2565. int syncDateTimeRTC(uint8_t *data)
  2566. {
  2567. struct ParsingResult
  2568. {
  2569. int result;
  2570. int scanedElement;
  2571. int year;
  2572. int month;
  2573. int mday;
  2574. int hour;
  2575. int min;
  2576. int sec;
  2577. int tz_hour;
  2578. int tz_min;
  2579. float minSec;
  2580. }result;
  2581. struct tm tmOrg;
  2582. struct tm *tmTarget;
  2583. struct timeb tbTarget;
  2584. char buf[128];
  2585. memset(&result, 0x00, sizeof(struct ParsingResult));
  2586. result.result = PASS;
  2587. if(strstr((char*)data, ".") != NULL)
  2588. {
  2589. // Original data with mini second
  2590. if(strstr((char*)data, "Z") != NULL)
  2591. {
  2592. // Original data with Z
  2593. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%fZ",
  2594. &result.year,
  2595. &result.month,
  2596. &result.mday,
  2597. &result.hour,
  2598. &result.min,
  2599. &result.sec,
  2600. &result.minSec);
  2601. }
  2602. else
  2603. {
  2604. // Original data without Z
  2605. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  2606. &result.year,
  2607. &result.month,
  2608. &result.mday,
  2609. &result.hour,
  2610. &result.min,
  2611. &result.sec,
  2612. &result.minSec,
  2613. &result.tz_hour,
  2614. &result.tz_min);
  2615. }
  2616. }
  2617. else
  2618. {
  2619. // Original data without mini second
  2620. if(strstr((char*)data, "Z") != NULL)
  2621. {
  2622. // Original data with Z
  2623. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%dZ",
  2624. &result.year,
  2625. &result.month,
  2626. &result.mday,
  2627. &result.hour,
  2628. &result.min,
  2629. &result.sec);
  2630. }
  2631. else
  2632. {
  2633. // Original data without Z
  2634. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d%d:%d",
  2635. &result.year,
  2636. &result.month,
  2637. &result.mday,
  2638. &result.hour,
  2639. &result.min,
  2640. &result.sec,
  2641. &result.tz_hour,
  2642. &result.tz_min);
  2643. }
  2644. }
  2645. tmOrg.tm_year = result.year - 1900;
  2646. tmOrg.tm_mon = result.month - 1;
  2647. tmOrg.tm_mday = result.mday;
  2648. tmOrg.tm_hour = result.hour;
  2649. tmOrg.tm_min = result.min;
  2650. tmOrg.tm_sec = result.sec;
  2651. tmOrg.tm_gmtoff = 0;
  2652. tbTarget.time = mktime(&tmOrg);
  2653. tbTarget.timezone = 0;
  2654. tbTarget.time -= (result.tz_hour*3600) + (result.tz_min*60*(result.tz_hour>=0?1:-1));
  2655. tmTarget = gmtime(&tbTarget.time);
  2656. sprintf(buf, "date -s '%04d-%02d-%02d %02d:%02d:%02d'", (tmTarget->tm_year+1900), (tmTarget->tm_mon+1), tmTarget->tm_mday, tmTarget->tm_hour, tmTarget->tm_min, tmTarget->tm_sec);
  2657. //DEBUG_INFO(" org date time: %s\n", data);
  2658. //DEBUG_INFO("parse date time: %s\n", buf);
  2659. system(buf);
  2660. system("/sbin/hwclock -w --systohc");
  2661. if(result.scanedElement < 6)
  2662. result.result = FAIL;
  2663. return result.result;
  2664. }
  2665. //==========================================
  2666. // GetCompositeSchedule logic related function
  2667. //==========================================
  2668. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2669. {
  2670. //return milli-second
  2671. unsigned int StartTime,StopTime;
  2672. StartTime=(unsigned int)ST.time;
  2673. StopTime=(unsigned int)ET.time;
  2674. return (StopTime-StartTime);
  2675. }
  2676. int DiffTimebWithNowSec(struct timeb ST)
  2677. {
  2678. //return milli-second
  2679. struct timeb ET;
  2680. unsigned int StartTime,StopTime;
  2681. ftime(&ET);
  2682. StartTime=(unsigned int)ST.time;
  2683. StopTime=(unsigned int)ET.time;
  2684. return (StopTime-StartTime);
  2685. }
  2686. int getStartStop(uint8_t *start, uint8_t *stop)
  2687. {
  2688. int result = -1;
  2689. struct tm tmStart;
  2690. struct timeb tbStart;
  2691. struct tm tmStop;
  2692. struct timeb tbStop;
  2693. 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) &&
  2694. (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))
  2695. {
  2696. //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);
  2697. //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);
  2698. tmStart.tm_year -= 1900;
  2699. tmStart.tm_mon -= 1;
  2700. tbStart.time = mktime(&tmStart);
  2701. tbStart.millitm = 0;
  2702. tmStop.tm_year -= 1900;
  2703. tmStop.tm_mon -= 1;
  2704. tbStop.time = mktime(&tmStop);
  2705. tbStop.millitm = 0;
  2706. result = DiffTimebSec(tbStart, tbStop);
  2707. //DEBUG_INFO("getStartStop(): %d\n", result);
  2708. }
  2709. else
  2710. {
  2711. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2712. }
  2713. return result;
  2714. }
  2715. int isOvertNow(uint8_t *start)
  2716. {
  2717. int result = NO;
  2718. struct tm tmStart;
  2719. struct timeb tbStart;
  2720. 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))
  2721. {
  2722. //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);
  2723. tmStart.tm_year -= 1900;
  2724. tmStart.tm_mon -= 1;
  2725. tbStart.time = mktime(&tmStart);
  2726. tbStart.millitm = 0;
  2727. if(DiffTimebWithNowSec(tbStart) <= 0)
  2728. result = NO;
  2729. else
  2730. result = YES;
  2731. }
  2732. else
  2733. {
  2734. DEBUG_WARN("Start date parsing error.\n");
  2735. }
  2736. return result;
  2737. }
  2738. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2739. {
  2740. int result = -1;
  2741. struct tm tmStart;
  2742. struct timeb tbStart;
  2743. struct tm tmStop;
  2744. struct timeb tbStop;
  2745. 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) &&
  2746. (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))
  2747. {
  2748. tmStart.tm_year -= 1900;
  2749. tmStart.tm_mon -= 1;
  2750. tbStart.time = mktime(&tmStart);
  2751. tbStart.millitm = 0;
  2752. tmStop.tm_year -= 1900;
  2753. tmStop.tm_mon -= 1;
  2754. tbStop.time = mktime(&tmStop);
  2755. tbStop.millitm = 0;
  2756. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2757. }
  2758. return result;
  2759. }
  2760. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  2761. {
  2762. FILE *fp;
  2763. char profileFileName[128];
  2764. char *line = NULL;
  2765. size_t len = 0;
  2766. time_t CurrentTime;
  2767. struct tm *tmComposite;
  2768. struct ChargingProfileType maxProfile;
  2769. struct ChargingProfileType defaultTxProfile;
  2770. struct ChargingProfileType txProfile;
  2771. struct ChargingSchedulePeriodType tmpPeriod;
  2772. uint8_t limitMax=0;
  2773. uint8_t limitDef=0;
  2774. uint8_t limitTx=0;
  2775. int compositePeriodIdx = 0;
  2776. CurrentTime = time(NULL);
  2777. tmComposite=localtime(&CurrentTime);
  2778. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].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);
  2779. if(isUnitA)
  2780. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit, "A");
  2781. else
  2782. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit, "W");
  2783. compositeProfile->chargingSchedule[idxSchedule].duration = durationReq;
  2784. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  2785. {
  2786. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2787. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  2788. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2789. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  2790. }
  2791. compositeProfile->id = 0;
  2792. compositeProfile->stackLevel = 99 ;
  2793. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  2794. maxProfile.id = -1;
  2795. defaultTxProfile.id = -1;
  2796. txProfile.id = -1;
  2797. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  2798. defaultTxProfile.chargingSchedule[idxSchedule].duration = -1;
  2799. txProfile.chargingSchedule[idxSchedule].duration = -1;
  2800. system("yes|rm /tmp/*.json");
  2801. system("cp /Storage/OCPP/*.json /tmp");
  2802. /*
  2803. * Search valid charging profile
  2804. */
  2805. //DEBUG_INFO("====================================\n");
  2806. // Search tx profile
  2807. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  2808. if((access(profileFileName, F_OK))!=-1)
  2809. {
  2810. fp = fopen(profileFileName, "r");
  2811. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  2812. {
  2813. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2814. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  2815. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2816. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2817. }
  2818. txProfile.id = -1;
  2819. txProfile.stackLevel = -1;
  2820. while(getline(&line, &len, fp) != -1)
  2821. {
  2822. json_object *obj = NULL;
  2823. obj = json_tokener_parse(line);
  2824. if(is_error(obj))
  2825. {
  2826. DEBUG_ERROR("Parse txProfile from file error.\n");
  2827. }
  2828. else
  2829. {
  2830. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  2831. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  2832. )
  2833. {
  2834. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2835. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2836. )
  2837. {
  2838. struct tm tmFrom, tmTo;
  2839. struct timeb tbFrom, tbTo;
  2840. 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) &&
  2841. (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))
  2842. {
  2843. tmFrom.tm_year -= 1900;
  2844. tmFrom.tm_mon -= 1;
  2845. tbFrom.time = mktime(&tmFrom);
  2846. tmTo.tm_year -= 1900;
  2847. tmTo.tm_mon -= 1;
  2848. tbTo.time = mktime(&tmTo);
  2849. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2850. {
  2851. if(txProfile.id == -1)
  2852. DEBUG_INFO("TxProfile found.\n");
  2853. else
  2854. DEBUG_INFO("TxProfile updated.\n");
  2855. // Required item
  2856. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2857. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2858. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2859. if(isUnitA)
  2860. {
  2861. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  2862. 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++)
  2863. {
  2864. txProfile.chargingSchedule[idxSchedule].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"));
  2865. txProfile.chargingSchedule[idxSchedule].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?
  2866. 3:
  2867. 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")));
  2868. txProfile.chargingSchedule[idxSchedule].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*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):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")));
  2869. }
  2870. }
  2871. else
  2872. {
  2873. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  2874. 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++)
  2875. {
  2876. txProfile.chargingSchedule[idxSchedule].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"));
  2877. txProfile.chargingSchedule[idxSchedule].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?
  2878. 3:
  2879. 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")));
  2880. txProfile.chargingSchedule[idxSchedule].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")):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*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  2881. }
  2882. }
  2883. // Optional item
  2884. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2885. {
  2886. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2887. }
  2888. else
  2889. {
  2890. sprintf((char*)txProfile.validFrom, " ");
  2891. }
  2892. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2893. {
  2894. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2895. }
  2896. else
  2897. {
  2898. sprintf((char*)txProfile.validTo, " ");
  2899. }
  2900. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2901. {
  2902. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2903. }
  2904. else
  2905. {
  2906. sprintf((char*)txProfile.recurrencyKind, " ");
  2907. }
  2908. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2909. {
  2910. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2911. }
  2912. else
  2913. {
  2914. sprintf((char*)txProfile.transactionId, " ");
  2915. }
  2916. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2917. {
  2918. txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2919. }
  2920. else
  2921. {
  2922. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  2923. }
  2924. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2925. {
  2926. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  2927. }
  2928. else
  2929. {
  2930. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  2931. }
  2932. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2933. {
  2934. txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2935. }
  2936. else
  2937. {
  2938. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  2939. }
  2940. }
  2941. }
  2942. }
  2943. else
  2944. {
  2945. if(txProfile.id == -1)
  2946. DEBUG_INFO("TxProfile found.\n");
  2947. else
  2948. DEBUG_INFO("TxProfile updated.\n");
  2949. // Required item
  2950. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2951. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2952. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2953. if(isUnitA)
  2954. {
  2955. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  2956. 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++)
  2957. {
  2958. txProfile.chargingSchedule[idxSchedule].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"));
  2959. txProfile.chargingSchedule[idxSchedule].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?
  2960. 3:
  2961. 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")));
  2962. txProfile.chargingSchedule[idxSchedule].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*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):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")));
  2963. }
  2964. }
  2965. else
  2966. {
  2967. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  2968. 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++)
  2969. {
  2970. txProfile.chargingSchedule[idxSchedule].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"));
  2971. txProfile.chargingSchedule[idxSchedule].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?
  2972. 3:
  2973. 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")));
  2974. txProfile.chargingSchedule[idxSchedule].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")):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*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  2975. }
  2976. }
  2977. // Optional item
  2978. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2979. {
  2980. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2981. }
  2982. else
  2983. {
  2984. sprintf((char*)txProfile.validFrom, " ");
  2985. }
  2986. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2987. {
  2988. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2989. }
  2990. else
  2991. {
  2992. sprintf((char*)txProfile.validTo, " ");
  2993. }
  2994. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2995. {
  2996. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2997. }
  2998. else
  2999. {
  3000. sprintf((char*)txProfile.recurrencyKind, " ");
  3001. }
  3002. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3003. {
  3004. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3005. }
  3006. else
  3007. {
  3008. sprintf((char*)txProfile.transactionId, " ");
  3009. }
  3010. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3011. {
  3012. txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3013. }
  3014. else
  3015. {
  3016. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  3017. }
  3018. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3019. {
  3020. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3021. }
  3022. else
  3023. {
  3024. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3025. }
  3026. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3027. {
  3028. txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3029. }
  3030. else
  3031. {
  3032. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3033. }
  3034. }
  3035. }
  3036. }
  3037. json_object_put(obj);
  3038. }
  3039. fclose(fp);
  3040. /*
  3041. if(txProfile.ChargingProfileId != -1)
  3042. {
  3043. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3044. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3045. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3046. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3047. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3048. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3049. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3050. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[idxSchedule].StartSchedule);
  3051. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  3052. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3053. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3054. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3055. {
  3056. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3057. {
  3058. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3059. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3060. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3061. }
  3062. }
  3063. }
  3064. else
  3065. DEBUG_INFO("TxProfile not found.\n");*/
  3066. }
  3067. // Search default tx profile
  3068. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  3069. if((access(profileFileName, F_OK))==-1)
  3070. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  3071. if((access(profileFileName, F_OK))!=-1)
  3072. {
  3073. fp = fopen(profileFileName, "r");
  3074. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3075. {
  3076. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3077. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3078. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3079. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3080. }
  3081. defaultTxProfile.id = -1;
  3082. defaultTxProfile.stackLevel = -1;
  3083. while(getline(&line, &len, fp) != -1)
  3084. {
  3085. json_object *obj = NULL;
  3086. obj = json_tokener_parse(line);
  3087. if(is_error(obj))
  3088. {
  3089. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  3090. }
  3091. else
  3092. {
  3093. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  3094. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  3095. )
  3096. {
  3097. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3098. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3099. )
  3100. {
  3101. struct tm tmFrom, tmTo;
  3102. struct timeb tbFrom, tbTo;
  3103. 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) &&
  3104. (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))
  3105. {
  3106. tmFrom.tm_year -= 1900;
  3107. tmFrom.tm_mon -= 1;
  3108. tbFrom.time = mktime(&tmFrom);
  3109. tmTo.tm_year -= 1900;
  3110. tmTo.tm_mon -= 1;
  3111. tbTo.time = mktime(&tmTo);
  3112. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3113. {
  3114. if(defaultTxProfile.id == -1)
  3115. DEBUG_INFO("TxDefaultProfile found.\n");
  3116. else
  3117. DEBUG_INFO("TxDefaultProfile updated.\n");
  3118. // Required item
  3119. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3120. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3121. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3122. if(isUnitA)
  3123. {
  3124. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3125. 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++)
  3126. {
  3127. defaultTxProfile.chargingSchedule[idxSchedule].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"));
  3128. defaultTxProfile.chargingSchedule[idxSchedule].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?
  3129. 3:
  3130. 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")));
  3131. defaultTxProfile.chargingSchedule[idxSchedule].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*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):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")));
  3132. }
  3133. }
  3134. else
  3135. {
  3136. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3137. 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++)
  3138. {
  3139. defaultTxProfile.chargingSchedule[idxSchedule].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"));
  3140. defaultTxProfile.chargingSchedule[idxSchedule].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?
  3141. 3:
  3142. 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")));
  3143. defaultTxProfile.chargingSchedule[idxSchedule].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")):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*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3144. }
  3145. }
  3146. // Optional item
  3147. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3148. {
  3149. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3150. }
  3151. else
  3152. {
  3153. sprintf((char*)defaultTxProfile.validFrom, " ");
  3154. }
  3155. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3156. {
  3157. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3158. }
  3159. else
  3160. {
  3161. sprintf((char*)defaultTxProfile.validTo, " ");
  3162. }
  3163. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3164. {
  3165. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3166. }
  3167. else
  3168. {
  3169. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3170. }
  3171. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3172. {
  3173. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3174. }
  3175. else
  3176. {
  3177. sprintf((char*)defaultTxProfile.transactionId, " ");
  3178. }
  3179. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3180. {
  3181. defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3182. }
  3183. else
  3184. {
  3185. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3186. }
  3187. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3188. {
  3189. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3190. }
  3191. else
  3192. {
  3193. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3194. }
  3195. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3196. {
  3197. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3198. }
  3199. else
  3200. {
  3201. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3202. }
  3203. }
  3204. }
  3205. }
  3206. else
  3207. {
  3208. if(defaultTxProfile.id == -1)
  3209. DEBUG_INFO("TxDefaultProfile found.\n");
  3210. else
  3211. DEBUG_INFO("TxDefaultProfile updated.\n");
  3212. // Required item
  3213. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3214. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3215. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3216. if(isUnitA)
  3217. {
  3218. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3219. 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++)
  3220. {
  3221. defaultTxProfile.chargingSchedule[idxSchedule].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"));
  3222. defaultTxProfile.chargingSchedule[idxSchedule].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?
  3223. 3:
  3224. 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")));
  3225. defaultTxProfile.chargingSchedule[idxSchedule].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*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):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")));
  3226. }
  3227. }
  3228. else
  3229. {
  3230. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3231. 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++)
  3232. {
  3233. defaultTxProfile.chargingSchedule[idxSchedule].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"));
  3234. defaultTxProfile.chargingSchedule[idxSchedule].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?
  3235. 3:
  3236. 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")));
  3237. defaultTxProfile.chargingSchedule[idxSchedule].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")):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*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3238. }
  3239. }
  3240. // Optional item
  3241. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3242. {
  3243. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3244. }
  3245. else
  3246. {
  3247. sprintf((char*)defaultTxProfile.validFrom, " ");
  3248. }
  3249. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3250. {
  3251. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3252. }
  3253. else
  3254. {
  3255. sprintf((char*)defaultTxProfile.validTo, " ");
  3256. }
  3257. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3258. {
  3259. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3260. }
  3261. else
  3262. {
  3263. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3264. }
  3265. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3266. {
  3267. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3268. }
  3269. else
  3270. {
  3271. sprintf((char*)defaultTxProfile.transactionId, " ");
  3272. }
  3273. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3274. {
  3275. defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3276. }
  3277. else
  3278. {
  3279. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3280. }
  3281. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3282. {
  3283. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3284. }
  3285. else
  3286. {
  3287. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3288. }
  3289. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3290. {
  3291. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3292. }
  3293. else
  3294. {
  3295. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3296. }
  3297. }
  3298. }
  3299. }
  3300. json_object_put(obj);
  3301. }
  3302. fclose(fp);
  3303. /*
  3304. if(defaultTxProfile.ChargingProfileId != -1)
  3305. {
  3306. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3307. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3308. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3309. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3310. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3311. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3312. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3313. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].StartSchedule);
  3314. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  3315. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3316. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3317. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3318. {
  3319. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3320. {
  3321. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3322. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3323. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3324. }
  3325. }
  3326. }
  3327. else
  3328. DEBUG_INFO("TxDefaultProfile not found.\n");
  3329. DEBUG_INFO("------------------------------------\n");*/
  3330. }
  3331. // Search max profile
  3332. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  3333. if((access(profileFileName, F_OK))!=-1)
  3334. {
  3335. fp = fopen(profileFileName, "r");
  3336. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3337. {
  3338. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3339. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3340. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3341. }
  3342. maxProfile.id = -1;
  3343. maxProfile.stackLevel = -1;
  3344. while(getline(&line, &len, fp) != -1)
  3345. {
  3346. json_object *obj = NULL;
  3347. obj = json_tokener_parse(line);
  3348. if(is_error(obj))
  3349. {
  3350. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3351. }
  3352. else
  3353. {
  3354. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  3355. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3356. )
  3357. {
  3358. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3359. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3360. )
  3361. {
  3362. struct tm tmFrom, tmTo;
  3363. struct timeb tbFrom, tbTo;
  3364. 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) &&
  3365. (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))
  3366. {
  3367. tmFrom.tm_year -= 1900;
  3368. tmFrom.tm_mon -= 1;
  3369. tbFrom.time = mktime(&tmFrom);
  3370. tmTo.tm_year -= 1900;
  3371. tmTo.tm_mon -= 1;
  3372. tbTo.time = mktime(&tmTo);
  3373. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3374. {
  3375. if(maxProfile.id == -1)
  3376. DEBUG_INFO("MaxProfile found.\n");
  3377. else
  3378. DEBUG_INFO("MaxProfile updated.\n");
  3379. // Required item
  3380. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3381. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3382. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3383. if(isUnitA)
  3384. {
  3385. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3386. 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++)
  3387. {
  3388. maxProfile.chargingSchedule[idxSchedule].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"));
  3389. maxProfile.chargingSchedule[idxSchedule].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?
  3390. 3:
  3391. 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")));
  3392. maxProfile.chargingSchedule[idxSchedule].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*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):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")));
  3393. }
  3394. }
  3395. else
  3396. {
  3397. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3398. 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++)
  3399. {
  3400. maxProfile.chargingSchedule[idxSchedule].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"));
  3401. maxProfile.chargingSchedule[idxSchedule].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?
  3402. 3:
  3403. 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")));
  3404. maxProfile.chargingSchedule[idxSchedule].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")):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*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3405. }
  3406. }
  3407. // Optional item
  3408. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3409. {
  3410. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3411. }
  3412. else
  3413. {
  3414. sprintf((char*)maxProfile.validFrom, " ");
  3415. }
  3416. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3417. {
  3418. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3419. }
  3420. else
  3421. {
  3422. sprintf((char*)maxProfile.validTo, " ");
  3423. }
  3424. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3425. {
  3426. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3427. }
  3428. else
  3429. {
  3430. sprintf((char*)maxProfile.recurrencyKind, " ");
  3431. }
  3432. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3433. {
  3434. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3435. }
  3436. else
  3437. {
  3438. sprintf((char*)maxProfile.transactionId, " ");
  3439. }
  3440. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3441. {
  3442. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3443. }
  3444. else
  3445. {
  3446. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3447. }
  3448. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3449. {
  3450. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3451. }
  3452. else
  3453. {
  3454. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3455. }
  3456. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3457. {
  3458. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3459. }
  3460. else
  3461. {
  3462. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3463. }
  3464. }
  3465. }
  3466. }
  3467. else
  3468. {
  3469. if(maxProfile.id == -1)
  3470. DEBUG_INFO("MaxProfile found.\n");
  3471. else
  3472. DEBUG_INFO("MaxProfile updated.\n");
  3473. // Required item
  3474. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3475. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3476. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3477. if(isUnitA)
  3478. {
  3479. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3480. 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++)
  3481. {
  3482. maxProfile.chargingSchedule[idxSchedule].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"));
  3483. maxProfile.chargingSchedule[idxSchedule].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?
  3484. 3:
  3485. 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")));
  3486. maxProfile.chargingSchedule[idxSchedule].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*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):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")));
  3487. }
  3488. }
  3489. else
  3490. {
  3491. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3492. 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++)
  3493. {
  3494. maxProfile.chargingSchedule[idxSchedule].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"));
  3495. maxProfile.chargingSchedule[idxSchedule].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?
  3496. 3:
  3497. 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")));
  3498. maxProfile.chargingSchedule[idxSchedule].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")):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*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3499. }
  3500. }
  3501. // Optional item
  3502. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3503. {
  3504. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3505. }
  3506. else
  3507. {
  3508. sprintf((char*)maxProfile.validFrom, " ");
  3509. }
  3510. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3511. {
  3512. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3513. }
  3514. else
  3515. {
  3516. sprintf((char*)maxProfile.validTo, " ");
  3517. }
  3518. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3519. {
  3520. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3521. }
  3522. else
  3523. {
  3524. sprintf((char*)maxProfile.recurrencyKind, " ");
  3525. }
  3526. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3527. {
  3528. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3529. }
  3530. else
  3531. {
  3532. sprintf((char*)maxProfile.transactionId, " ");
  3533. }
  3534. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3535. {
  3536. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3537. }
  3538. else
  3539. {
  3540. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3541. }
  3542. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3543. {
  3544. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3545. }
  3546. else
  3547. {
  3548. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3549. }
  3550. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3551. {
  3552. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3553. }
  3554. else
  3555. {
  3556. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3557. }
  3558. }
  3559. }
  3560. }
  3561. json_object_put(obj);
  3562. }
  3563. fclose(fp);
  3564. /*
  3565. if(maxProfile.ChargingProfileId !=-1)
  3566. {
  3567. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3568. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3569. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3570. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3571. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3572. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3573. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3574. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  3575. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3576. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3577. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3578. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3579. {
  3580. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3581. {
  3582. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3583. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3584. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3585. }
  3586. }
  3587. }
  3588. else
  3589. DEBUG_INFO("MaxProfile not found.\n");
  3590. DEBUG_INFO("------------------------------------\n");*/
  3591. }
  3592. /*
  3593. * Align found profile start schedule & periods
  3594. */
  3595. //DEBUG_INFO("====================================\n");
  3596. /*
  3597. // For local test usage, force modify found profile start schedule info
  3598. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].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);
  3599. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].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);
  3600. sprintf((char*)txProfile.chargingSchedule[idxSchedule].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);
  3601. */
  3602. if(txProfile.id != -1)
  3603. {
  3604. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3605. {
  3606. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  3607. {
  3608. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3609. 0:
  3610. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3611. }
  3612. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3613. {
  3614. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3615. {
  3616. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3617. 0:
  3618. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3619. if(idxPeriod > 0)
  3620. {
  3621. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3622. {
  3623. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3624. }
  3625. }
  3626. }
  3627. }
  3628. }
  3629. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3630. {
  3631. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  3632. {
  3633. txProfile.chargingSchedule[idxSchedule].duration = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?txProfile.chargingSchedule[idxSchedule].duration:((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3634. 0:
  3635. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3636. }
  3637. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3638. {
  3639. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3640. {
  3641. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod:((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3642. 0:
  3643. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3644. if(idxPeriod > 0)
  3645. {
  3646. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3647. {
  3648. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3649. }
  3650. }
  3651. }
  3652. }
  3653. }
  3654. else
  3655. {
  3656. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3657. {
  3658. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  3659. {
  3660. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3661. 0:
  3662. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3663. }
  3664. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3665. {
  3666. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3667. {
  3668. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3669. 0:
  3670. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3671. if(idxPeriod > 0)
  3672. {
  3673. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3674. {
  3675. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3676. }
  3677. }
  3678. }
  3679. }
  3680. }
  3681. else
  3682. {
  3683. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  3684. {
  3685. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3686. 0:
  3687. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3688. }
  3689. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3690. {
  3691. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3692. {
  3693. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3694. 0:
  3695. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3696. if(idxPeriod > 0)
  3697. {
  3698. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3699. {
  3700. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3701. }
  3702. }
  3703. }
  3704. }
  3705. }
  3706. }
  3707. /*
  3708. DEBUG_INFO("txProfile after align.\n");
  3709. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3710. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3711. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3712. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3713. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3714. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3715. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3716. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3717. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  3718. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3719. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3720. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3721. {
  3722. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3723. {
  3724. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3725. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3726. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3727. }
  3728. }*/
  3729. }
  3730. if(defaultTxProfile.id != -1)
  3731. {
  3732. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3733. {
  3734. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  3735. {
  3736. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3737. 0:
  3738. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3739. }
  3740. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3741. {
  3742. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3743. {
  3744. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3745. 0:
  3746. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3747. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  3748. {
  3749. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  3750. }
  3751. if(idxPeriod > 0)
  3752. {
  3753. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3754. {
  3755. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3756. }
  3757. }
  3758. }
  3759. }
  3760. }
  3761. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3762. {
  3763. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  3764. {
  3765. defaultTxProfile.chargingSchedule[idxSchedule].duration = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?defaultTxProfile.chargingSchedule[idxSchedule].duration:((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3766. 0:
  3767. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3768. }
  3769. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3770. {
  3771. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3772. {
  3773. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod:((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3774. 0:
  3775. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3776. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  3777. {
  3778. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  3779. }
  3780. if(idxPeriod > 0)
  3781. {
  3782. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3783. {
  3784. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3785. }
  3786. }
  3787. }
  3788. }
  3789. }
  3790. else
  3791. {
  3792. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3793. {
  3794. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  3795. {
  3796. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3797. 0:
  3798. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3799. }
  3800. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3801. {
  3802. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3803. {
  3804. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3805. 0:
  3806. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3807. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  3808. {
  3809. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  3810. }
  3811. if(idxPeriod > 0)
  3812. {
  3813. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3814. {
  3815. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3816. }
  3817. }
  3818. }
  3819. }
  3820. }
  3821. else
  3822. {
  3823. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  3824. {
  3825. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3826. 0:
  3827. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3828. }
  3829. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3830. {
  3831. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3832. {
  3833. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3834. 0:
  3835. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3836. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  3837. {
  3838. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  3839. }
  3840. if(idxPeriod > 0)
  3841. {
  3842. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3843. {
  3844. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3845. }
  3846. }
  3847. }
  3848. }
  3849. }
  3850. }
  3851. /*
  3852. DEBUG_INFO("defaultTxProfile after align.\n");
  3853. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3854. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3855. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3856. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3857. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3858. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3859. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3860. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3861. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  3862. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3863. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3864. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3865. {
  3866. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3867. {
  3868. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3869. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3870. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3871. }
  3872. }
  3873. DEBUG_INFO("------------------------------------\n");*/
  3874. }
  3875. if(maxProfile.id != -1)
  3876. {
  3877. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3878. {
  3879. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3880. {
  3881. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3882. 0:
  3883. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3884. }
  3885. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3886. {
  3887. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3888. {
  3889. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3890. 0:
  3891. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3892. if(idxPeriod > 0)
  3893. {
  3894. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3895. {
  3896. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3897. }
  3898. }
  3899. }
  3900. }
  3901. }
  3902. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3903. {
  3904. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3905. {
  3906. maxProfile.chargingSchedule[idxSchedule].duration = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?maxProfile.chargingSchedule[idxSchedule].duration:((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3907. 0:
  3908. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  3909. }
  3910. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3911. {
  3912. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3913. {
  3914. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod:((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3915. 0:
  3916. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3917. if(idxPeriod > 0)
  3918. {
  3919. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3920. {
  3921. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3922. }
  3923. }
  3924. }
  3925. }
  3926. }
  3927. else
  3928. {
  3929. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3930. {
  3931. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3932. {
  3933. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3934. 0:
  3935. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3936. }
  3937. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3938. {
  3939. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3940. {
  3941. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3942. 0:
  3943. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3944. if(idxPeriod > 0)
  3945. {
  3946. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3947. {
  3948. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3949. }
  3950. }
  3951. }
  3952. }
  3953. }
  3954. else
  3955. {
  3956. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3957. {
  3958. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3959. 0:
  3960. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3961. }
  3962. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3963. {
  3964. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3965. {
  3966. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3967. 0:
  3968. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3969. if(idxPeriod > 0)
  3970. {
  3971. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3972. {
  3973. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3974. }
  3975. }
  3976. }
  3977. }
  3978. }
  3979. }
  3980. /*
  3981. DEBUG_INFO("MaxProfile after align.\n");
  3982. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3983. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3984. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3985. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3986. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3987. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3988. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3989. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3990. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3991. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3992. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3993. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3994. {
  3995. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3996. {
  3997. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3998. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3999. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4000. }
  4001. }
  4002. DEBUG_INFO("------------------------------------\n");*/
  4003. }
  4004. /*
  4005. * Merge to conposite schedule
  4006. */
  4007. //DEBUG_INFO("====================================\n");
  4008. // Find each profile period quantity
  4009. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4010. {
  4011. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4012. limitMax = idx+1;
  4013. }
  4014. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4015. {
  4016. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4017. limitDef = idx+1;
  4018. }
  4019. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4020. {
  4021. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4022. limitTx = idx+1;
  4023. }
  4024. // TxProfile found, composite schedule based on it
  4025. if(txProfile.id != -1)
  4026. {
  4027. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  4028. {
  4029. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  4030. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  4031. (txProfile.chargingSchedule[idxSchedule].duration > 0))
  4032. {
  4033. if(maxProfile.id != -1)
  4034. {
  4035. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4036. {
  4037. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  4038. {
  4039. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4040. {
  4041. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  4042. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  4043. tmpPeriod.limit = (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit>maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit:txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit);
  4044. }
  4045. else
  4046. {
  4047. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  4048. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  4049. tmpPeriod.limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit;
  4050. }
  4051. }
  4052. if(idxMaxPeriod == (limitMax-1))
  4053. {
  4054. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4055. {
  4056. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4057. {
  4058. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4059. compositePeriodIdx++;
  4060. }
  4061. else
  4062. {
  4063. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4064. }
  4065. }
  4066. }
  4067. }
  4068. }
  4069. else
  4070. {
  4071. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4072. {
  4073. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  4074. compositePeriodIdx++;
  4075. }
  4076. else
  4077. {
  4078. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  4079. }
  4080. }
  4081. }
  4082. if(idxTxPeriod == (limitTx-1))
  4083. {
  4084. if(defaultTxProfile.id != -1)
  4085. {
  4086. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  4087. {
  4088. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  4089. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  4090. (defaultTxProfile.chargingSchedule[idxSchedule].duration>0))
  4091. {
  4092. if(maxProfile.id != -1)
  4093. {
  4094. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4095. {
  4096. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  4097. {
  4098. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4099. {
  4100. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4101. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4102. tmpPeriod.limit = (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit>maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit:defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit);
  4103. }
  4104. else
  4105. {
  4106. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4107. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4108. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  4109. }
  4110. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4111. {
  4112. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4113. {
  4114. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4115. compositePeriodIdx++;
  4116. }
  4117. else
  4118. {
  4119. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4120. }
  4121. }
  4122. break;
  4123. }
  4124. }
  4125. }
  4126. else
  4127. {
  4128. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4129. {
  4130. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4131. compositePeriodIdx++;
  4132. }
  4133. else
  4134. {
  4135. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4136. }
  4137. }
  4138. }
  4139. }
  4140. }
  4141. }
  4142. }
  4143. }
  4144. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  4145. else if(defaultTxProfile.id != -1)
  4146. {
  4147. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  4148. {
  4149. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  4150. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  4151. (defaultTxProfile.chargingSchedule[idxSchedule].duration > 0))
  4152. {
  4153. if(maxProfile.id != -1)
  4154. {
  4155. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4156. {
  4157. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  4158. {
  4159. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4160. {
  4161. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4162. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4163. tmpPeriod.limit = (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit>maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit:defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit);
  4164. }
  4165. else
  4166. {
  4167. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4168. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4169. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  4170. }
  4171. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4172. {
  4173. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4174. {
  4175. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4176. compositePeriodIdx++;
  4177. }
  4178. else
  4179. {
  4180. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4181. }
  4182. }
  4183. break;
  4184. }
  4185. }
  4186. }
  4187. else
  4188. {
  4189. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4190. {
  4191. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4192. compositePeriodIdx++;
  4193. }
  4194. else
  4195. {
  4196. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4197. }
  4198. }
  4199. }
  4200. }
  4201. }
  4202. // Fill other period by MaxProfile
  4203. if(maxProfile.id != -1)
  4204. {
  4205. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4206. {
  4207. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  4208. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  4209. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4210. {
  4211. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  4212. (maxProfile.chargingSchedule[idxSchedule].duration > compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  4213. {
  4214. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  4215. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  4216. tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
  4217. }
  4218. if((maxProfile.chargingSchedule[idxSchedule].duration > compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  4219. {
  4220. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[idxSchedule].duration;
  4221. tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  4222. tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
  4223. }
  4224. if(tmpPeriod.limit != -1)
  4225. {
  4226. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4227. {
  4228. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4229. {
  4230. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4231. compositePeriodIdx++;
  4232. }
  4233. else
  4234. {
  4235. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4236. }
  4237. }
  4238. }
  4239. }
  4240. }
  4241. }
  4242. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  4243. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[idxSchedule].startSchedule);
  4244. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[idxSchedule].duration);
  4245. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit);
  4246. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4247. {
  4248. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  4249. {
  4250. compositeProfile->id = 1;
  4251. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4252. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  4253. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  4254. }
  4255. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  4256. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  4257. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  4258. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  4259. }
  4260. if(line)
  4261. free(line);
  4262. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  4263. }
  4264. //==========================================
  4265. // Init all share memory
  4266. //==========================================
  4267. int InitShareMemory()
  4268. {
  4269. int result = PASS;
  4270. int MeterSMId;
  4271. //creat ShmSysConfigAndInfo
  4272. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  4273. {
  4274. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  4275. result = FAIL;
  4276. }
  4277. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4278. {
  4279. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  4280. result = FAIL;
  4281. }
  4282. else
  4283. {}
  4284. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  4285. {
  4286. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  4287. result = FAIL;
  4288. }
  4289. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4290. {
  4291. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  4292. result = FAIL;
  4293. }
  4294. else
  4295. {}
  4296. //creat ShmPsuData
  4297. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  4298. {
  4299. DEBUG_ERROR("shmget ShmPsuData NG\n");
  4300. result = FAIL;
  4301. }
  4302. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4303. {
  4304. DEBUG_ERROR("shmat ShmPsuData NG\n");
  4305. result = FAIL;
  4306. }
  4307. else
  4308. {}
  4309. //creat ShmOCPP20Data
  4310. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  4311. {
  4312. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  4313. result = FAIL;
  4314. }
  4315. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4316. {
  4317. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  4318. result = FAIL;
  4319. }
  4320. else
  4321. {}
  4322. /****************************** For Initial Settings************************************************/
  4323. /*
  4324. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  4325. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  4326. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  4327. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  4328. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  4329. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  4330. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  4331. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  4332. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  4333. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  4334. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  4335. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  4336. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  4337. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  4338. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  4339. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  4340. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  4341. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  4342. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  4343. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  4344. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  4345. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  4346. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  4347. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  4348. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  4349. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  4350. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  4351. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  4352. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  4353. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  4354. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  4355. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  4356. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  4357. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  4358. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  4359. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  4360. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  4361. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  4362. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  4363. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  4364. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  4365. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  4366. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  4367. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  4368. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  4369. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  4370. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  4371. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  4372. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  4373. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  4374. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  4375. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  4376. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  4377. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  4378. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  4379. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  4380. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  4381. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  4382. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  4383. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  4384. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  4385. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  4386. */
  4387. return result;
  4388. }
  4389. int ProcessShareMemory()
  4390. {
  4391. if(InitShareMemory() == FAIL)
  4392. {
  4393. DEBUG_ERROR("InitShareMemory NG\n");
  4394. if(ShmStatusCodeData!=NULL)
  4395. {
  4396. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  4397. }
  4398. sleep(5);
  4399. return FAIL;
  4400. }
  4401. return PASS;
  4402. }
  4403. //---------------------common routine---------------------------//
  4404. void checkNetworkProfile(void)
  4405. {
  4406. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  4407. json_object *priority;
  4408. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  4409. if(!is_error(priority))
  4410. {
  4411. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  4412. {
  4413. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  4414. {
  4415. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  4416. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  4417. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  4418. {
  4419. memcpy(ShmOCPP20Data->OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  4420. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  4421. break;
  4422. }
  4423. }
  4424. }
  4425. }
  4426. json_object_put(priority);
  4427. DEBUG_INFO("Get network profile URL: %s\n", ShmOCPP20Data->OcppServerURL);
  4428. }
  4429. void CheckSystemValue(void)
  4430. {
  4431. char filenmae[100]={0};
  4432. char str[100]={0};
  4433. int tempIndex = 0;
  4434. //===============================
  4435. // EVSE operation check
  4436. //===============================
  4437. //===============================
  4438. // Heartbeat check
  4439. //===============================
  4440. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  4441. {
  4442. clientTime.Heartbeat = time((time_t*)NULL);
  4443. if(server_sign == TRUE)
  4444. {
  4445. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  4446. }
  4447. else
  4448. {
  4449. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  4450. }
  4451. }
  4452. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  4453. {
  4454. //parameter for test
  4455. sendHeartbeatRequest(0);
  4456. //==============================================
  4457. // Reset Waiting Time
  4458. //==============================================
  4459. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  4460. }
  4461. //===============================
  4462. // CSU Trigger Reset Conf
  4463. //===============================
  4464. if(isWebsocketSendable && (ShmOCPP20Data->MsMsg.bits.ResetConf == ON))
  4465. {
  4466. sendResetConfirmation((char *)ShmOCPP20Data->Reset.guid);
  4467. }
  4468. //===============================
  4469. // CSU Trigger Authorize Request
  4470. //===============================
  4471. if(isWebsocketSendable &&
  4472. (server_sign == TRUE) &&
  4473. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4474. (authorizeRetryTimes < 3))
  4475. {
  4476. sendAuthorizeRequest(0);
  4477. authorizeRetryTimes = authorizeRetryTimes + 1;
  4478. if(authorizeRetryTimes < 3)
  4479. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4480. }
  4481. else if((server_sign == TRUE) &&
  4482. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4483. (authorizeRetryTimes >= 3))
  4484. {
  4485. authorizeRetryTimes = 0;
  4486. SetOcppConnStatus(FALSE);
  4487. server_sign = FALSE;
  4488. }
  4489. else if((server_sign == FALSE) &&
  4490. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  4491. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  4492. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  4493. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  4494. {
  4495. sendAuthorizeRequest(0);
  4496. }
  4497. if(isWebsocketSendable &&
  4498. (server_sign == TRUE) &&
  4499. (ShmOCPP20Data->GetReport.requestId > 0))
  4500. {
  4501. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetReport.componentCriteria);idxCriterion++)
  4502. {
  4503. if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Active]) == 0)
  4504. {
  4505. /*
  4506. * TODO:
  4507. * 1. Report component that are active
  4508. */
  4509. }
  4510. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Available]) == 0)
  4511. {
  4512. /*
  4513. * TODO:
  4514. * 1. Report component that are available
  4515. */
  4516. }
  4517. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Enabled]) == 0)
  4518. {
  4519. /*
  4520. * TODO:
  4521. * 1. Report component that are enable
  4522. */
  4523. }
  4524. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Problem]) == 0)
  4525. {
  4526. /*
  4527. * TODO:
  4528. * 1. Report component that are problem
  4529. */
  4530. }
  4531. else
  4532. {
  4533. /*
  4534. * TODO:
  4535. * 1. Process unknown criteria condition
  4536. */
  4537. }
  4538. }
  4539. ShmOCPP20Data->GetReport.requestId = 0;
  4540. }
  4541. if(isWebsocketSendable &&
  4542. (server_sign == TRUE) &&
  4543. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  4544. {
  4545. uint8_t reportIdx = 0;
  4546. ShmOCPP20Data->NotifyReport.requestId = ShmOCPP20Data->GetBaseReport.requestId;
  4547. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  4548. {
  4549. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  4550. {
  4551. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  4552. {
  4553. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]) == 0) || (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]) == 0))
  4554. {
  4555. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  4556. reportIdx++;
  4557. }
  4558. }
  4559. else
  4560. {
  4561. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4562. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4563. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4564. else
  4565. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4566. sendNotifyReportRequest();
  4567. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4568. reportIdx = 0;
  4569. }
  4570. }
  4571. }
  4572. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  4573. {
  4574. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  4575. {
  4576. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  4577. {
  4578. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  4579. reportIdx++;
  4580. }
  4581. else
  4582. {
  4583. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4584. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4585. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4586. else
  4587. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4588. sendNotifyReportRequest();
  4589. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4590. reportIdx = 0;
  4591. }
  4592. }
  4593. }
  4594. else
  4595. {
  4596. /*
  4597. * TODO:
  4598. * 1. Fill out summary inventory to response message, currently not support
  4599. */
  4600. }
  4601. if(reportIdx > 0)
  4602. {
  4603. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4604. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4605. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4606. else
  4607. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4608. sendNotifyReportRequest();
  4609. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4610. reportIdx = 0;
  4611. }
  4612. ShmOCPP20Data->GetBaseReport.requestId = 0;
  4613. }
  4614. if(isWebsocketSendable &&
  4615. (server_sign == TRUE) &&
  4616. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  4617. {
  4618. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  4619. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  4620. if(ShmOCPP20Data->NotifyEvent.seqNo < INT_MAX)
  4621. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  4622. else
  4623. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  4624. sendNotifyEventRequest();
  4625. memset(&ShmOCPP20Data->NotifyEvent.eventData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)* sizeof(struct EventDataType ));
  4626. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  4627. }
  4628. if(isWebsocketSendable &&
  4629. (server_sign == TRUE) &&
  4630. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq)
  4631. {
  4632. if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Install]) == 0)
  4633. {
  4634. }
  4635. else if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Update]) == 0)
  4636. {
  4637. }
  4638. else
  4639. {
  4640. }
  4641. sendGet15118EVCertificateRequest();
  4642. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  4643. }
  4644. //===============================
  4645. // Each connector operation check
  4646. //===============================
  4647. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  4648. {
  4649. //==========================================
  4650. // csu trigger DataTransferReq
  4651. //==========================================
  4652. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4653. {
  4654. sendDataTransferRequest(gun_index);
  4655. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  4656. }
  4657. //===============================
  4658. // CSU Trigger Smart Charging Profilw
  4659. //===============================
  4660. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4661. {
  4662. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index], 0, TRUE);
  4663. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4664. }
  4665. //==============================================
  4666. // Charger start transaction
  4667. //==============================================
  4668. /*
  4669. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  4670. {
  4671. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4672. sendStartTransactionRequest(gun_index);
  4673. clientTime.StartTransaction = time((time_t*)NULL);
  4674. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4675. }*/
  4676. //==============================================
  4677. // Charger stop transaction
  4678. //==============================================
  4679. /*
  4680. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  4681. {
  4682. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  4683. sendStopTransactionRequest(gun_index);
  4684. clientTime.StopTransaction = time((time_t*)NULL);
  4685. }*/
  4686. //==============================================
  4687. // Charger status notification & Transaction event report
  4688. //==============================================
  4689. //--- Check Mode Change ---//
  4690. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4691. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  4692. {
  4693. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4694. {
  4695. tempIndex = ((gun_index==2) ? 1: 0);
  4696. }
  4697. else
  4698. {
  4699. tempIndex = gun_index;
  4700. }
  4701. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4702. {
  4703. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4704. {
  4705. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4706. {
  4707. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4708. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4709. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4710. if((SystemInitial == 0) &&
  4711. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4712. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4713. {
  4714. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4715. }
  4716. }
  4717. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4718. {
  4719. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4720. if((access(filenmae,F_OK))!=-1)
  4721. {
  4722. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4723. sprintf(str,"rm -f %s",filenmae);
  4724. system(str);
  4725. }
  4726. }
  4727. #if 1 // for TempStopTransaction
  4728. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4729. {
  4730. checkTempStopTransaction(gun_index);
  4731. }
  4732. #endif
  4733. }
  4734. }
  4735. }
  4736. else if(gunType[gun_index] == GUN_TYPE_CCS)
  4737. {
  4738. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4739. {
  4740. tempIndex = ((gun_index==2) ? 1: 0);
  4741. }
  4742. else
  4743. {
  4744. tempIndex = gun_index;
  4745. }
  4746. for (int index = 0; index < CCS_QUANTITY; index++)
  4747. {
  4748. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4749. {
  4750. 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]*/ )
  4751. {
  4752. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4753. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4754. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4755. if((SystemInitial == 0) &&
  4756. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4757. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4758. {
  4759. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4760. }
  4761. }
  4762. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4763. {
  4764. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4765. if((access(filenmae,F_OK))!=-1)
  4766. {
  4767. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4768. sprintf(str,"rm -f %s",filenmae);
  4769. system(str);
  4770. }
  4771. }
  4772. #if 1 // for TempStopTransaction
  4773. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4774. {
  4775. checkTempStopTransaction(gun_index);
  4776. }
  4777. #endif
  4778. }
  4779. }
  4780. }
  4781. else if(gunType[gun_index] == GUN_TYPE_GBT)
  4782. {
  4783. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4784. {
  4785. tempIndex = ((gun_index==2) ? 1: 0);
  4786. }
  4787. else
  4788. {
  4789. tempIndex = gun_index;
  4790. }
  4791. for (int index = 0; index < GB_QUANTITY; index++)
  4792. {
  4793. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4794. {
  4795. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4796. {
  4797. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4798. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4799. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4800. if((SystemInitial == 0) &&
  4801. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4802. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4803. {
  4804. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4805. }
  4806. }
  4807. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4808. {
  4809. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4810. if((access(filenmae,F_OK))!=-1)
  4811. {
  4812. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4813. sprintf(str,"rm -f %s",filenmae);
  4814. system(str);
  4815. }
  4816. }
  4817. #if 1 // for TempStopTransaction
  4818. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4819. {
  4820. checkTempStopTransaction(gun_index);
  4821. }
  4822. #endif
  4823. }
  4824. }
  4825. }
  4826. else if(gunType[gun_index] == GUN_TYPE_DO)
  4827. {
  4828. tempIndex = gun_index;
  4829. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4830. {
  4831. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4832. {
  4833. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4834. {
  4835. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4836. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4837. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4838. if((SystemInitial == 0) &&
  4839. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING) &&
  4840. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE))
  4841. {
  4842. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4843. }
  4844. }
  4845. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4846. {
  4847. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4848. if((access(filenmae,F_OK))!=-1)
  4849. {
  4850. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4851. sprintf(str,"rm -f %s",filenmae);
  4852. system(str);
  4853. }
  4854. }
  4855. #if 1 // for TempStopTransaction
  4856. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4857. {
  4858. checkTempStopTransaction(gun_index);
  4859. }
  4860. #endif
  4861. }
  4862. }
  4863. }
  4864. else
  4865. {
  4866. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4867. {
  4868. tempIndex = 2;
  4869. }
  4870. else
  4871. {
  4872. tempIndex = gun_index;
  4873. }
  4874. for (int index = 0; index < AC_QUANTITY; index++)
  4875. {
  4876. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4877. {
  4878. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4879. {
  4880. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4881. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4882. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4883. if((SystemInitial == 0) &&
  4884. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4885. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4886. {
  4887. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4888. }
  4889. }
  4890. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4891. {
  4892. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4893. if((access(filenmae,F_OK))!=-1)
  4894. {
  4895. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4896. sprintf(str,"rm -f %s",filenmae);
  4897. system(str);
  4898. }
  4899. }
  4900. #if 1 // for TempStopTransaction
  4901. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4902. {
  4903. checkTempStopTransaction(gun_index);
  4904. }
  4905. #endif
  4906. }
  4907. }// END
  4908. }
  4909. if(isWebsocketSendable && (server_sign == TRUE) &&
  4910. (cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) &&
  4911. ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 5) )
  4912. {
  4913. if(SystemInitial > 0)
  4914. SystemInitial -= 1;
  4915. sendStatusNotificationRequest(gun_index);
  4916. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4917. }
  4918. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  4919. {
  4920. sendTransactionEventRequest(gun_index);
  4921. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  4922. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  4923. }
  4924. //==============================================
  4925. // Meter report
  4926. //==============================================
  4927. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  4928. {
  4929. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4930. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  4931. }
  4932. // ClockAlign MeterValue
  4933. 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))
  4934. {
  4935. //check Transaction active
  4936. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  4937. {
  4938. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4939. {
  4940. tempIndex = ((gun_index==2) ? 1: 0);
  4941. }
  4942. else
  4943. {
  4944. tempIndex = gun_index;
  4945. }
  4946. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4947. {
  4948. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4949. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4950. {
  4951. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4952. {
  4953. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4954. }
  4955. }
  4956. }// End for CHAdeMO
  4957. }
  4958. else if(gunType[gun_index] == GUN_TYPE_CCS)
  4959. {
  4960. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4961. {
  4962. tempIndex = ((gun_index==2) ? 1: 0);
  4963. }
  4964. else
  4965. {
  4966. tempIndex = gun_index;
  4967. }
  4968. for (int index = 0; index < CCS_QUANTITY; index++)
  4969. {
  4970. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4971. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4972. {
  4973. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4974. {
  4975. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4976. }
  4977. }
  4978. } // End for CCS
  4979. }
  4980. else if(gunType[gun_index] == GUN_TYPE_GBT)
  4981. {
  4982. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4983. {
  4984. tempIndex = ((gun_index==2) ? 1: 0);
  4985. }
  4986. else
  4987. {
  4988. tempIndex = gun_index;
  4989. }
  4990. for (int index = 0; index < GB_QUANTITY; index++)
  4991. {
  4992. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4993. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4994. {
  4995. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4996. {
  4997. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4998. }
  4999. }
  5000. }// End for GB
  5001. }
  5002. else if(gunType[gun_index] == GUN_TYPE_DO)
  5003. {
  5004. tempIndex = gun_index;
  5005. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5006. {
  5007. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5008. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5009. {
  5010. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_CHARGING)
  5011. {
  5012. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5013. }
  5014. }
  5015. }
  5016. }
  5017. else
  5018. {
  5019. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5020. {
  5021. tempIndex = 2;
  5022. }
  5023. else
  5024. {
  5025. tempIndex = gun_index;
  5026. }
  5027. for (int index = 0; index < AC_QUANTITY; index++)
  5028. {
  5029. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5030. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5031. {
  5032. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  5033. {
  5034. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5035. }
  5036. }
  5037. }//End for AC
  5038. }
  5039. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  5040. {
  5041. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  5042. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  5043. }
  5044. }
  5045. // Sample period MeterValue
  5046. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)))
  5047. {
  5048. //check Transaction active
  5049. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5050. {
  5051. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5052. {
  5053. tempIndex = ((gun_index==2) ? 1: 0);
  5054. }
  5055. else
  5056. {
  5057. tempIndex = gun_index;
  5058. }
  5059. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5060. {
  5061. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5062. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5063. {
  5064. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5065. {
  5066. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5067. }
  5068. }
  5069. }// End for CHAdeMO
  5070. }
  5071. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5072. {
  5073. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5074. {
  5075. tempIndex = ((gun_index==2) ? 1: 0);
  5076. }
  5077. else
  5078. {
  5079. tempIndex = gun_index;
  5080. }
  5081. for (int index = 0; index < CCS_QUANTITY; index++)
  5082. {
  5083. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5084. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5085. {
  5086. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5087. {
  5088. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5089. }
  5090. }
  5091. } // End for CCS
  5092. }
  5093. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5094. {
  5095. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5096. {
  5097. tempIndex = ((gun_index==2) ? 1: 0);
  5098. }
  5099. else
  5100. {
  5101. tempIndex = gun_index;
  5102. }
  5103. for (int index = 0; index < GB_QUANTITY; index++)
  5104. {
  5105. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5106. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5107. {
  5108. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5109. {
  5110. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5111. }
  5112. }
  5113. }// End for GB
  5114. }
  5115. else if(gunType[gun_index] == GUN_TYPE_DO)
  5116. {
  5117. tempIndex = gun_index;
  5118. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5119. {
  5120. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5121. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5122. {
  5123. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  5124. {
  5125. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5126. }
  5127. }
  5128. }
  5129. }
  5130. else
  5131. {
  5132. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5133. {
  5134. tempIndex = 2;
  5135. }
  5136. else
  5137. {
  5138. tempIndex = gun_index;
  5139. }
  5140. for (int index = 0; index < AC_QUANTITY; index++)
  5141. {
  5142. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5143. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5144. {
  5145. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5146. {
  5147. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5148. }
  5149. }
  5150. }//End for AC
  5151. }
  5152. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  5153. {
  5154. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  5155. storeTempStopTransaction(gun_index);
  5156. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  5157. }
  5158. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  5159. }
  5160. //==============================================
  5161. // Check Connector reserved
  5162. //==============================================
  5163. //===============================
  5164. // Check if Reserve is expired
  5165. //===============================
  5166. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  5167. {
  5168. double diff_t;
  5169. struct tm tp;
  5170. // current time
  5171. time_t t = time(NULL);
  5172. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  5173. tp.tm_isdst = -1;
  5174. time_t utc = mktime(&tp);
  5175. diff_t = difftime(utc, t);
  5176. if(diff_t <= 0)
  5177. {
  5178. DEBUG_INFO("reserve expired.\n");
  5179. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  5180. }
  5181. }//END OF Check if Reserve is expired
  5182. //==========================================
  5183. // csu trigger FirmwareStatusNotificationReq
  5184. //==========================================
  5185. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  5186. {
  5187. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  5188. }
  5189. //==========================================
  5190. // csu cleared charging limit request
  5191. //==========================================
  5192. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq == ON))
  5193. {
  5194. sendClearedChargingLimitRequest(gun_index);
  5195. }
  5196. //==========================================
  5197. // csu trigger CancelReservationConf
  5198. //==========================================
  5199. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  5200. {
  5201. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  5202. }
  5203. //==========================================
  5204. // csu notify EV charging need request
  5205. //==========================================
  5206. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq == ON))
  5207. {
  5208. sendNotifyEVChargingNeedsRequest(gun_index);
  5209. }
  5210. //==========================================
  5211. // csu trigger ChangeAvailabilityConf
  5212. //==========================================
  5213. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  5214. {
  5215. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  5216. }
  5217. //==========================================
  5218. // csu trigger UnlockConnectorConf
  5219. //==========================================
  5220. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  5221. {
  5222. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  5223. }
  5224. //==========================================
  5225. // csu trigger ReserveNowConf
  5226. //==========================================
  5227. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  5228. {
  5229. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  5230. }
  5231. }
  5232. }
  5233. //==========================================
  5234. // send request routine
  5235. //==========================================
  5236. int sendAuthorizeRequest(int gun_index)
  5237. {
  5238. mtrace();
  5239. int result = FAIL;
  5240. char message[4096]={0};
  5241. char guid[37];
  5242. char tempdata[128]={0};
  5243. json_object *Authorize = json_object_new_object();
  5244. json_object *idToken = json_object_new_object();
  5245. DEBUG_INFO("sendAuthorizeRequest...\n");
  5246. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  5247. //Local Authorize
  5248. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  5249. {
  5250. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  5251. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  5252. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  5253. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  5254. result = PASS;
  5255. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5256. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  5257. authorizeRetryTimes = 0;
  5258. return result;
  5259. }
  5260. 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)) ||
  5261. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  5262. {
  5263. // Query idtag from cache
  5264. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  5265. // Query idtag from list
  5266. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  5267. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  5268. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  5269. {
  5270. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  5271. {
  5272. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  5273. }
  5274. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  5275. {
  5276. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  5277. }
  5278. // Return authorize result if does not connect to server
  5279. if(!ShmOCPP20Data->OcppConnStatus)
  5280. {
  5281. DEBUG_INFO("Local Authorization Fail.\n");
  5282. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  5283. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  5284. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  5285. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  5286. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5287. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  5288. authorizeRetryTimes = 0;
  5289. return result;
  5290. }
  5291. }
  5292. else
  5293. {
  5294. DEBUG_INFO("Local Authorization get result.\n");
  5295. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  5296. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  5297. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  5298. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  5299. else
  5300. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  5301. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  5302. result = PASS;
  5303. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5304. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  5305. authorizeRetryTimes = 0;
  5306. return result;
  5307. }
  5308. }
  5309. //get data from shared memory
  5310. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  5311. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  5312. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  5313. json_object_object_add(Authorize, "idToken", idToken);
  5314. random_uuid(guid);
  5315. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  5316. json_object_put(Authorize);
  5317. LWS_Send(message);
  5318. sprintf(tempdata, "Authorize,%d", gun_index);
  5319. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5320. {
  5321. result = PASS;
  5322. }
  5323. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5324. return result;
  5325. }
  5326. int sendBootNotificationRequest()
  5327. {
  5328. mtrace();
  5329. int result = FAIL;
  5330. char message[4096]={0};
  5331. char guid[37]={0};
  5332. char tempdata[128]={0};
  5333. json_object *BootNotification = json_object_new_object();
  5334. json_object *chargingStation = json_object_new_object();
  5335. json_object *modem = json_object_new_object();
  5336. DEBUG_INFO("sendBootNotificationRequest...\n");
  5337. // Fill BootNotification fields
  5338. DB_getBooType();
  5339. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  5340. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  5341. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  5342. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  5343. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  5344. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  5345. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  5346. {
  5347. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  5348. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  5349. json_object_object_add(chargingStation, "modem", modem);
  5350. }
  5351. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  5352. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  5353. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  5354. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  5355. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  5356. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  5357. random_uuid(guid);
  5358. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  5359. json_object_put(BootNotification);
  5360. LWS_Send(message);
  5361. sprintf(tempdata, "BootNotification,0");
  5362. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5363. {
  5364. result = PASS;
  5365. }
  5366. return result;
  5367. }
  5368. int sendClearedChargingLimitRequest(int gun_index)
  5369. {
  5370. mtrace();
  5371. int result = FAIL;
  5372. char message[4096]={0};
  5373. char guid[37]={0};
  5374. char tempdata[128]={0};
  5375. json_object *ClearedChargingLimit = json_object_new_object();
  5376. DEBUG_INFO("sendClearedChargingLimitRequest...\n");
  5377. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  5378. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  5379. random_uuid(guid);
  5380. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  5381. json_object_put(ClearedChargingLimit);
  5382. LWS_Send(message);
  5383. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  5384. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5385. {
  5386. result = PASS;
  5387. }
  5388. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  5389. return result;
  5390. }
  5391. int sendDataTransferRequest(int gun_index)
  5392. {
  5393. mtrace();
  5394. char message[1000]={0};
  5395. char guid[37]={0};
  5396. char tempdata[65]={0};
  5397. int result = FAIL;
  5398. DEBUG_INFO("sendDataTransferRequest...\n");
  5399. random_uuid(guid);
  5400. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  5401. MESSAGE_TYPE_CALL,
  5402. guid,
  5403. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  5404. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  5405. ShmOCPP20Data->DataTransfer[gun_index].data);
  5406. LWS_Send(message);
  5407. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  5408. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5409. {
  5410. result = PASS;
  5411. }
  5412. return result;
  5413. }
  5414. int sendFirmwareStatusNotificationRequest(char *status)
  5415. {
  5416. mtrace();
  5417. int result = FAIL;
  5418. char message[110]={0};
  5419. char guid[37]={0};
  5420. char tempdata[65]={0};
  5421. json_object *FirmwareStatusNotification = json_object_new_object();
  5422. DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
  5423. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  5424. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  5425. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  5426. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  5427. random_uuid(guid);
  5428. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  5429. json_object_put(FirmwareStatusNotification);
  5430. LWS_SendNow(message);
  5431. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  5432. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5433. {
  5434. result = PASS;
  5435. }
  5436. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  5437. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  5438. //record status
  5439. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  5440. {
  5441. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  5442. }
  5443. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  5444. {
  5445. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  5446. }
  5447. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  5448. {
  5449. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  5450. }
  5451. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  5452. {
  5453. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  5454. }
  5455. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  5456. {
  5457. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  5458. }
  5459. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  5460. {
  5461. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  5462. }
  5463. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  5464. {
  5465. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  5466. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5467. }
  5468. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  5469. {
  5470. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  5471. }
  5472. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  5473. {
  5474. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  5475. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5476. }
  5477. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  5478. {
  5479. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  5480. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5481. }
  5482. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  5483. {
  5484. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  5485. }
  5486. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  5487. {
  5488. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  5489. }
  5490. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  5491. {
  5492. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  5493. }
  5494. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  5495. {
  5496. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  5497. }
  5498. return result;
  5499. }
  5500. int sendGet15118EVCertificateRequest()
  5501. {
  5502. mtrace();
  5503. int result = FAIL;
  5504. char message[4096]={0};
  5505. char guid[37]={0};
  5506. char tempdata[128]={0};
  5507. json_object *Get15118EVCertificate = json_object_new_object();
  5508. DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
  5509. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  5510. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  5511. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  5512. random_uuid(guid);
  5513. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  5514. json_object_put(Get15118EVCertificate);
  5515. LWS_Send(message);
  5516. sprintf(tempdata, "Get15118EVCertificate,0");
  5517. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5518. {
  5519. result = PASS;
  5520. }
  5521. return result;
  5522. }
  5523. int sendGetCertificateStatusRequest()
  5524. {
  5525. mtrace();
  5526. int result = FAIL;
  5527. char message[4096]={0};
  5528. char guid[37]={0};
  5529. char tempdata[128]={0};
  5530. json_object *GetCertificateStatus = json_object_new_object();
  5531. json_object *ocspRequestData = json_object_new_object();
  5532. DEBUG_INFO("sendGetCertificateStatusRequest...\n");
  5533. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  5534. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  5535. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  5536. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  5537. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  5538. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  5539. random_uuid(guid);
  5540. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  5541. json_object_put(GetCertificateStatus);
  5542. LWS_Send(message);
  5543. sprintf(tempdata, "GetCertificateStatus,0");
  5544. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5545. {
  5546. result = PASS;
  5547. }
  5548. return result;
  5549. }
  5550. int sendHeartbeatRequest()
  5551. {
  5552. mtrace();
  5553. int result = FAIL;
  5554. char message[40096]={0};
  5555. char guid[37]={0};
  5556. char tempdata[128]={0};
  5557. DEBUG_INFO("sendHeartbeatRequest...\n");
  5558. random_uuid(guid);
  5559. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  5560. , MESSAGE_TYPE_CALL
  5561. , guid );
  5562. LWS_Send(message);
  5563. sprintf(tempdata, "Heartbeat,%d", 0);
  5564. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5565. {
  5566. result = PASS;
  5567. }
  5568. return result;
  5569. }
  5570. int sendLogStatusNotificationRequest(char *status)
  5571. {
  5572. mtrace();
  5573. int result = FAIL;
  5574. char message[4096]={0};
  5575. char guid[37]={0};
  5576. char tempdata[128]={0};
  5577. json_object *LogStatusNotification = json_object_new_object();
  5578. DEBUG_INFO("sendLogStatusNotificationRequest...\n");
  5579. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  5580. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  5581. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  5582. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  5583. random_uuid(guid);
  5584. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  5585. json_object_put(LogStatusNotification);
  5586. LWS_SendNow(message);
  5587. sprintf(tempdata, "LogStatusNotification,%d", 0);
  5588. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5589. {
  5590. result = PASS;
  5591. }
  5592. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  5593. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  5594. //record status
  5595. if(strcmp(status,"BadMessage")==0)
  5596. {
  5597. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  5598. }
  5599. else if(strcmp(status,"Idle")==0)
  5600. {
  5601. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  5602. }
  5603. else if(strcmp(status,"NotSupportedOperation")==0)
  5604. {
  5605. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  5606. }
  5607. else if(strcmp(status,"PermissionDenied")==0)
  5608. {
  5609. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  5610. }
  5611. else if(strcmp(status,"Uploaded")==0)
  5612. {
  5613. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  5614. }
  5615. else if(strcmp(status,"UploadFailure")==0)
  5616. {
  5617. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  5618. }
  5619. else if(strcmp(status,"Uploading")==0)
  5620. {
  5621. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  5622. }
  5623. return result;
  5624. }
  5625. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  5626. {
  5627. mtrace();
  5628. int result = FAIL;
  5629. char guid[37]={0};
  5630. char tempdata[65]={0};
  5631. int tempIndex = 0;
  5632. json_object *MeterValueReq = json_object_new_object();
  5633. json_object *meterValues = json_object_new_array();
  5634. json_object *sampledValues = json_object_new_array();
  5635. DEBUG_INFO("sendMeterValuesRequest...\n");
  5636. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  5637. //set value
  5638. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  5639. //UTC Date time
  5640. struct timeval tmnow;
  5641. struct tm *tm;
  5642. char buf[28];//, usec_buf[6];
  5643. gettimeofday(&tmnow, NULL);
  5644. time_t t;
  5645. t = time(NULL);
  5646. /*UTC time and date*/
  5647. tm = gmtime(&t);
  5648. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  5649. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  5650. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  5651. //idx_sample=0;
  5652. //********************************(1)Current.Import L1************************************************/
  5653. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5654. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5655. {
  5656. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5657. {
  5658. tempIndex = ((gun_index==2) ? 1: 0);
  5659. }
  5660. else
  5661. {
  5662. tempIndex = gun_index;
  5663. }
  5664. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5665. {
  5666. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5667. {
  5668. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  5669. }
  5670. }
  5671. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5672. }
  5673. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5674. {
  5675. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5676. {
  5677. tempIndex = ((gun_index==2) ? 1: 0);
  5678. }
  5679. else
  5680. {
  5681. tempIndex = gun_index;
  5682. }
  5683. for (int index = 0; index < CCS_QUANTITY; index++)
  5684. {
  5685. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5686. {
  5687. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  5688. }
  5689. }
  5690. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5691. }
  5692. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5693. {
  5694. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5695. {
  5696. tempIndex = ((gun_index==2) ? 1: 0);
  5697. }
  5698. else
  5699. {
  5700. tempIndex = gun_index;
  5701. }
  5702. for (int index = 0; index < GB_QUANTITY; index++)
  5703. {
  5704. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5705. {
  5706. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  5707. }
  5708. }
  5709. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5710. }
  5711. else if(gunType[gun_index] == GUN_TYPE_DO)
  5712. {
  5713. tempIndex = gun_index;
  5714. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5715. {
  5716. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5717. {
  5718. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
  5719. }
  5720. }
  5721. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5722. }
  5723. else
  5724. {
  5725. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5726. {
  5727. tempIndex = 2;
  5728. }
  5729. else
  5730. {
  5731. tempIndex = gun_index;
  5732. }
  5733. for (int index = 0; index < AC_QUANTITY; index++)
  5734. {
  5735. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5736. {
  5737. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  5738. }
  5739. }
  5740. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5741. }
  5742. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  5743. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5744. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5745. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  5746. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  5747. //idx_sample=1;
  5748. //********************************(2)Energy.Active.Import.Register ************************************************/
  5749. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5750. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5751. {
  5752. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5753. {
  5754. tempIndex = ((gun_index==2) ? 1: 0);
  5755. }
  5756. else
  5757. {
  5758. tempIndex = gun_index;
  5759. }
  5760. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5761. {
  5762. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5763. {
  5764. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5765. }
  5766. }
  5767. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5768. }
  5769. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5770. {
  5771. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5772. {
  5773. tempIndex = ((gun_index==2) ? 1: 0);
  5774. }
  5775. else
  5776. {
  5777. tempIndex = gun_index;
  5778. }
  5779. for (int index = 0; index < CCS_QUANTITY; index++)
  5780. {
  5781. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5782. {
  5783. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5784. }
  5785. }
  5786. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5787. }
  5788. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5789. {
  5790. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5791. {
  5792. tempIndex = ((gun_index==2) ? 1: 0);
  5793. }
  5794. else
  5795. {
  5796. tempIndex = gun_index;
  5797. }
  5798. for (int index = 0; index < GB_QUANTITY; index++)
  5799. {
  5800. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5801. {
  5802. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5803. }
  5804. }
  5805. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5806. }
  5807. else if(gunType[gun_index] == GUN_TYPE_DO)
  5808. {
  5809. tempIndex = gun_index;
  5810. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5811. {
  5812. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5813. {
  5814. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5815. }
  5816. }
  5817. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5818. }
  5819. else
  5820. {
  5821. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5822. {
  5823. tempIndex = 2;
  5824. }
  5825. else
  5826. {
  5827. tempIndex = gun_index;
  5828. }
  5829. for (int index = 0; index < AC_QUANTITY; index++)
  5830. {
  5831. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5832. {
  5833. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5834. }
  5835. }
  5836. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5837. }
  5838. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  5839. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  5840. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5841. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  5842. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5843. //idx_sample=2;
  5844. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  5845. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5846. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5847. {
  5848. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5849. {
  5850. tempIndex = ((gun_index==2) ? 1: 0);
  5851. }
  5852. else
  5853. {
  5854. tempIndex = gun_index;
  5855. }
  5856. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5857. {
  5858. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5859. {
  5860. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  5861. }
  5862. } // END OF FOR CHAdeMO_QUANTITY
  5863. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5864. }
  5865. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5866. {
  5867. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5868. {
  5869. tempIndex = ((gun_index==2) ? 1: 0);
  5870. }
  5871. else
  5872. {
  5873. tempIndex = gun_index;
  5874. }
  5875. for (int index = 0; index < CCS_QUANTITY; index++)
  5876. {
  5877. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5878. {
  5879. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  5880. }
  5881. } // END OF CCS_QUANTITY
  5882. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5883. }
  5884. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5885. {
  5886. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5887. {
  5888. tempIndex = ((gun_index==2) ? 1: 0);
  5889. }
  5890. else
  5891. {
  5892. tempIndex = gun_index;
  5893. }
  5894. for (int index = 0; index < GB_QUANTITY; index++)
  5895. {
  5896. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5897. {
  5898. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  5899. }
  5900. } // END OF GB_QUANTITY
  5901. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5902. }
  5903. else if(gunType[gun_index] == GUN_TYPE_DO)
  5904. {
  5905. tempIndex = gun_index;
  5906. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5907. {
  5908. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5909. {
  5910. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
  5911. }
  5912. }
  5913. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5914. }
  5915. else
  5916. {
  5917. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5918. {
  5919. tempIndex = 2;
  5920. }
  5921. else
  5922. {
  5923. tempIndex = gun_index;
  5924. }
  5925. for (int index = 0; index < AC_QUANTITY; index++)
  5926. {
  5927. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5928. {
  5929. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  5930. }
  5931. }
  5932. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5933. }
  5934. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  5935. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  5936. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5937. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  5938. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5939. //idx_sample=3;
  5940. //********************************(4)Power.Active.Import************************************************/
  5941. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5942. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5943. {
  5944. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5945. {
  5946. tempIndex = ((gun_index==2) ? 1: 0);
  5947. }
  5948. else
  5949. {
  5950. tempIndex = gun_index;
  5951. }
  5952. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5953. {
  5954. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5955. {
  5956. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  5957. }
  5958. } // END OF FOR
  5959. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5960. }
  5961. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5962. {
  5963. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5964. {
  5965. tempIndex = ((gun_index==2) ? 1: 0);
  5966. }
  5967. else
  5968. {
  5969. tempIndex = gun_index;
  5970. }
  5971. for (int index = 0; index < CCS_QUANTITY; index++)
  5972. {
  5973. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5974. {
  5975. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  5976. }
  5977. }
  5978. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5979. }
  5980. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5981. {
  5982. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5983. {
  5984. tempIndex = ((gun_index==2) ? 1: 0);
  5985. }
  5986. else
  5987. {
  5988. tempIndex = gun_index;
  5989. }
  5990. for (int index = 0; index < GB_QUANTITY; index++)
  5991. {
  5992. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5993. {
  5994. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5995. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  5996. }
  5997. }
  5998. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5999. }
  6000. else if(gunType[gun_index] == GUN_TYPE_DO)
  6001. {
  6002. tempIndex = gun_index;
  6003. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6004. {
  6005. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6006. {
  6007. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  6008. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
  6009. }
  6010. }
  6011. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6012. }
  6013. else
  6014. {
  6015. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6016. {
  6017. tempIndex = 2;
  6018. }
  6019. else
  6020. {
  6021. tempIndex = gun_index;
  6022. }
  6023. for (int index = 0; index < AC_QUANTITY; index++)
  6024. {
  6025. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6026. {
  6027. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  6028. }
  6029. }
  6030. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6031. }
  6032. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  6033. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  6034. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6035. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  6036. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  6037. //idx_sample=4;
  6038. //***********************************************(5)VOLTAGE L1******************************************************/
  6039. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6040. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6041. {
  6042. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6043. {
  6044. tempIndex = ((gun_index==2) ? 1: 0);
  6045. }
  6046. else
  6047. {
  6048. tempIndex = gun_index;
  6049. }
  6050. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6051. {
  6052. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6053. {
  6054. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  6055. }
  6056. }
  6057. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6058. }
  6059. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6060. {
  6061. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6062. {
  6063. tempIndex = ((gun_index==2) ? 1: 0);
  6064. }
  6065. else
  6066. {
  6067. tempIndex = gun_index;
  6068. }
  6069. for (int index = 0; index < CCS_QUANTITY; index++)
  6070. {
  6071. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6072. {
  6073. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  6074. }
  6075. }
  6076. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6077. }
  6078. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6079. {
  6080. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6081. {
  6082. tempIndex = ((gun_index==2) ? 1: 0);
  6083. }
  6084. else
  6085. {
  6086. tempIndex = gun_index;
  6087. }
  6088. for (int index = 0; index < GB_QUANTITY; index++)
  6089. {
  6090. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6091. {
  6092. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  6093. }
  6094. }
  6095. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6096. }
  6097. else if(gunType[gun_index] == GUN_TYPE_DO)
  6098. {
  6099. tempIndex = gun_index;
  6100. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6101. {
  6102. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6103. {
  6104. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
  6105. }
  6106. }
  6107. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6108. }
  6109. else
  6110. {
  6111. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6112. {
  6113. tempIndex = 2;
  6114. }
  6115. else
  6116. {
  6117. tempIndex = gun_index;
  6118. }
  6119. for (int index = 0; index < AC_QUANTITY; index++)
  6120. {
  6121. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6122. {
  6123. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  6124. }
  6125. }
  6126. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6127. }
  6128. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  6129. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  6130. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6131. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  6132. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  6133. //***********************************************(6)SOC******************************************************/
  6134. if((gunType[gun_index] == GUN_TYPE_CHAdeMO)||(gunType[gun_index] == GUN_TYPE_CCS)||(gunType[gun_index] == GUN_TYPE_GBT)||(gunType[gun_index] == GUN_TYPE_DO))
  6135. {
  6136. if((ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0') && (gunType[gun_index] != GUN_TYPE_DO))
  6137. {
  6138. tempIndex = ((gun_index==2) ? 1: 0);
  6139. }
  6140. else
  6141. {
  6142. tempIndex = gun_index;
  6143. }
  6144. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6145. {
  6146. //tempIndex = ((gun_index==2) ? 1: 0);
  6147. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6148. {
  6149. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6150. {
  6151. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  6152. }
  6153. }
  6154. }
  6155. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6156. {
  6157. //tempIndex = ((gun_index==2) ? 1: 0);
  6158. for (int index = 0; index < CCS_QUANTITY; index++)
  6159. {
  6160. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6161. {
  6162. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  6163. }
  6164. }
  6165. }
  6166. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6167. {
  6168. //tempIndex = ((gun_index==2) ? 1: 0);
  6169. for (int index = 0; index < GB_QUANTITY; index++)
  6170. {
  6171. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6172. {
  6173. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  6174. }
  6175. }
  6176. }
  6177. else if(gunType[gun_index] == GUN_TYPE_DO)
  6178. {
  6179. //tempIndex = ((gun_index==2) ? 1: 0);
  6180. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6181. {
  6182. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6183. {
  6184. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  6185. }
  6186. }
  6187. }
  6188. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  6189. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  6190. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6191. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  6192. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  6193. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  6194. }
  6195. //********************************(7)Current.Import L2************************************************/
  6196. // Only for AC 3 phase
  6197. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  6198. {
  6199. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6200. {
  6201. tempIndex = 2;
  6202. }
  6203. else
  6204. {
  6205. tempIndex = gun_index;
  6206. }
  6207. for (int index = 0; index < AC_QUANTITY; index++)
  6208. {
  6209. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6210. {
  6211. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  6212. }
  6213. }
  6214. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  6215. }
  6216. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  6217. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  6218. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6219. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  6220. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  6221. //********************************(8)Current.Import L3************************************************/
  6222. // Only for AC 3 phase
  6223. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  6224. {
  6225. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6226. {
  6227. tempIndex = 2;
  6228. }
  6229. else
  6230. {
  6231. tempIndex = gun_index;
  6232. }
  6233. for (int index = 0; index < AC_QUANTITY; index++)
  6234. {
  6235. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6236. {
  6237. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  6238. }
  6239. }
  6240. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6241. }
  6242. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  6243. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  6244. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6245. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  6246. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  6247. //***********************************************(9)VOLTAGE L2******************************************************/
  6248. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  6249. {
  6250. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6251. {
  6252. tempIndex = 2;
  6253. }
  6254. else
  6255. {
  6256. tempIndex = gun_index;
  6257. }
  6258. for (int index = 0; index < AC_QUANTITY; index++)
  6259. {
  6260. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6261. {
  6262. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  6263. }
  6264. }
  6265. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  6266. }
  6267. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  6268. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  6269. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6270. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  6271. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  6272. //***********************************************(10)VOLTAGE L3******************************************************/
  6273. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  6274. {
  6275. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6276. {
  6277. tempIndex = 2;
  6278. }
  6279. else
  6280. {
  6281. tempIndex = gun_index;
  6282. }
  6283. for (int index = 0; index < AC_QUANTITY; index++)
  6284. {
  6285. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6286. {
  6287. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  6288. }
  6289. }
  6290. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6291. }
  6292. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  6293. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  6294. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6295. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  6296. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  6297. // Message create ====================================================================================================
  6298. random_uuid(guid);
  6299. for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
  6300. {
  6301. json_object *meterValue = json_object_new_object();
  6302. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  6303. {
  6304. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  6305. {
  6306. json_object *sampledValue = json_object_new_object();
  6307. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  6308. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  6309. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  6310. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  6311. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  6312. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  6313. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  6314. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  6315. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  6316. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  6317. {
  6318. json_object *unitOfMeasure = json_object_new_object();
  6319. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  6320. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  6321. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  6322. }
  6323. json_object_array_add(sampledValues, sampledValue);
  6324. }
  6325. }
  6326. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  6327. json_object_object_add(meterValue, "sampledValue", sampledValues);
  6328. json_object_array_add(meterValues, meterValue);
  6329. idxMeter++;
  6330. }
  6331. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  6332. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  6333. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  6334. ,gun_index + 1
  6335. ,MESSAGE_TYPE_CALL
  6336. ,guid
  6337. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  6338. json_object_put(MeterValueReq);
  6339. if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]) == 0) ||
  6340. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]) == 0) ||
  6341. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]) == 0))
  6342. {
  6343. // Transaction meter value send by TransactionEvent message
  6344. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  6345. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  6346. result = PASS;
  6347. }
  6348. else
  6349. {
  6350. // Put request guid to hash map
  6351. sprintf(tempdata, "MeterValues,%d", (gun_index));
  6352. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6353. {
  6354. result = PASS;
  6355. }
  6356. if((dataType != ReadingContextEnumType_Trigger) &&
  6357. (dataType != ReadingContextEnumType_Sample_Clock))
  6358. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  6359. else
  6360. {
  6361. if(FirstHeartBeat)
  6362. LWS_Send(queuedata +2);
  6363. }
  6364. }
  6365. return result;
  6366. }
  6367. int sendNotifyChargingLimitRequest(int gun_index)
  6368. {
  6369. mtrace();
  6370. int result = FAIL;
  6371. char message[4096]={0};
  6372. char guid[37]={0};
  6373. char tempdata[128]={0};
  6374. json_object *NotifyChargingLimit = json_object_new_object();
  6375. json_object *chargingLimit = json_object_new_object();
  6376. DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
  6377. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  6378. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  6379. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  6380. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  6381. random_uuid(guid);
  6382. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  6383. json_object_put(NotifyChargingLimit);
  6384. LWS_Send(message);
  6385. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  6386. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6387. {
  6388. result = PASS;
  6389. }
  6390. return result;
  6391. }
  6392. int sendNotifyCustomerInformationRequest()
  6393. {
  6394. mtrace();
  6395. int result = FAIL;
  6396. char message[4096]={0};
  6397. char guid[37]={0};
  6398. char tempdata[128]={0};
  6399. json_object *NotifyCustomerInformation = json_object_new_object();
  6400. DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
  6401. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  6402. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  6403. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  6404. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  6405. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  6406. random_uuid(guid);
  6407. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  6408. json_object_put(NotifyCustomerInformation);
  6409. LWS_Send(message);
  6410. sprintf(tempdata, "NotifyCustomerInformation,0");
  6411. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6412. {
  6413. result = PASS;
  6414. }
  6415. return result;
  6416. }
  6417. int sendNotifyDisplayMessagesRequest()
  6418. {
  6419. mtrace();
  6420. int result = FAIL;
  6421. char message[4096]={0};
  6422. char guid[37]={0};
  6423. char tempdata[128]={0};
  6424. json_object *NotifyDisplayMessages = json_object_new_object();
  6425. json_object *messageInfos = json_object_new_array();
  6426. DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
  6427. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  6428. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  6429. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  6430. {
  6431. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  6432. {
  6433. json_object *messageInfo = json_object_new_object();
  6434. json_object *message = json_object_new_object();
  6435. json_object *display = json_object_new_object();
  6436. json_object *evse = json_object_new_object();
  6437. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  6438. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  6439. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  6440. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  6441. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  6442. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  6443. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  6444. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  6445. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  6446. json_object_object_add(messageInfo, "message", message);
  6447. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  6448. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  6449. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  6450. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  6451. json_object_object_add(display, "evse",evse);
  6452. json_object_object_add(messageInfo, "evse", display);
  6453. json_object_array_add(messageInfos, messageInfo);
  6454. }
  6455. }
  6456. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  6457. random_uuid(guid);
  6458. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  6459. json_object_put(NotifyDisplayMessages);
  6460. LWS_Send(message);
  6461. sprintf(tempdata, "NotifyDisplayMessages,0");
  6462. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6463. {
  6464. result = PASS;
  6465. }
  6466. return result;
  6467. }
  6468. int sendNotifyEVChargingNeedsRequest(int gun_index)
  6469. {
  6470. mtrace();
  6471. int result = FAIL;
  6472. char message[4096]={0};
  6473. char guid[37]={0};
  6474. char tempdata[128]={0};
  6475. json_object *NotifyEVChargingNeeds = json_object_new_object();
  6476. json_object *chargingNeeds = json_object_new_object();
  6477. json_object *acChargingParameters = json_object_new_object();
  6478. json_object *dcChargingParameters = json_object_new_object();
  6479. DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
  6480. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  6481. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  6482. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  6483. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  6484. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  6485. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  6486. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  6487. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  6488. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  6489. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  6490. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  6491. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  6492. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  6493. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  6494. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  6495. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  6496. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  6497. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  6498. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  6499. random_uuid(guid);
  6500. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  6501. json_object_put(NotifyEVChargingNeeds);
  6502. LWS_Send(message);
  6503. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  6504. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6505. {
  6506. result = PASS;
  6507. }
  6508. return result;
  6509. }
  6510. int sendNotifyEVChargingScheduleRequest(int gun_index)
  6511. {
  6512. mtrace();
  6513. int result = FAIL;
  6514. char message[4096]={0};
  6515. char guid[37]={0};
  6516. char tempdata[128]={0};
  6517. json_object *NotifyEVChargingSchedule = json_object_new_object();
  6518. json_object *chargingSchedule = json_object_new_object();
  6519. json_object *periods = json_object_new_array();
  6520. DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
  6521. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  6522. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  6523. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  6524. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  6525. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  6526. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  6527. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  6528. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  6529. {
  6530. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  6531. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  6532. {
  6533. json_object *Period = json_object_new_object();
  6534. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  6535. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  6536. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  6537. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  6538. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  6539. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  6540. json_object_array_add(periods, Period);
  6541. }
  6542. }
  6543. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  6544. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  6545. random_uuid(guid);
  6546. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  6547. json_object_put(NotifyEVChargingSchedule);
  6548. LWS_Send(message);
  6549. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  6550. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6551. {
  6552. result = PASS;
  6553. }
  6554. return result;
  6555. }
  6556. int sendNotifyEventRequest()
  6557. {
  6558. mtrace();
  6559. int result = FAIL;
  6560. char message[4096]={0};
  6561. char guid[37]={0};
  6562. char tempdata[128]={0};
  6563. json_object *NotifyEvent = json_object_new_object();
  6564. json_object *eventDatas = json_object_new_array();
  6565. DEBUG_INFO("sendNotifyEventRequest...\n");
  6566. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  6567. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  6568. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  6569. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  6570. {
  6571. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  6572. {
  6573. json_object *eventData = json_object_new_object();
  6574. json_object *component = json_object_new_object();
  6575. json_object *evse = json_object_new_object();
  6576. json_object *variable = json_object_new_object();
  6577. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  6578. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  6579. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  6580. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  6581. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  6582. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  6583. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  6584. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  6585. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  6586. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  6587. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  6588. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  6589. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  6590. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  6591. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  6592. json_object_object_add(component, "evse",evse);
  6593. json_object_object_add(eventData, "component", component);
  6594. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  6595. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  6596. json_object_object_add(eventData, "variable", variable);
  6597. json_object_array_add(eventDatas, eventData);
  6598. }
  6599. }
  6600. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  6601. random_uuid(guid);
  6602. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  6603. json_object_put(NotifyEvent);
  6604. LWS_Send(message);
  6605. sprintf(tempdata, "NotifyEvent,0");
  6606. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6607. {
  6608. result = PASS;
  6609. }
  6610. return result;
  6611. }
  6612. int sendNotifyMonitoringReportRequest()
  6613. {
  6614. mtrace();
  6615. int result = FAIL;
  6616. char message[4096]={0};
  6617. char guid[37]={0};
  6618. char tempdata[128]={0};
  6619. json_object *NotifyMonitoringReport = json_object_new_object();
  6620. json_object *monitors = json_object_new_array();
  6621. DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
  6622. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  6623. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  6624. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  6625. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  6626. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  6627. {
  6628. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  6629. {
  6630. json_object *monitor = json_object_new_object();
  6631. json_object *component = json_object_new_object();
  6632. json_object *evse = json_object_new_object();
  6633. json_object *variable = json_object_new_object();
  6634. json_object *variableMonitorings = json_object_new_array();
  6635. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  6636. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  6637. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  6638. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  6639. json_object_object_add(component, "evse",evse);
  6640. json_object_object_add(monitor, "component", component);
  6641. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  6642. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  6643. json_object_object_add(monitor, "variable", variable);
  6644. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  6645. {
  6646. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  6647. {
  6648. json_object *variableMonitoring = json_object_new_object();
  6649. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  6650. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  6651. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  6652. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  6653. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  6654. json_object_array_add(variableMonitorings, variableMonitoring);
  6655. }
  6656. }
  6657. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  6658. json_object_array_add(monitors, monitor);
  6659. }
  6660. }
  6661. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  6662. random_uuid(guid);
  6663. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  6664. json_object_put(NotifyMonitoringReport);
  6665. LWS_Send(message);
  6666. sprintf(tempdata, "NotifyMonitoringReport,0");
  6667. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6668. {
  6669. result = PASS;
  6670. }
  6671. return result;
  6672. }
  6673. int sendNotifyReportRequest()
  6674. {
  6675. mtrace();
  6676. int result = FAIL;
  6677. char message[4096]={0};
  6678. char guid[37]={0};
  6679. char tempdata[128]={0};
  6680. json_object *NotifyReport = json_object_new_object();
  6681. json_object *reportDatas = json_object_new_array();
  6682. DEBUG_INFO("sendNotifyReportRequest...\n");
  6683. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  6684. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  6685. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  6686. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  6687. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  6688. {
  6689. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  6690. {
  6691. json_object *reportData = json_object_new_object();
  6692. json_object *component = json_object_new_object();
  6693. json_object *evse = json_object_new_object();
  6694. json_object *variable = json_object_new_object();
  6695. json_object *variableAttributes = json_object_new_array();
  6696. json_object *variableCharacteristics = json_object_new_object();
  6697. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  6698. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  6699. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  6700. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  6701. json_object_object_add(component, "evse",evse);
  6702. json_object_object_add(reportData, "component", component);
  6703. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  6704. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  6705. json_object_object_add(reportData, "variable",variable);
  6706. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  6707. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  6708. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  6709. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  6710. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  6711. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  6712. {
  6713. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  6714. {
  6715. json_object *variableAttribute = json_object_new_object();
  6716. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  6717. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  6718. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  6719. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  6720. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  6721. json_object_array_add(variableAttributes, variableAttribute);
  6722. }
  6723. }
  6724. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  6725. json_object_array_add(reportDatas, reportData);
  6726. }
  6727. }
  6728. json_object_object_add(NotifyReport, "reportData", reportDatas);
  6729. random_uuid(guid);
  6730. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  6731. json_object_put(NotifyReport);
  6732. LWS_SendNow(message);
  6733. sprintf(tempdata, "NotifyReport,0");
  6734. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6735. {
  6736. result = PASS;
  6737. }
  6738. return result;
  6739. }
  6740. int sendPublishFirmwareStatusNotificationRequest()
  6741. {
  6742. mtrace();
  6743. int result = FAIL;
  6744. char message[4096]={0};
  6745. char guid[37]={0};
  6746. char tempdata[128]={0};
  6747. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  6748. json_object *locations = json_object_new_array();
  6749. DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
  6750. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  6751. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  6752. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  6753. {
  6754. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  6755. }
  6756. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  6757. random_uuid(guid);
  6758. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6759. json_object_put(PublishFirmwareStatusNotification);
  6760. LWS_Send(message);
  6761. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  6762. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6763. {
  6764. result = PASS;
  6765. }
  6766. return result;
  6767. }
  6768. int sendReportChargingProfilesRequest(int gun_index)
  6769. {
  6770. mtrace();
  6771. int result = FAIL;
  6772. char message[4096]={0};
  6773. char guid[37]={0};
  6774. char tempdata[128]={0};
  6775. json_object *ReportChargingProfiles = json_object_new_object();
  6776. json_object *chargingProfiles = json_object_new_array();
  6777. DEBUG_INFO("sendReportChargingProfilesRequest...\n");
  6778. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  6779. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  6780. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  6781. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  6782. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  6783. {
  6784. json_object *chargingProfile = json_object_new_object();
  6785. json_object *chargingSchedules = json_object_new_array();
  6786. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  6787. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  6788. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  6789. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  6790. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  6791. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  6792. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  6793. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  6794. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  6795. {
  6796. json_object *chargingSchedule = json_object_new_object();
  6797. json_object *chargingSchedulePeriods = json_object_new_array();
  6798. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  6799. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  6800. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  6801. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  6802. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  6803. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  6804. {
  6805. json_object *chargingSchedulePeriod = json_object_new_object();
  6806. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  6807. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  6808. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  6809. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  6810. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  6811. }
  6812. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  6813. json_object_array_add(chargingSchedules, chargingSchedule);
  6814. }
  6815. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  6816. json_object_array_add(chargingProfiles, chargingProfile);
  6817. }
  6818. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  6819. random_uuid(guid);
  6820. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6821. json_object_put(ReportChargingProfiles);
  6822. LWS_Send(message);
  6823. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  6824. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6825. {
  6826. result = PASS;
  6827. }
  6828. return result;
  6829. }
  6830. int sendReservationStatusUpdateRequest(int gun_index)
  6831. {
  6832. mtrace();
  6833. int result = FAIL;
  6834. char message[4096]={0};
  6835. char guid[37]={0};
  6836. char tempdata[128]={0};
  6837. json_object *ReservationStatusUpdate = json_object_new_object();
  6838. DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
  6839. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  6840. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  6841. random_uuid(guid);
  6842. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  6843. json_object_put(ReservationStatusUpdate);
  6844. LWS_Send(message);
  6845. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  6846. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6847. {
  6848. result = PASS;
  6849. }
  6850. return result;
  6851. }
  6852. int sendSecurityEventNotificationRequest()
  6853. {
  6854. mtrace();
  6855. int result = FAIL;
  6856. char message[4096]={0};
  6857. char guid[37]={0};
  6858. char tempdata[128]={0};
  6859. json_object *SecurityEventNotification = json_object_new_object();
  6860. DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
  6861. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  6862. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  6863. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techInfo));
  6864. random_uuid(guid);
  6865. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  6866. json_object_put(SecurityEventNotification);
  6867. LWS_Send(message);
  6868. sprintf(tempdata, "SecurityEventNotification,0");
  6869. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6870. {
  6871. result = PASS;
  6872. }
  6873. return result;
  6874. }
  6875. int sendSignCertificateRequest()
  6876. {
  6877. mtrace();
  6878. int result = FAIL;
  6879. char message[4096]={0};
  6880. char guid[37]={0};
  6881. char tempdata[128]={0};
  6882. json_object *SignCertificate = json_object_new_object();
  6883. DEBUG_INFO("sendSignCertificateRequest...\n");
  6884. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  6885. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  6886. random_uuid(guid);
  6887. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  6888. json_object_put(SignCertificate);
  6889. LWS_Send(message);
  6890. sprintf(tempdata, "SignCertificate,0");
  6891. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6892. {
  6893. result = PASS;
  6894. }
  6895. return result;
  6896. }
  6897. int sendStatusNotificationRequest(int gun_index)
  6898. {
  6899. mtrace();
  6900. int result = FAIL;
  6901. char message[600]={0};
  6902. char guid[37];
  6903. int currentStatus = 0;
  6904. struct timeval tmnow;
  6905. struct tm *tm;
  6906. char buf[28];//, usec_buf[6];
  6907. char tempdata[65]={0};
  6908. int tempIndex = 0;
  6909. DEBUG_INFO("sendStatusNotificationRequest...\n");
  6910. gettimeofday(&tmnow, NULL);
  6911. time_t t;
  6912. t = time(NULL);
  6913. /*UTC time and date*/
  6914. tm = gmtime(&t);
  6915. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6916. #if 0 // remove temporally
  6917. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  6918. strcat(buf,".");
  6919. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  6920. strcat(buf,usec_buf);
  6921. #endif
  6922. printf("%s",buf);
  6923. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  6924. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  6925. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  6926. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  6927. /*
  6928. enum _SYSTEM_STATUS
  6929. {
  6930. S_BOOTING = 0,
  6931. S_IDLE, = 1
  6932. S_AUTHORIZING, =2
  6933. S_REASSIGN_CHECK, =3
  6934. S_REASSIGN, =4
  6935. S_PRECHARGE, =5
  6936. S_PREPARING_FOR_EV, =6
  6937. S_PREPARING_FOR_EVSE, =7
  6938. S_CHARGING, =8
  6939. S_TERMINATING, =9
  6940. S_COMPLETE, =10
  6941. S_ALARM, =11
  6942. S_FAULT =12
  6943. }
  6944. */
  6945. //check Transaction active
  6946. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6947. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6948. {
  6949. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6950. {
  6951. tempIndex = ((gun_index==2) ? 1: 0);
  6952. }
  6953. else
  6954. {
  6955. tempIndex = gun_index;
  6956. }
  6957. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6958. {
  6959. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6960. {
  6961. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6962. {
  6963. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6964. {
  6965. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6966. }
  6967. else
  6968. {
  6969. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6970. }
  6971. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  6972. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6973. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  6974. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  6975. }
  6976. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6977. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6978. ) //S_PRECHARGE
  6979. {
  6980. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6981. }
  6982. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6983. {
  6984. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6985. }
  6986. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6987. {
  6988. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6989. }
  6990. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6991. {
  6992. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6993. }
  6994. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (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
  6995. {
  6996. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6997. }
  6998. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6999. {
  7000. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  7001. }
  7002. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7003. {
  7004. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  7005. }
  7006. } //end of the same index
  7007. }//end of for CHAdeMO_QUANTITY
  7008. }
  7009. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7010. {
  7011. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7012. {
  7013. tempIndex = ((gun_index==2) ? 1: 0);
  7014. }
  7015. else
  7016. {
  7017. tempIndex = gun_index;
  7018. }
  7019. for (int index = 0; index < CCS_QUANTITY; index++)
  7020. {
  7021. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7022. {
  7023. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7024. {
  7025. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7026. {
  7027. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  7028. }
  7029. else
  7030. {
  7031. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  7032. }
  7033. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7034. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7035. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  7036. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  7037. }
  7038. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7039. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7040. ) //S_PRECHARGE
  7041. {
  7042. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  7043. }
  7044. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7045. {
  7046. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  7047. }
  7048. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7049. {
  7050. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  7051. }
  7052. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  7053. {
  7054. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  7055. }
  7056. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (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
  7057. {
  7058. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  7059. }
  7060. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  7061. {
  7062. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  7063. }
  7064. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7065. {
  7066. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  7067. }
  7068. } //end of the same index
  7069. } // end of for CCS_QUANTITY
  7070. }
  7071. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7072. {
  7073. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7074. {
  7075. tempIndex = ((gun_index==2) ? 1: 0);
  7076. }
  7077. else
  7078. {
  7079. tempIndex = gun_index;
  7080. }
  7081. for (int index = 0; index < GB_QUANTITY; index++)
  7082. {
  7083. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7084. {
  7085. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7086. {
  7087. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7088. {
  7089. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  7090. }
  7091. else
  7092. {
  7093. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  7094. }
  7095. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7096. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7097. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  7098. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  7099. }
  7100. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7101. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7102. ) //S_PRECHARGE
  7103. {
  7104. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  7105. }
  7106. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7107. {
  7108. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  7109. }
  7110. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7111. {
  7112. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  7113. }
  7114. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7115. {
  7116. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  7117. }
  7118. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (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
  7119. {
  7120. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  7121. }
  7122. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  7123. {
  7124. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  7125. }
  7126. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7127. {
  7128. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  7129. }
  7130. } //end of the same index
  7131. } // end of for GB_QUANTITY
  7132. }
  7133. else if(gunType[gun_index] == GUN_TYPE_DO)
  7134. {
  7135. tempIndex = gun_index;
  7136. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7137. {
  7138. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7139. {
  7140. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7141. {
  7142. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7143. {
  7144. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  7145. }
  7146. else
  7147. {
  7148. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  7149. }
  7150. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7151. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7152. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  7153. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  7154. }
  7155. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7156. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7157. ) //S_PRECHARGE
  7158. {
  7159. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  7160. }
  7161. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7162. {
  7163. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  7164. }
  7165. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7166. {
  7167. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  7168. }
  7169. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7170. {
  7171. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  7172. }
  7173. else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (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
  7174. {
  7175. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  7176. }
  7177. 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
  7178. {
  7179. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  7180. }
  7181. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7182. {
  7183. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  7184. }
  7185. } //end of the same index
  7186. }
  7187. }
  7188. else
  7189. {
  7190. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7191. {
  7192. tempIndex = 2;
  7193. }
  7194. else
  7195. {
  7196. tempIndex = gun_index;
  7197. }
  7198. for (int index = 0; index < AC_QUANTITY; index++)
  7199. {
  7200. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7201. {
  7202. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  7203. {
  7204. 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))
  7205. {
  7206. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  7207. }
  7208. else
  7209. {
  7210. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  7211. }
  7212. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7213. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7214. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  7215. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  7216. }
  7217. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  7218. {
  7219. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  7220. }
  7221. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  7222. {
  7223. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  7224. }
  7225. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  7226. {
  7227. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  7228. }
  7229. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7230. {
  7231. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  7232. }
  7233. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (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
  7234. {
  7235. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  7236. }
  7237. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7238. {
  7239. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  7240. }
  7241. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7242. {
  7243. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  7244. }
  7245. }//end of the same index
  7246. }//end of for AC_QUANTITY
  7247. }
  7248. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  7249. random_uuid(guid);
  7250. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  7251. , MESSAGE_TYPE_CALL
  7252. , guid
  7253. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  7254. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  7255. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  7256. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  7257. if((server_sign == TRUE))
  7258. {
  7259. LWS_Send(message);
  7260. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  7261. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7262. {
  7263. result = PASS;
  7264. }
  7265. }
  7266. else
  7267. {
  7268. result = PASS;
  7269. }
  7270. return result;
  7271. }
  7272. int sendTransactionEventRequest(int gun_index)
  7273. {
  7274. mtrace();
  7275. int result = FAIL;
  7276. char message[1024*20]={0};
  7277. char guid[37]={0};
  7278. char tempdata[128]={0};
  7279. uint8_t tempIndex;
  7280. json_object *TransactionEvent = json_object_new_object();
  7281. json_object *transactionInfo = json_object_new_object();
  7282. json_object *idToken = json_object_new_object();
  7283. json_object *evse = json_object_new_object();
  7284. json_object *meterValues = json_object_new_array();
  7285. char TempStopTransaction[256];
  7286. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  7287. DEBUG_INFO("sendTransactionEventRequest...\n");
  7288. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7289. {
  7290. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7291. {
  7292. tempIndex = ((gun_index==2) ? 1: 0);
  7293. }
  7294. else
  7295. {
  7296. tempIndex = gun_index;
  7297. }
  7298. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7299. {
  7300. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  7301. {
  7302. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  7303. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  7304. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  7305. else
  7306. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  7307. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7308. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  7309. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  7310. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  7311. {
  7312. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7313. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  7314. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  7315. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7316. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7317. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7318. {
  7319. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7320. }
  7321. else
  7322. {
  7323. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7324. }
  7325. }
  7326. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7327. {
  7328. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7329. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7330. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7331. }
  7332. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7333. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7334. ) //S_PRECHARGE
  7335. {
  7336. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  7337. {
  7338. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  7339. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  7340. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7341. storeTempStopTransaction(gun_index);
  7342. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7343. }
  7344. else
  7345. {
  7346. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7347. }
  7348. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7349. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7350. }
  7351. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7352. {
  7353. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7354. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7355. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7356. }
  7357. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7358. {
  7359. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7360. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7361. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7362. if((access(TempStopTransaction,F_OK))!=-1)
  7363. {
  7364. remove(TempStopTransaction); // remove file "TempStopTransaction"
  7365. }
  7366. }
  7367. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7368. {
  7369. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7370. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7371. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7372. }
  7373. 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
  7374. {
  7375. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7376. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7377. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7378. }
  7379. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7380. {
  7381. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7382. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7383. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7384. }
  7385. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7386. {
  7387. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7388. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7389. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7390. }
  7391. } //end of the same index
  7392. }//end of for CHAdeMO_QUANTITY
  7393. }
  7394. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7395. {
  7396. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7397. {
  7398. tempIndex = ((gun_index==2) ? 1: 0);
  7399. }
  7400. else
  7401. {
  7402. tempIndex = gun_index;
  7403. }
  7404. for (int index = 0; index < CCS_QUANTITY; index++)
  7405. {
  7406. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7407. {
  7408. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  7409. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  7410. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  7411. else
  7412. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  7413. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7414. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  7415. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  7416. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7417. {
  7418. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7419. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  7420. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  7421. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7422. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7423. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7424. {
  7425. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7426. }
  7427. else
  7428. {
  7429. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7430. }
  7431. }
  7432. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7433. {
  7434. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7435. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7436. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7437. }
  7438. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7439. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7440. ) //S_PRECHARGE
  7441. {
  7442. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  7443. {
  7444. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  7445. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  7446. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7447. storeTempStopTransaction(gun_index);
  7448. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7449. }
  7450. else
  7451. {
  7452. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7453. }
  7454. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7455. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7456. }
  7457. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7458. {
  7459. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7460. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7461. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7462. }
  7463. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7464. {
  7465. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7466. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7467. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7468. if((access(TempStopTransaction,F_OK))!=-1)
  7469. {
  7470. remove(TempStopTransaction); // remove file "TempStopTransaction"
  7471. }
  7472. }
  7473. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7474. {
  7475. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7476. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7477. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7478. }
  7479. 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
  7480. {
  7481. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7482. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7483. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7484. }
  7485. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7486. {
  7487. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7488. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7489. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7490. }
  7491. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7492. {
  7493. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7494. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7495. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7496. }
  7497. } //end of the same index
  7498. } // end of for CCS_QUANTITY
  7499. }
  7500. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7501. {
  7502. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7503. {
  7504. tempIndex = ((gun_index==2) ? 1: 0);
  7505. }
  7506. else
  7507. {
  7508. tempIndex = gun_index;
  7509. }
  7510. for (int index = 0; index < GB_QUANTITY; index++)
  7511. {
  7512. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7513. {
  7514. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  7515. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  7516. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  7517. else
  7518. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  7519. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7520. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  7521. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  7522. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7523. {
  7524. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7525. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  7526. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  7527. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7528. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7529. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7530. {
  7531. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7532. }
  7533. else
  7534. {
  7535. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7536. }
  7537. }
  7538. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7539. {
  7540. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7541. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7542. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7543. }
  7544. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7545. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7546. ) //S_PRECHARGE
  7547. {
  7548. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  7549. {
  7550. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  7551. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  7552. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7553. storeTempStopTransaction(gun_index);
  7554. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7555. }
  7556. else
  7557. {
  7558. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7559. }
  7560. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7561. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7562. }
  7563. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7564. {
  7565. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7566. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7567. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7568. }
  7569. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7570. {
  7571. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7572. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7573. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7574. if((access(TempStopTransaction,F_OK))!=-1)
  7575. {
  7576. remove(TempStopTransaction); // remove file "TempStopTransaction"
  7577. }
  7578. }
  7579. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7580. {
  7581. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7582. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7583. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7584. }
  7585. 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
  7586. {
  7587. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7588. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7589. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7590. }
  7591. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7592. {
  7593. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7594. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7595. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7596. }
  7597. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7598. {
  7599. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7600. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7601. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7602. }
  7603. } //end of the same index
  7604. } // end of for GB_QUANTITY
  7605. }
  7606. else if(gunType[gun_index] == GUN_TYPE_DO)
  7607. {
  7608. tempIndex = gun_index;
  7609. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7610. {
  7611. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7612. {
  7613. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  7614. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  7615. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  7616. else
  7617. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  7618. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7619. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  7620. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  7621. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7622. {
  7623. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7624. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  7625. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  7626. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7627. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7628. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7629. {
  7630. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7631. }
  7632. else
  7633. {
  7634. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7635. }
  7636. }
  7637. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7638. {
  7639. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7640. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7641. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7642. }
  7643. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7644. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7645. ) //S_PRECHARGE
  7646. {
  7647. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  7648. {
  7649. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  7650. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  7651. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7652. storeTempStopTransaction(gun_index);
  7653. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7654. }
  7655. else
  7656. {
  7657. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7658. }
  7659. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7660. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7661. }
  7662. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7663. {
  7664. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7665. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7666. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7667. }
  7668. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7669. {
  7670. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7671. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7672. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7673. if((access(TempStopTransaction,F_OK))!=-1)
  7674. {
  7675. remove(TempStopTransaction); // remove file "TempStopTransaction"
  7676. }
  7677. }
  7678. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7679. {
  7680. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7681. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7682. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7683. }
  7684. 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
  7685. {
  7686. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7687. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7688. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7689. }
  7690. 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
  7691. {
  7692. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7693. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7694. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7695. }
  7696. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7697. {
  7698. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7699. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7700. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7701. }
  7702. } //end of the same index
  7703. }
  7704. }
  7705. else
  7706. {
  7707. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7708. {
  7709. tempIndex = 2;
  7710. }
  7711. else
  7712. {
  7713. tempIndex = gun_index;
  7714. }
  7715. for (int index = 0; index < AC_QUANTITY; index++)
  7716. {
  7717. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7718. {
  7719. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  7720. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  7721. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  7722. else
  7723. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  7724. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7725. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  7726. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  7727. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  7728. {
  7729. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7730. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  7731. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  7732. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7733. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7734. 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))
  7735. {
  7736. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7737. }
  7738. else
  7739. {
  7740. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7741. }
  7742. }
  7743. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7744. {
  7745. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7746. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7747. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7748. }
  7749. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7750. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7751. ) //S_PRECHARGE
  7752. {
  7753. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  7754. {
  7755. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  7756. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  7757. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7758. storeTempStopTransaction(gun_index);
  7759. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7760. }
  7761. else
  7762. {
  7763. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7764. }
  7765. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7766. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7767. }
  7768. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7769. {
  7770. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7771. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7772. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7773. }
  7774. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7775. {
  7776. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7777. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7778. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7779. if((access(TempStopTransaction,F_OK))!=-1)
  7780. {
  7781. remove(TempStopTransaction); // remove file "TempStopTransaction"
  7782. }
  7783. }
  7784. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7785. {
  7786. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7787. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7788. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7789. }
  7790. 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
  7791. {
  7792. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7793. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7794. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7795. }
  7796. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7797. {
  7798. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7799. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7800. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7801. }
  7802. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7803. {
  7804. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7805. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7806. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7807. }
  7808. }//end of the same index
  7809. }//end of for AC_QUANTITY
  7810. }
  7811. // Message
  7812. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7813. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  7814. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  7815. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  7816. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  7817. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  7818. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  7819. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  7820. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  7821. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  7822. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  7823. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  7824. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  7825. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  7826. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  7827. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  7828. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  7829. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  7830. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  7831. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  7832. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  7833. {
  7834. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  7835. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  7836. json_object_object_add(TransactionEvent, "idToken", idToken);
  7837. }
  7838. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  7839. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  7840. json_object_object_add(TransactionEvent, "evse", evse);
  7841. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  7842. {
  7843. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  7844. {
  7845. json_object *meterValue = json_object_new_object();
  7846. json_object *sampledValues = json_object_new_array();
  7847. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  7848. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7849. {
  7850. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  7851. ((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) == 0)))
  7852. {
  7853. json_object *sampledValue = json_object_new_object();
  7854. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7855. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7856. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7857. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  7858. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7859. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  7860. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7861. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  7862. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7863. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  7864. {
  7865. json_object *unitOfMeasure = json_object_new_object();
  7866. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7867. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7868. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7869. }
  7870. json_object_array_add(sampledValues, sampledValue);
  7871. }
  7872. }
  7873. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7874. json_object_array_add(meterValues, meterValue);
  7875. }
  7876. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  7877. }
  7878. random_uuid(guid);
  7879. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  7880. json_object_put(TransactionEvent);
  7881. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  7882. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7883. {
  7884. result = PASS;
  7885. }
  7886. queue_operation(QUEUE_OPERATION_ADD, guid, message);
  7887. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Started]) != NULL)
  7888. OCPP_insert_transaction_msg(YES, message);
  7889. else if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL)
  7890. OCPP_insert_transaction_msg(NO, message);
  7891. return result;
  7892. }
  7893. //==========================================
  7894. // send confirm routine
  7895. //==========================================
  7896. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  7897. {
  7898. mtrace();
  7899. int result = FAIL;
  7900. char message[4096]={0};
  7901. json_object *CancelReservation = json_object_new_object();
  7902. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  7903. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  7904. sprintf(message,"[%d,\"%s\",%s]"
  7905. ,MESSAGE_TYPE_CALLRESULT
  7906. ,uuid
  7907. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  7908. json_object_put(CancelReservation);
  7909. ShmOCPP20Data->CsMsg.bits[0].CancelReservationConf = OFF;
  7910. LWS_Send(message);
  7911. result = TRUE;
  7912. return result;
  7913. }
  7914. int sendCertificateSignedConfirmation(char *uuid)
  7915. {
  7916. mtrace();
  7917. int result = FAIL;
  7918. char message[4096]={0};
  7919. json_object *CertificateSigned = json_object_new_object();
  7920. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  7921. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  7922. sprintf(message,"[%d,\"%s\",%s]"
  7923. ,MESSAGE_TYPE_CALLRESULT
  7924. ,uuid
  7925. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  7926. json_object_put(CertificateSigned);
  7927. LWS_Send(message);
  7928. result = TRUE;
  7929. return result;
  7930. }
  7931. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  7932. {
  7933. mtrace();
  7934. int result = FAIL;
  7935. char message[4096]={0};
  7936. json_object *ChangeAvailability = json_object_new_object();
  7937. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  7938. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  7939. sprintf(message,"[%d,\"%s\",%s]"
  7940. ,MESSAGE_TYPE_CALLRESULT
  7941. ,uuid
  7942. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  7943. json_object_put(ChangeAvailability);
  7944. LWS_Send(message);
  7945. result = TRUE;
  7946. return result;
  7947. }
  7948. int sendClearCacheConfirmation(char *uuid)
  7949. {
  7950. mtrace();
  7951. int result = FAIL;
  7952. char message[4096]={0};
  7953. json_object *ClearCache = json_object_new_object();
  7954. DEBUG_INFO("sendClearCacheConfirmation...\n");
  7955. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  7956. sprintf(message,"[%d,\"%s\",%s]"
  7957. ,MESSAGE_TYPE_CALLRESULT
  7958. ,uuid
  7959. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  7960. json_object_put(ClearCache);
  7961. LWS_Send(message);
  7962. result = TRUE;
  7963. return result;
  7964. }
  7965. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  7966. {
  7967. mtrace();
  7968. int result = FAIL;
  7969. char message[500]={0};
  7970. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  7971. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  7972. LWS_Send(message);
  7973. return result;
  7974. }
  7975. int sendClearDisplayMessageConfirmation(char *uuid)
  7976. {
  7977. mtrace();
  7978. int result = FAIL;
  7979. char message[4096]={0};
  7980. json_object *ClearDisplayMessage = json_object_new_object();
  7981. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  7982. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  7983. sprintf(message,"[%d,\"%s\",%s]"
  7984. ,MESSAGE_TYPE_CALLRESULT
  7985. ,uuid
  7986. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7987. json_object_put(ClearDisplayMessage);
  7988. LWS_Send(message);
  7989. result = TRUE;
  7990. return result;
  7991. }
  7992. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7993. {
  7994. mtrace();
  7995. int result = FAIL;
  7996. char message[4096]={0};
  7997. json_object *ClearVariableMonitoring = json_object_new_object();
  7998. json_object *clearMonitoringResults = json_object_new_array();
  7999. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  8000. for(int idx=0;idx<variableQuantity;idx++)
  8001. {
  8002. json_object *clearMonitoringResult = json_object_new_object();
  8003. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  8004. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  8005. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  8006. }
  8007. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  8008. sprintf(message,"[%d,\"%s\",%s]"
  8009. ,MESSAGE_TYPE_CALLRESULT
  8010. ,uuid
  8011. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  8012. json_object_put(ClearVariableMonitoring);
  8013. LWS_Send(message);
  8014. result = TRUE;
  8015. return result;
  8016. }
  8017. int sendCostUpdatedConfirmation(char *uuid)
  8018. {
  8019. mtrace();
  8020. int result = FAIL;
  8021. char message[4096]={0};
  8022. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  8023. sprintf(message,"[%d,\"%s\",{}]"
  8024. ,MESSAGE_TYPE_CALLRESULT
  8025. ,uuid);
  8026. LWS_Send(message);
  8027. result = TRUE;
  8028. return result;
  8029. }
  8030. int sendCustomerInformationConfirmation(char *uuid)
  8031. {
  8032. mtrace();
  8033. int result = FAIL;
  8034. char message[4096]={0};
  8035. json_object *CustomerInformation = json_object_new_object();
  8036. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  8037. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  8038. sprintf(message,"[%d,\"%s\",%s]"
  8039. ,MESSAGE_TYPE_CALLRESULT
  8040. ,uuid
  8041. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  8042. json_object_put(CustomerInformation);
  8043. LWS_Send(message);
  8044. result = TRUE;
  8045. return result;
  8046. }
  8047. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  8048. {
  8049. mtrace();
  8050. int result = FAIL;
  8051. char message[4096]={0};
  8052. json_object *DataTransfer = json_object_new_object();
  8053. DEBUG_INFO("sendDataTransferConfirmation...\n");
  8054. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  8055. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  8056. sprintf(message,"[%d,\"%s\",%s]"
  8057. ,MESSAGE_TYPE_CALLRESULT
  8058. ,uuid
  8059. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  8060. json_object_put(DataTransfer);
  8061. LWS_Send(message);
  8062. result = TRUE;
  8063. return result;
  8064. }
  8065. int sendDeleteCertificateConfirmation(char *uuid)
  8066. {
  8067. mtrace();
  8068. int result = FAIL;
  8069. char message[4096]={0};
  8070. json_object *DeleteCertificate = json_object_new_object();
  8071. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  8072. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  8073. sprintf(message,"[%d,\"%s\",%s]"
  8074. ,MESSAGE_TYPE_CALLRESULT
  8075. ,uuid
  8076. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  8077. json_object_put(DeleteCertificate);
  8078. LWS_Send(message);
  8079. result = TRUE;
  8080. return result;
  8081. }
  8082. int sendGetBaseReportConfirmation(char *uuid)
  8083. {
  8084. mtrace();
  8085. int result = FAIL;
  8086. char message[4096]={0};
  8087. json_object *GetBaseReport = json_object_new_object();
  8088. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  8089. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  8090. sprintf(message,"[%d,\"%s\",%s]"
  8091. ,MESSAGE_TYPE_CALLRESULT
  8092. ,uuid
  8093. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  8094. json_object_put(GetBaseReport);
  8095. LWS_Send(message);
  8096. result = TRUE;
  8097. return result;
  8098. }
  8099. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  8100. {
  8101. mtrace();
  8102. int result = FAIL;
  8103. char message[4096]={0};
  8104. json_object *GetChargingProfiles = json_object_new_object();
  8105. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  8106. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  8107. sprintf(message,"[%d,\"%s\",%s]"
  8108. ,MESSAGE_TYPE_CALLRESULT
  8109. ,uuid
  8110. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  8111. json_object_put(GetChargingProfiles);
  8112. LWS_Send(message);
  8113. result = TRUE;
  8114. return result;
  8115. }
  8116. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  8117. {
  8118. mtrace();
  8119. int result = FAIL;
  8120. char message[4096]={0};
  8121. int CompositeScheduleIndex = 0;
  8122. json_object *GetCompositeSchedule = json_object_new_object();
  8123. json_object *schedule = json_object_new_object();
  8124. json_object *chargingSchedule = json_object_new_object();
  8125. json_object *chargingSchedulePeriod = json_object_new_array();
  8126. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  8127. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  8128. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  8129. if(nPeriod == 0)
  8130. {
  8131. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  8132. {
  8133. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  8134. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  8135. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  8136. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  8137. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  8138. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  8139. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  8140. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  8141. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  8142. {
  8143. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  8144. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  8145. {
  8146. json_object *Period = json_object_new_object();
  8147. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  8148. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  8149. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  8150. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  8151. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  8152. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  8153. json_object_array_add(chargingSchedulePeriod, Period);
  8154. }
  8155. }
  8156. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  8157. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  8158. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  8159. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  8160. }
  8161. }
  8162. else
  8163. {
  8164. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  8165. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  8166. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  8167. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  8168. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  8169. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  8170. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  8171. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  8172. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  8173. {
  8174. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  8175. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  8176. {
  8177. json_object *Period = json_object_new_object();
  8178. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  8179. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  8180. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  8181. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  8182. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  8183. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  8184. json_object_array_add(chargingSchedulePeriod, Period);
  8185. }
  8186. }
  8187. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  8188. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  8189. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  8190. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  8191. }
  8192. sprintf(message,"[%d,\"%s\",%s]"
  8193. ,MESSAGE_TYPE_CALLRESULT
  8194. ,uuid
  8195. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  8196. json_object_put(GetCompositeSchedule);
  8197. LWS_Send(message);
  8198. result = TRUE;
  8199. return result;
  8200. }
  8201. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  8202. {
  8203. mtrace();
  8204. int result = FAIL;
  8205. char message[4096]={0};
  8206. json_object *GetGetDisplayMessages = json_object_new_object();
  8207. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  8208. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  8209. sprintf(message,"[%d,\"%s\",%s]"
  8210. ,MESSAGE_TYPE_CALLRESULT
  8211. ,uuid
  8212. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  8213. json_object_put(GetGetDisplayMessages);
  8214. LWS_Send(message);
  8215. result = TRUE;
  8216. return result;
  8217. }
  8218. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  8219. {
  8220. mtrace();
  8221. int result = FAIL;
  8222. char message[4096]={0};
  8223. json_object *GetInstalledCertificateIds = json_object_new_object();
  8224. json_object *certificateHashDataChains = json_object_new_array();
  8225. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  8226. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  8227. for(int idx=0;idx<certQuantity;idx++)
  8228. {
  8229. json_object *cert = json_object_new_object();
  8230. json_object *certificateHashData = json_object_new_object();
  8231. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  8232. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  8233. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  8234. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  8235. json_object_object_add(cert, "certificateHashData", certificateHashData);
  8236. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  8237. json_object_array_add(certificateHashDataChains, cert);
  8238. }
  8239. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  8240. sprintf(message,"[%d,\"%s\",%s]"
  8241. ,MESSAGE_TYPE_CALLRESULT
  8242. ,uuid
  8243. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  8244. json_object_put(GetInstalledCertificateIds);
  8245. LWS_Send(message);
  8246. result = TRUE;
  8247. return result;
  8248. }
  8249. int sendGetLocalListVersionConfirmation(char *uuid)
  8250. {
  8251. mtrace();
  8252. int result = FAIL;
  8253. char message[4096]={0};
  8254. json_object *GetLocalListVersion = json_object_new_object();
  8255. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  8256. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  8257. sprintf(message,"[%d,\"%s\",%s]"
  8258. ,MESSAGE_TYPE_CALLRESULT
  8259. ,uuid
  8260. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  8261. json_object_put(GetLocalListVersion);
  8262. LWS_Send(message);
  8263. result = TRUE;
  8264. return result;
  8265. }
  8266. int sendGetLogConfirmation(char *uuid)
  8267. {
  8268. mtrace();
  8269. int result = FAIL;
  8270. char message[4096]={0};
  8271. json_object *GetLog = json_object_new_object();
  8272. DEBUG_INFO("sendGetLogConfirmation...\n");
  8273. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  8274. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  8275. sprintf(message,"[%d,\"%s\",%s]"
  8276. ,MESSAGE_TYPE_CALLRESULT
  8277. ,uuid
  8278. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  8279. json_object_put(GetLog);
  8280. LWS_Send(message);
  8281. result = TRUE;
  8282. return result;
  8283. }
  8284. int sendGetMonitoringReportConfirmation(char *uuid)
  8285. {
  8286. mtrace();
  8287. int result = FAIL;
  8288. char message[4096]={0};
  8289. json_object *GetMonitoringReport = json_object_new_object();
  8290. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  8291. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  8292. sprintf(message,"[%d,\"%s\",%s]"
  8293. ,MESSAGE_TYPE_CALLRESULT
  8294. ,uuid
  8295. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  8296. json_object_put(GetMonitoringReport);
  8297. LWS_Send(message);
  8298. result = TRUE;
  8299. return result;
  8300. }
  8301. int sendGetReportConfirmation(char *uuid)
  8302. {
  8303. mtrace();
  8304. int result = FAIL;
  8305. char message[4096]={0};
  8306. json_object *GetReport = json_object_new_object();
  8307. DEBUG_INFO("sendGetReportConfirmation...\n");
  8308. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  8309. sprintf(message,"[%d,\"%s\",%s]"
  8310. ,MESSAGE_TYPE_CALLRESULT
  8311. ,uuid
  8312. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  8313. json_object_put(GetReport);
  8314. LWS_Send(message);
  8315. result = TRUE;
  8316. return result;
  8317. }
  8318. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  8319. {
  8320. mtrace();
  8321. int result = FAIL;
  8322. char message[4096]={0};
  8323. json_object *GetTransactionStatus = json_object_new_object();
  8324. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  8325. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  8326. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  8327. sprintf(message,"[%d,\"%s\",%s]"
  8328. ,MESSAGE_TYPE_CALLRESULT
  8329. ,uuid
  8330. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  8331. json_object_put(GetTransactionStatus);
  8332. LWS_Send(message);
  8333. result = TRUE;
  8334. return result;
  8335. }
  8336. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  8337. {
  8338. mtrace();
  8339. int result = FAIL;
  8340. char message[4096]={0};
  8341. json_object *GetVariables = json_object_new_object();
  8342. json_object *getVariableResults = json_object_new_array();
  8343. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  8344. for(int idx=0;idx<variableQuantity;idx++)
  8345. {
  8346. json_object *variableResult = json_object_new_object();
  8347. json_object *component = json_object_new_object();
  8348. json_object *variable = json_object_new_object();
  8349. json_object *evse = json_object_new_object();
  8350. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  8351. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  8352. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  8353. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  8354. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  8355. json_object_object_add(component, "evse", evse);
  8356. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  8357. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  8358. json_object_object_add(variableResult, "component", component);
  8359. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  8360. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  8361. json_object_object_add(variableResult, "variable", variable);
  8362. json_object_array_add(getVariableResults, variableResult);
  8363. }
  8364. json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
  8365. sprintf(message,"[%d,\"%s\",%s]"
  8366. ,MESSAGE_TYPE_CALLRESULT
  8367. ,uuid
  8368. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  8369. json_object_put(GetVariables);
  8370. LWS_Send(message);
  8371. result = TRUE;
  8372. return result;
  8373. }
  8374. int sendInstallCertificateConfirmation(char *uuid)
  8375. {
  8376. mtrace();
  8377. int result = FAIL;
  8378. char message[4096]={0};
  8379. json_object *InstallCertificate = json_object_new_object();
  8380. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  8381. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  8382. sprintf(message,"[%d,\"%s\",%s]"
  8383. ,MESSAGE_TYPE_CALLRESULT
  8384. ,uuid
  8385. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  8386. json_object_put(InstallCertificate);
  8387. LWS_Send(message);
  8388. result = TRUE;
  8389. return result;
  8390. }
  8391. int sendPublishFirmwareConfirmation(char *uuid)
  8392. {
  8393. mtrace();
  8394. int result = FAIL;
  8395. char message[4096]={0};
  8396. json_object *PublishFirmware = json_object_new_object();
  8397. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  8398. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  8399. sprintf(message,"[%d,\"%s\",%s]"
  8400. ,MESSAGE_TYPE_CALLRESULT
  8401. ,uuid
  8402. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  8403. json_object_put(PublishFirmware);
  8404. LWS_Send(message);
  8405. result = TRUE;
  8406. return result;
  8407. }
  8408. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  8409. {
  8410. mtrace();
  8411. int result = FAIL;
  8412. char message[4096]={0};
  8413. json_object *RemoteStartTransaction = json_object_new_object();
  8414. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  8415. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  8416. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  8417. sprintf(message,"[%d,\"%s\",%s]"
  8418. ,MESSAGE_TYPE_CALLRESULT
  8419. ,uuid
  8420. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  8421. json_object_put(RemoteStartTransaction);
  8422. LWS_Send(message);
  8423. result = TRUE;
  8424. return result;
  8425. }
  8426. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  8427. {
  8428. mtrace();
  8429. int result = FAIL;
  8430. char message[4096]={0};
  8431. json_object *RemoteStopTransaction = json_object_new_object();
  8432. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  8433. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  8434. sprintf(message,"[%d,\"%s\",%s]"
  8435. ,MESSAGE_TYPE_CALLRESULT
  8436. ,uuid
  8437. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  8438. json_object_put(RemoteStopTransaction);
  8439. LWS_Send(message);
  8440. result = TRUE;
  8441. return result;
  8442. }
  8443. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  8444. {
  8445. mtrace();
  8446. int result = FAIL;
  8447. char message[4096]={0};
  8448. json_object *ReserveNow = json_object_new_object();
  8449. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  8450. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  8451. sprintf(message,"[%d,\"%s\",%s]"
  8452. ,MESSAGE_TYPE_CALLRESULT
  8453. ,uuid
  8454. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  8455. json_object_put(ReserveNow);
  8456. LWS_Send(message);
  8457. result = TRUE;
  8458. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  8459. return result;
  8460. }
  8461. int sendResetConfirmation(char *uuid)
  8462. {
  8463. mtrace();
  8464. int result = FAIL;
  8465. char message[4096]={0};
  8466. json_object *Reset = json_object_new_object();
  8467. DEBUG_INFO("sendResetConfirmation...\n");
  8468. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  8469. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  8470. sprintf(message,"[%d,\"%s\",%s]"
  8471. ,MESSAGE_TYPE_CALLRESULT
  8472. ,uuid
  8473. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  8474. json_object_put(Reset);
  8475. LWS_Send(message);
  8476. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  8477. {
  8478. DB_updateBootType(BootReasonEnumType_RemoteReset);
  8479. }
  8480. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  8481. {
  8482. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  8483. }
  8484. result = TRUE;
  8485. return result;
  8486. }
  8487. int sendSendLocalListConfirmation(char *uuid)
  8488. {
  8489. mtrace();
  8490. int result = FAIL;
  8491. char message[4096]={0};
  8492. json_object *SendLocalList = json_object_new_object();
  8493. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  8494. sprintf(message,"[%d,\"%s\",%s]"
  8495. ,MESSAGE_TYPE_CALLRESULT
  8496. ,uuid
  8497. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  8498. json_object_put(SendLocalList);
  8499. LWS_Send(message);
  8500. result = TRUE;
  8501. return result;
  8502. }
  8503. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  8504. {
  8505. mtrace();
  8506. int result = FAIL;
  8507. char message[4096]={0};
  8508. json_object *SetChargingProfile = json_object_new_object();
  8509. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  8510. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  8511. sprintf(message,"[%d,\"%s\",%s]"
  8512. ,MESSAGE_TYPE_CALLRESULT
  8513. ,uuid
  8514. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  8515. json_object_put(SetChargingProfile);
  8516. LWS_Send(message);
  8517. result = TRUE;
  8518. return result;
  8519. }
  8520. int sendSetDisplayMessageConfirmation(char *uuid)
  8521. {
  8522. mtrace();
  8523. int result = FAIL;
  8524. char message[4096]={0};
  8525. json_object *SetDisplayMessage = json_object_new_object();
  8526. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  8527. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  8528. sprintf(message,"[%d,\"%s\",%s]"
  8529. ,MESSAGE_TYPE_CALLRESULT
  8530. ,uuid
  8531. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  8532. json_object_put(SetDisplayMessage);
  8533. LWS_Send(message);
  8534. result = TRUE;
  8535. return result;
  8536. }
  8537. int sendSetMonitoringBaseConfirmation(char *uuid)
  8538. {
  8539. mtrace();
  8540. int result = FAIL;
  8541. char message[4096]={0};
  8542. json_object *SetMonitoringBase = json_object_new_object();
  8543. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  8544. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  8545. sprintf(message,"[%d,\"%s\",%s]"
  8546. ,MESSAGE_TYPE_CALLRESULT
  8547. ,uuid
  8548. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  8549. json_object_put(SetMonitoringBase);
  8550. LWS_Send(message);
  8551. result = TRUE;
  8552. return result;
  8553. }
  8554. int sendSetMonitoringLevelConfirmation(char *uuid)
  8555. {
  8556. mtrace();
  8557. int result = FAIL;
  8558. char message[4096]={0};
  8559. json_object *SetMonitoringLevel = json_object_new_object();
  8560. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  8561. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  8562. sprintf(message,"[%d,\"%s\",%s]"
  8563. ,MESSAGE_TYPE_CALLRESULT
  8564. ,uuid
  8565. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  8566. json_object_put(SetMonitoringLevel);
  8567. LWS_Send(message);
  8568. result = TRUE;
  8569. return result;
  8570. }
  8571. int sendSetNetworkProfileConfirmation(char *uuid)
  8572. {
  8573. mtrace();
  8574. int result = FAIL;
  8575. char message[4096]={0};
  8576. json_object *SetNetworkProfile = json_object_new_object();
  8577. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  8578. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  8579. sprintf(message,"[%d,\"%s\",%s]"
  8580. ,MESSAGE_TYPE_CALLRESULT
  8581. ,uuid
  8582. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  8583. json_object_put(SetNetworkProfile);
  8584. LWS_Send(message);
  8585. result = TRUE;
  8586. return result;
  8587. }
  8588. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  8589. {
  8590. mtrace();
  8591. int result = FAIL;
  8592. char message[4096]={0};
  8593. json_object *SetVariableMonitoring = json_object_new_object();
  8594. json_object *setMonitoringResults = json_object_new_array();
  8595. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  8596. for(int idx=0;idx<variableQuantity;idx++)
  8597. {
  8598. json_object *variableMonitorResult = json_object_new_object();
  8599. json_object *component = json_object_new_object();
  8600. json_object *variable = json_object_new_object();
  8601. json_object *evse = json_object_new_object();
  8602. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  8603. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  8604. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  8605. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  8606. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  8607. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  8608. json_object_object_add(component, "component", evse);
  8609. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  8610. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  8611. json_object_object_add(variableMonitorResult, "component", component);
  8612. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  8613. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  8614. json_object_object_add(variableMonitorResult, "variable", variable);
  8615. json_object_array_add(setMonitoringResults, variableMonitorResult);
  8616. }
  8617. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  8618. sprintf(message,"[%d,\"%s\",%s]"
  8619. ,MESSAGE_TYPE_CALLRESULT
  8620. ,uuid
  8621. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  8622. json_object_put(SetVariableMonitoring);
  8623. LWS_Send(message);
  8624. result = TRUE;
  8625. return result;
  8626. }
  8627. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  8628. {
  8629. mtrace();
  8630. int result = FAIL;
  8631. char message[4096]={0};
  8632. json_object *SetVariable = json_object_new_object();
  8633. json_object *setVariableResults = json_object_new_array();
  8634. DEBUG_INFO("sendSetVariableConfirmation...\n");
  8635. for(int idx=0;idx<variableQuantity;idx++)
  8636. {
  8637. json_object *variableResult = json_object_new_object();
  8638. json_object *component = json_object_new_object();
  8639. json_object *variable = json_object_new_object();
  8640. json_object *evse = json_object_new_object();
  8641. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  8642. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  8643. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  8644. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  8645. json_object_object_add(component, "component", evse);
  8646. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  8647. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  8648. json_object_object_add(variableResult, "component", component);
  8649. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  8650. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  8651. json_object_object_add(variableResult, "variable", variable);
  8652. json_object_array_add(setVariableResults, variableResult);
  8653. }
  8654. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  8655. sprintf(message,"[%d,\"%s\",%s]"
  8656. ,MESSAGE_TYPE_CALLRESULT
  8657. ,uuid
  8658. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  8659. json_object_put(SetVariable);
  8660. LWS_Send(message);
  8661. result = TRUE;
  8662. return result;
  8663. }
  8664. int sendTriggerMessageConfirmation(char *uuid)
  8665. {
  8666. mtrace();
  8667. int result = FAIL;
  8668. char message[4096]={0};
  8669. json_object *TriggerMessage = json_object_new_object();
  8670. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  8671. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  8672. sprintf(message,"[%d,\"%s\",%s]",
  8673. MESSAGE_TYPE_CALLRESULT,
  8674. uuid,
  8675. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  8676. json_object_put(TriggerMessage);
  8677. LWS_Send(message);
  8678. result = TRUE;
  8679. return result;
  8680. }
  8681. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  8682. {
  8683. mtrace();
  8684. int result = FAIL;
  8685. char message[4096]={0};
  8686. json_object *UnlockConnector = json_object_new_object();
  8687. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  8688. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  8689. sprintf(message,"[%d,\"%s\",%s]",
  8690. MESSAGE_TYPE_CALLRESULT,
  8691. uuid,
  8692. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  8693. json_object_put(UnlockConnector);
  8694. LWS_Send(message);
  8695. result = TRUE;
  8696. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  8697. return result;
  8698. }
  8699. int sendUnpublishFirmwareConfirmation(char *uuid)
  8700. {
  8701. mtrace();
  8702. int result = FAIL;
  8703. char message[4096]={0};
  8704. json_object *UnpublishFirmware = json_object_new_object();
  8705. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  8706. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  8707. sprintf(message,"[%d,\"%s\",%s]"
  8708. ,MESSAGE_TYPE_CALLRESULT
  8709. ,uuid
  8710. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  8711. json_object_put(UnpublishFirmware);
  8712. LWS_Send(message);
  8713. result = TRUE;
  8714. return result;
  8715. }
  8716. int sendUpdateFirmwareConfirmation(char *uuid)
  8717. {
  8718. mtrace();
  8719. int result = FAIL;
  8720. char message[4096]={0};
  8721. json_object *UpdateFirmware = json_object_new_object();
  8722. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  8723. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  8724. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  8725. sprintf(message,"[%d,\"%s\",%s]"
  8726. ,MESSAGE_TYPE_CALLRESULT
  8727. ,uuid
  8728. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  8729. json_object_put(UpdateFirmware);
  8730. LWS_Send(message);
  8731. result = TRUE;
  8732. return result;
  8733. }
  8734. int sendUnknownConfirmation(char *uuid)
  8735. {
  8736. mtrace();
  8737. int result = FAIL;
  8738. char message[256]={0};
  8739. //[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
  8740. DEBUG_INFO("sendUnknownConfirmation...\n");
  8741. sprintf(message,"[%d,\"%s\",\"NotImplemented\",\"Requested Action is not known by receiver\",{}]", MESSAGE_TYPE_CALLERROR, uuid);
  8742. LWS_Send(message);
  8743. result = TRUE;
  8744. return result;
  8745. }
  8746. //==========================================
  8747. // send CallError routine
  8748. //==========================================
  8749. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  8750. {
  8751. mtrace();
  8752. char message[220]={0};
  8753. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  8754. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  8755. LWS_Send(message);
  8756. }
  8757. //==========================================
  8758. // Handle server request routine Start
  8759. //==========================================
  8760. int handleCancelReservationRequest(char *uuid, char *payload)
  8761. {
  8762. mtrace();
  8763. int result = FAIL;
  8764. int gunNO = 0;
  8765. int reservationIdInt = -1;
  8766. DEBUG_INFO("handleCancelReservationRequest...\n");
  8767. json_object *CancelReservation;
  8768. CancelReservation = json_tokener_parse(payload);
  8769. if(!is_error(CancelReservation))
  8770. {
  8771. // Required data
  8772. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  8773. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  8774. }
  8775. json_object_put(CancelReservation);
  8776. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  8777. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  8778. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  8779. if(reservationIdInt != -1)
  8780. {
  8781. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  8782. //check Transaction active
  8783. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8784. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8785. {
  8786. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  8787. {
  8788. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8789. if(gunType[2] == GUN_TYPE_CHAdeMO)
  8790. {
  8791. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  8792. }
  8793. else
  8794. {
  8795. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  8796. }
  8797. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8798. goto end;
  8799. }
  8800. }
  8801. for (int index = 0; index < CCS_QUANTITY; index++)
  8802. {
  8803. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  8804. {
  8805. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8806. if(gunType[2] == GUN_TYPE_CCS)
  8807. {
  8808. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  8809. }
  8810. else
  8811. {
  8812. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  8813. }
  8814. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8815. goto end;
  8816. }
  8817. }
  8818. for (int index = 0; index < GB_QUANTITY; index++)
  8819. {
  8820. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  8821. {
  8822. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8823. if(gunType[2] == GUN_TYPE_GBT)
  8824. {
  8825. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  8826. }
  8827. else
  8828. {
  8829. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8830. }
  8831. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8832. goto end;
  8833. }
  8834. }
  8835. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8836. {
  8837. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId == reservationIdInt)
  8838. {
  8839. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8840. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8841. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8842. goto end;
  8843. }
  8844. }
  8845. for (int index = 0; index < AC_QUANTITY; index++)
  8846. {
  8847. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  8848. {
  8849. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8850. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8851. {
  8852. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  8853. }
  8854. else
  8855. {
  8856. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  8857. }
  8858. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8859. goto end;
  8860. }
  8861. }
  8862. }
  8863. //The reservationId does NOT match the reservationId
  8864. sendCancelReservationConfirmation(uuid, gunNO);
  8865. end:
  8866. // Fill in ocpp packet uuid
  8867. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  8868. return result;
  8869. }
  8870. int handleCertificateSignedRequest(char *uuid, char *payload)
  8871. {
  8872. mtrace();
  8873. int result = FAIL;
  8874. json_object *CertificateSigned;
  8875. DEBUG_INFO("handleCertificateSignedRequest...\n");
  8876. CertificateSigned = json_tokener_parse(payload);
  8877. if(!is_error(CertificateSigned))
  8878. {
  8879. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  8880. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  8881. // Required data
  8882. if(json_object_array_length(json_object_object_get(CertificateSigned, "certificate")) <= ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.certificate))
  8883. {
  8884. for(int idx=0;idx<json_object_array_length(json_object_object_get(CertificateSigned, "certificate"));idx++)
  8885. {
  8886. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificate[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateType"), idx)));
  8887. /*
  8888. * TODO:
  8889. * 1. Certificate install response
  8890. */
  8891. }
  8892. }
  8893. // Optional data
  8894. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  8895. {
  8896. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  8897. if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]) == 0)
  8898. {
  8899. }
  8900. else if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0)
  8901. {
  8902. }
  8903. else
  8904. {
  8905. }
  8906. }
  8907. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  8908. }
  8909. else
  8910. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  8911. json_object_put(CertificateSigned);
  8912. sendCertificateSignedConfirmation(uuid);
  8913. return result;
  8914. }
  8915. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  8916. {
  8917. mtrace();
  8918. int result = FAIL;
  8919. int evseId = 0, gunIndex = 0;
  8920. char operationalStatus[16]={0};
  8921. char comfirmstr[20];
  8922. int specificId = FALSE;
  8923. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  8924. json_object *ChangeAvailability;
  8925. ChangeAvailability = json_tokener_parse(payload);
  8926. if(!is_error(ChangeAvailability))
  8927. {
  8928. // Required data
  8929. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  8930. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  8931. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  8932. {
  8933. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  8934. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  8935. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  8936. }
  8937. }
  8938. json_object_put(ChangeAvailability);
  8939. if((evseId != 0) && (evseId <= gunTotalNumber))
  8940. {
  8941. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  8942. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  8943. }
  8944. else if(evseId == 0)
  8945. {
  8946. for(int i=0; i < gunTotalNumber; i++)
  8947. {
  8948. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  8949. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8950. }
  8951. }
  8952. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8953. {
  8954. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  8955. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  8956. }
  8957. else if(gunIndex == 0)
  8958. {
  8959. for(int i=0; i < gunTotalNumber; i++)
  8960. {
  8961. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  8962. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8963. }
  8964. }
  8965. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  8966. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8967. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  8968. {
  8969. specificId = TRUE;
  8970. }
  8971. if(specificId == FALSE)
  8972. goto end;
  8973. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  8974. {
  8975. //----------------------gunIndex is 0 ------------------------------------------------//
  8976. if(gunIndex == 0)
  8977. {
  8978. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8979. {
  8980. for(int i=0; i < gunTotalNumber; i++)
  8981. {
  8982. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8983. {
  8984. if ((gunType[i] == GUN_TYPE_CHAdeMO)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  8985. {
  8986. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8987. {
  8988. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8989. goto end;
  8990. }
  8991. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8992. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8993. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8994. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8995. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8996. {
  8997. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8998. goto end;
  8999. }
  9000. }
  9001. }//END FOR CHAdeMO_QUANTITY
  9002. for (int index = 0; index < CCS_QUANTITY; index++)
  9003. {
  9004. if ((gunType[i] == GUN_TYPE_CCS)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  9005. {
  9006. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  9007. {
  9008. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9009. goto end;
  9010. }
  9011. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  9012. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  9013. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  9014. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  9015. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  9016. {
  9017. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  9018. goto end;
  9019. }
  9020. }
  9021. }//END FOR CCS_QUANTITY
  9022. for (int index = 0; index < GB_QUANTITY; index++)
  9023. {
  9024. if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  9025. {
  9026. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  9027. {
  9028. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9029. goto end;
  9030. }
  9031. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  9032. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  9033. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  9034. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  9035. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  9036. {
  9037. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  9038. goto end;
  9039. }
  9040. }
  9041. }// END FOR GB_QUANTITY
  9042. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9043. {
  9044. if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i))
  9045. {
  9046. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  9047. {
  9048. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9049. goto end;
  9050. }
  9051. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  9052. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  9053. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  9054. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  9055. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  9056. {
  9057. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  9058. goto end;
  9059. }
  9060. }
  9061. }// END FOR DO_QUANTITY
  9062. for (int index = 0; index < AC_QUANTITY; index++)
  9063. {
  9064. if ((gunType[i] == GUN_TYPE_AC)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  9065. {
  9066. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  9067. {
  9068. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9069. goto end;
  9070. }
  9071. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  9072. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  9073. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  9074. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  9075. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  9076. {
  9077. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  9078. goto end;
  9079. }
  9080. }
  9081. }//END FOR AC_QUANTITY
  9082. }// END FOR gunTotalNumber
  9083. }
  9084. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  9085. {
  9086. for(int i=0; i < gunTotalNumber; i++)
  9087. {
  9088. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  9089. {
  9090. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9091. goto end;
  9092. }
  9093. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  9094. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  9095. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  9096. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  9097. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  9098. {
  9099. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  9100. goto end;
  9101. }
  9102. }
  9103. }
  9104. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9105. goto end;
  9106. }
  9107. //----------------------gunIndex is not 0 ------------------------------------------------//
  9108. //check Transaction active
  9109. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  9110. {
  9111. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO))
  9112. {
  9113. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  9114. {
  9115. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9116. goto end;
  9117. }
  9118. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  9119. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  9120. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  9121. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  9122. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  9123. {
  9124. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  9125. goto end;
  9126. }
  9127. else
  9128. {
  9129. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  9130. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9131. goto end;
  9132. }
  9133. }
  9134. }//END FOR CHAdeMO_QUANTITY
  9135. for (int index = 0; index < CCS_QUANTITY; index++)
  9136. {
  9137. if ((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS))
  9138. {
  9139. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  9140. {
  9141. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9142. goto end;
  9143. }
  9144. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  9145. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  9146. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  9147. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  9148. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  9149. {
  9150. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  9151. goto end;
  9152. }
  9153. else
  9154. {
  9155. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  9156. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9157. goto end;
  9158. }
  9159. }
  9160. }//END FOR CCS_QUANTITY
  9161. for (int index = 0; index < GB_QUANTITY; index++)
  9162. {
  9163. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))
  9164. {
  9165. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  9166. {
  9167. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9168. goto end;
  9169. }
  9170. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  9171. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  9172. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  9173. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  9174. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  9175. {
  9176. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  9177. goto end;
  9178. }
  9179. else
  9180. {
  9181. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  9182. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9183. goto end;
  9184. }
  9185. }
  9186. }// END FOR GB_QUANTITY
  9187. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9188. {
  9189. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))
  9190. {
  9191. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  9192. {
  9193. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9194. goto end;
  9195. }
  9196. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  9197. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  9198. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  9199. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  9200. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  9201. {
  9202. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  9203. goto end;
  9204. }
  9205. else
  9206. {
  9207. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  9208. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9209. goto end;
  9210. }
  9211. }
  9212. }// END FOR DO_QUANTITY
  9213. for (int index = 0; index < AC_QUANTITY; index++)
  9214. {
  9215. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC))
  9216. {
  9217. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  9218. {
  9219. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9220. goto end;
  9221. }
  9222. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  9223. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  9224. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  9225. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  9226. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  9227. {
  9228. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  9229. goto end;
  9230. }
  9231. else
  9232. {
  9233. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  9234. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9235. goto end;
  9236. }
  9237. }
  9238. }//END FOR AC_QUANTITY
  9239. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  9240. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  9241. {
  9242. //----------------------gunIndex is 0 ------------------------------------------------//
  9243. if(gunIndex == 0)
  9244. {
  9245. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  9246. {
  9247. for(int i=0; i < gunTotalNumber; i++)
  9248. {
  9249. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  9250. {
  9251. if ((gunType[i] == GUN_TYPE_CHAdeMO )&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO)) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9252. {
  9253. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9254. goto end;
  9255. }
  9256. }//END FOR CHAdeMO_QUANTITY
  9257. for (int index = 0; index < CCS_QUANTITY; index++)
  9258. {
  9259. if ((gunType[i] == GUN_TYPE_CCS)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT//(((gunIndex == 0)|| ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9260. {
  9261. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9262. goto end;
  9263. }
  9264. }//END FOR CCS_QUANTITY
  9265. for (int index = 0; index < GB_QUANTITY; index++)
  9266. {
  9267. if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT)))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9268. {
  9269. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  9270. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9271. goto end;
  9272. }
  9273. }// END FOR GB_QUANTITY
  9274. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9275. {
  9276. if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT)))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9277. {
  9278. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  9279. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9280. goto end;
  9281. }
  9282. }// END FOR DO_QUANTITY
  9283. for (int index = 0; index < AC_QUANTITY; index++)
  9284. {
  9285. if ((gunType[i] == GUN_TYPE_AC) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT // (((gunIndex == 0)|| ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9286. {
  9287. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9288. goto end;
  9289. }
  9290. }//END FOR CHAdeMO_QUANTITY
  9291. }// END FOR gunTotalNumber
  9292. }
  9293. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  9294. {
  9295. for(int i=0; i < gunTotalNumber; i++)
  9296. {
  9297. for (int index = 0; index < AC_QUANTITY; index++)
  9298. {
  9299. if ((gunType[i] == GUN_TYPE_AC) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT // (((gunIndex == 0)|| ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9300. {
  9301. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9302. goto end;
  9303. }
  9304. }//END FOR CHAdeMO_QUANTITY
  9305. } // END FOR gunTotalNumber
  9306. }
  9307. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9308. goto end;
  9309. }
  9310. //----------------------gunIndex is not 0 ------------------------------------------------//
  9311. //check Transaction active
  9312. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  9313. {
  9314. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9315. {
  9316. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9317. goto end;
  9318. }
  9319. }//END FOR CHAdeMO_QUANTITY
  9320. for (int index = 0; index < CCS_QUANTITY; index++)
  9321. {
  9322. if ((((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS)) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9323. {
  9324. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9325. goto end;
  9326. }
  9327. }//END FOR CCS_QUANTITY
  9328. for (int index = 0; index < GB_QUANTITY; index++)
  9329. {
  9330. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9331. {
  9332. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9333. goto end;
  9334. }
  9335. }// END FOR GB_QUANTITY
  9336. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9337. {
  9338. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9339. {
  9340. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9341. goto end;
  9342. }
  9343. }// END FOR DO_QUANTITY
  9344. for (int index = 0; index < AC_QUANTITY; index++)
  9345. {
  9346. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC)) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9347. {
  9348. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9349. goto end;
  9350. }
  9351. }//END FOR AC_QUANTITY
  9352. }//END FOR AvailabilityEnumTypeStr[Operative]
  9353. end:
  9354. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  9355. {
  9356. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  9357. }
  9358. else
  9359. {
  9360. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  9361. }
  9362. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  9363. {
  9364. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  9365. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  9366. }
  9367. else if(gunIndex == 0)
  9368. {
  9369. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  9370. {
  9371. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  9372. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  9373. }
  9374. }
  9375. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  9376. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  9377. return result;
  9378. }
  9379. int handleClearCacheRequest(char *uuid, char *payload)
  9380. {
  9381. mtrace();
  9382. int result = FAIL;
  9383. char rmFileCmd[100]={0};
  9384. struct stat stats;
  9385. DEBUG_INFO("handleClearCacheRequest...\n");
  9386. stat("/Storage/OCPP", &stats);
  9387. // Check for directory existence
  9388. if (S_ISDIR(stats.st_mode) == 1)
  9389. {}
  9390. else
  9391. {
  9392. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  9393. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  9394. system(rmFileCmd);
  9395. }
  9396. /*
  9397. * TODO:
  9398. * 1. Clear cache from sqlite db
  9399. */
  9400. if(1)
  9401. {
  9402. DEBUG_INFO("open AuthorizationCache file failed\n");
  9403. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  9404. }
  9405. else
  9406. {
  9407. DEBUG_INFO("open AuthorizationCache file successful\n");
  9408. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  9409. }
  9410. sendClearCacheConfirmation(uuid);
  9411. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  9412. return result;
  9413. }
  9414. int handleClearChargingProfileRequest(char *uuid, char *payload)
  9415. {
  9416. mtrace();
  9417. int result = FAIL;
  9418. int resultRename;
  9419. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  9420. char chargingProfilePurposeStr[26]={0};
  9421. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  9422. char tempchargingProfilePurposeStr[26]={0};
  9423. char sstr[160]={0};
  9424. char str[100]={0};
  9425. int c = 0;
  9426. char *loc;
  9427. char fname[200]={0};
  9428. char comfirmstr[20]={0};
  9429. char word[1600]={0};
  9430. int clearflag = FALSE;
  9431. int chargingProfileIdIsNULL = FALSE;
  9432. int connectorIsNULL = FALSE;
  9433. int chargingProfilePurposeIsNULL = FALSE;
  9434. int stackLevelIsNULL = FALSE;
  9435. //int GotoEnd = FALSE;
  9436. FILE *fptr1, *fptr2;
  9437. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  9438. int n_chargingProfile=0;
  9439. int isEmptyFile = FALSE;
  9440. char sLineWord[1600]={0};
  9441. char chargingProfiles[10][100]={0};
  9442. int ChargeProfileCount = 0;
  9443. int ch;
  9444. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  9445. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  9446. json_object *ClearChargingProfile;
  9447. ClearChargingProfile = json_tokener_parse(payload);
  9448. if(!is_error(ClearChargingProfile))
  9449. {
  9450. // Optional data
  9451. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  9452. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  9453. else
  9454. chargingProfileIdIsNULL = TRUE;
  9455. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  9456. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  9457. else
  9458. connectorIsNULL = TRUE;
  9459. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  9460. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  9461. else
  9462. chargingProfilePurposeIsNULL = TRUE;
  9463. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  9464. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  9465. else
  9466. stackLevelIsNULL = TRUE;
  9467. }
  9468. json_object_put(ClearChargingProfile);
  9469. if(connectorIsNULL == FALSE)
  9470. {
  9471. switch(connectorIdInt)
  9472. {
  9473. case 0:
  9474. if(chargingProfilePurposeIsNULL == TRUE)
  9475. {
  9476. int l = 0;
  9477. strcpy(fname, ChargePointMaxProfile_JSON);
  9478. if((access(fname,F_OK))!=-1)
  9479. {
  9480. strcpy(chargingProfiles[l], fname);
  9481. l = l + 1;
  9482. }
  9483. strcpy(fname, TxDefaultProfile_0_JSON);
  9484. if((access(fname,F_OK))!=-1)
  9485. {
  9486. strcpy(chargingProfiles[l], fname);
  9487. l = l + 1;
  9488. }
  9489. ChargeProfileCount = l;
  9490. }
  9491. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  9492. {
  9493. strcpy(fname, ChargePointMaxProfile_JSON);
  9494. if((access(fname,F_OK))!=-1)
  9495. {
  9496. strcpy(chargingProfiles[0], fname);
  9497. ChargeProfileCount = 1;
  9498. }
  9499. }
  9500. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  9501. {
  9502. strcpy(fname, TxDefaultProfile_0_JSON);
  9503. if((access(fname,F_OK))!=-1)
  9504. {
  9505. strcpy(chargingProfiles[0], fname);
  9506. ChargeProfileCount = 1;
  9507. }
  9508. }
  9509. break;
  9510. default:
  9511. if(chargingProfilePurposeIsNULL == TRUE)
  9512. {
  9513. int m = 0;
  9514. memset(fname, 0, ARRAY_SIZE(fname));
  9515. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  9516. if((access(fname,F_OK))!=-1)
  9517. {
  9518. strcpy(chargingProfiles[m], fname);
  9519. m = m + 1;
  9520. }
  9521. memset(fname, 0, ARRAY_SIZE(fname));
  9522. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  9523. if((access(fname,F_OK))!=-1)
  9524. {
  9525. strcpy(chargingProfiles[m], fname);
  9526. m = m + 1;
  9527. }
  9528. ChargeProfileCount = m;
  9529. }
  9530. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  9531. {
  9532. //strcpy(fname, TxDefaultProfile_1_JSON);
  9533. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  9534. if((access(fname,F_OK))!=-1)
  9535. {
  9536. strcpy(chargingProfiles[0], fname);
  9537. ChargeProfileCount = 1;
  9538. }
  9539. }
  9540. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  9541. {
  9542. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  9543. if((access(fname,F_OK))!=-1)
  9544. {
  9545. strcpy(chargingProfiles[0], fname);
  9546. ChargeProfileCount = 1;
  9547. }
  9548. }
  9549. //strcpy(fname, ChargePointMaxProfile_JSON );
  9550. break;
  9551. }
  9552. }
  9553. else // Check all Charging Profiles
  9554. {
  9555. int i = 0;
  9556. char fnametemp[200]={0};
  9557. ChargeProfileCount = 0;
  9558. //Check ChargePointMaxProfile.json exit
  9559. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  9560. {
  9561. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  9562. i = i + 1;
  9563. }
  9564. //Check TxDefaultProfile_0.json exit
  9565. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  9566. {
  9567. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  9568. i = i + 1;
  9569. }
  9570. //Check TxDefaultProfile_%d.json
  9571. for(int j=1; j <= gunTotalNumber; j++)
  9572. {
  9573. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9574. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  9575. if((access(fnametemp,F_OK))!=-1)
  9576. {
  9577. strcpy(chargingProfiles[i], fnametemp);
  9578. i = i + 1;
  9579. }
  9580. }
  9581. //Check TxProfile_%d.json
  9582. for(int j=1; j <= gunTotalNumber; j++)
  9583. {
  9584. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9585. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  9586. if((access(fnametemp,F_OK))!=-1)
  9587. {
  9588. strcpy(chargingProfiles[i], fnametemp);
  9589. i = i + 1;
  9590. }
  9591. }
  9592. ChargeProfileCount = i;
  9593. }// End connectorIsNULL is TRUE
  9594. if(ChargeProfileCount == 0)
  9595. {
  9596. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9597. goto end;
  9598. }
  9599. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  9600. {
  9601. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9602. goto end;
  9603. }
  9604. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  9605. {
  9606. memset(str, 0, ARRAY_SIZE(str));
  9607. // clear temp file
  9608. sprintf(str,"rm -f %s",temp);
  9609. system(str);
  9610. for(int k=0; k < ChargeProfileCount; k++)
  9611. {
  9612. memset(str, 0, ARRAY_SIZE(str));
  9613. //clear file in C
  9614. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9615. system(str);
  9616. }
  9617. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9618. goto end;
  9619. }
  9620. else if(connectorIsNULL == TRUE)
  9621. {
  9622. for(int k=0; k < ChargeProfileCount; k++)
  9623. {
  9624. fptr1 = fopen(chargingProfiles[k], "r");
  9625. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  9626. //Check Charging Profile Count
  9627. while(fscanf(fptr1, "%s", word) != EOF)
  9628. {
  9629. //DEBUG_INFO("word=%s\n",word);
  9630. if(strstr(word, "chargingProfileId")!= NULL)
  9631. {
  9632. //DEBUG_INFO("test chargingProfileId \n");
  9633. n_chargingProfile = n_chargingProfile + 1;
  9634. //DEBUG_INFO("chargingProfileId Found\n");
  9635. }
  9636. }
  9637. rewind(fptr1);
  9638. //search Charging Profile Element
  9639. //int i= 0;
  9640. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9641. {
  9642. //------------------------tempconnectorIdInt------------------------//
  9643. loc = strstr(sLineWord, "connectorId");
  9644. c = 0;
  9645. memset(sstr ,0, sizeof(sstr) );
  9646. while (loc[strlen("connectorId")+2+c] != ',')
  9647. {
  9648. sstr[c] = loc[strlen("connectorId")+2+c];
  9649. c++;
  9650. }
  9651. sstr[c] = '\0';
  9652. tempconnectorIdInt = atoi(sstr);
  9653. printf("file's gun number is %d\n", tempconnectorIdInt);
  9654. //--------------------------chargingProfileId--------------------//
  9655. c = 0;
  9656. loc = strstr(sLineWord, "chargingProfileId");
  9657. memset(sstr ,0, ARRAY_SIZE(sstr));
  9658. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9659. {
  9660. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9661. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9662. c++;
  9663. }
  9664. sstr[c] = '\0';
  9665. tempchargingProfileIdInt = atoi(sstr);
  9666. //stackLevel
  9667. c = 0;
  9668. loc = strstr(sLineWord, "stackLevel");
  9669. memset(sstr ,0, ARRAY_SIZE(sstr));
  9670. while (loc[strlen("stackLevel")+2+c] != ',')
  9671. {
  9672. sstr[c] = loc[strlen("stackLevel")+2+c];
  9673. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9674. c++;
  9675. }
  9676. sstr[c] = '\0';
  9677. tempstackLevelInt = atoi(sstr);
  9678. c = 0;
  9679. loc = strstr(sLineWord, "chargingProfilePurpose");
  9680. memset(sstr ,0, ARRAY_SIZE(sstr));
  9681. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9682. {
  9683. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9684. c++;
  9685. }
  9686. sstr[c] = '\0';
  9687. strcpy(tempchargingProfilePurposeStr, sstr);
  9688. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9689. {
  9690. //------- not write to fptr2-------//
  9691. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9692. //clearflag = TRUE;
  9693. }
  9694. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  9695. {
  9696. //------- not write to fptr2-------//
  9697. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9698. }
  9699. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9700. {
  9701. //------- not write to fptr2-------//
  9702. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9703. }
  9704. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  9705. {
  9706. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9707. }
  9708. else
  9709. {
  9710. fprintf(fptr2, sLineWord);//writing data into file
  9711. }
  9712. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9713. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9714. if(clearflag == TRUE)
  9715. {
  9716. fclose(fptr1);
  9717. fclose(fptr2);
  9718. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9719. system(str);
  9720. // clear temp file
  9721. sprintf(str,"rm -f %s",temp);
  9722. system(str);
  9723. }
  9724. else
  9725. {
  9726. fclose(fptr1);
  9727. fclose(fptr2);
  9728. memset(str, 0, ARRAY_SIZE(str));
  9729. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9730. system(str);
  9731. resultRename = rename(temp, chargingProfiles[k]);
  9732. if(resultRename == 0)
  9733. {
  9734. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  9735. }
  9736. else
  9737. {
  9738. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  9739. }
  9740. if(comfirmstr[0]== 0)
  9741. {
  9742. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9743. }
  9744. //Check chargingProfile is empty file
  9745. /*------ Read the file ----------------*/
  9746. fptr1=fopen(chargingProfiles[k],"r");
  9747. ch=fgetc(fptr1);
  9748. rewind(fptr1);
  9749. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9750. if(ch!=EOF)
  9751. {
  9752. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9753. {
  9754. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9755. if(sLineWord[0]=='\0')
  9756. {
  9757. isEmptyFile = TRUE;
  9758. break;
  9759. }
  9760. else
  9761. {
  9762. isEmptyFile = FALSE;
  9763. break;
  9764. }
  9765. }
  9766. }
  9767. else
  9768. isEmptyFile = TRUE;
  9769. fclose(fptr1);
  9770. if(isEmptyFile == TRUE)
  9771. {
  9772. memset(str, 0, ARRAY_SIZE(str));
  9773. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9774. system(str);
  9775. }
  9776. }
  9777. }// End of while(int k=0; k < ChargePointCount; k++)
  9778. }
  9779. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  9780. {
  9781. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  9782. for(int k=0; k < ChargeProfileCount; k++)
  9783. {
  9784. fptr1 = fopen(chargingProfiles[k], "r");
  9785. fptr2 = fopen(temp, "w+");
  9786. //Check Charging Profile Count
  9787. while(fscanf(fptr1, "%s", word) != EOF)
  9788. {
  9789. //DEBUG_INFO("word=%s\n",word);
  9790. if(strstr(word, "chargingProfileId")!= NULL)
  9791. {
  9792. n_chargingProfile = n_chargingProfile + 1;
  9793. }
  9794. }
  9795. rewind(fptr1);
  9796. //search Charging Profile Element
  9797. //int i= 0;
  9798. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9799. {
  9800. //*************************tempconnectorIdInt*********************************/
  9801. loc = strstr(sLineWord, "connectorId");
  9802. c = 0;
  9803. memset(sstr ,0, ARRAY_SIZE(sstr));
  9804. while (loc[strlen("connectorId")+2+c] != ',')
  9805. {
  9806. sstr[c] = loc[strlen("connectorId")+2+c];
  9807. c++;
  9808. }
  9809. sstr[c] = '\0';
  9810. tempconnectorIdInt = atoi(sstr);
  9811. //chargingProfileId
  9812. c = 0;
  9813. loc = strstr(sLineWord, "chargingProfileId");
  9814. memset(sstr ,0, ARRAY_SIZE(sstr));
  9815. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9816. {
  9817. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9818. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9819. c++;
  9820. }
  9821. sstr[c] = '\0';
  9822. tempchargingProfileIdInt = atoi(sstr);
  9823. //stackLevel
  9824. c = 0;
  9825. loc = strstr(sLineWord, "stackLevel");
  9826. memset(sstr ,0, ARRAY_SIZE(sstr));
  9827. while (loc[strlen("stackLevel")+2+c] != ',')
  9828. {
  9829. sstr[c] = loc[strlen("stackLevel")+2+c];
  9830. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9831. c++;
  9832. }
  9833. sstr[c] = '\0';
  9834. tempstackLevelInt = atoi(sstr);
  9835. c = 0;
  9836. loc = strstr(sLineWord, "chargingProfilePurpose");
  9837. memset(sstr ,0, ARRAY_SIZE(sstr));
  9838. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9839. {
  9840. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9841. c++;
  9842. }
  9843. sstr[c] = '\0';
  9844. strcpy(tempchargingProfilePurposeStr, sstr);
  9845. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9846. {
  9847. //------- not write to fptr2-------//
  9848. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9849. //clearflag = TRUE;
  9850. }
  9851. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9852. {
  9853. //------- not write to fptr2-------//
  9854. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9855. }
  9856. else if(stackLevelIsNULL == TRUE)
  9857. {
  9858. //Clear Whole File
  9859. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9860. clearflag = TRUE;
  9861. break;
  9862. }
  9863. else
  9864. {
  9865. fprintf(fptr2, sLineWord);//writing data into file
  9866. }
  9867. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9868. }
  9869. if(clearflag == TRUE)
  9870. {
  9871. fclose(fptr1);
  9872. fclose(fptr2);
  9873. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9874. system(str);
  9875. // clear temp file
  9876. sprintf(str,"rm -f %s",temp);
  9877. system(str);
  9878. }
  9879. else
  9880. {
  9881. fclose(fptr1);
  9882. fclose(fptr2);
  9883. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9884. system(str);
  9885. resultRename = rename(temp, chargingProfiles[k]);
  9886. if(resultRename == 0)
  9887. {
  9888. DEBUG_INFO("File ChargingProfile renamed successfully");
  9889. }
  9890. else
  9891. {
  9892. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  9893. }
  9894. if(comfirmstr[0]== 0)
  9895. {
  9896. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9897. }
  9898. //Check chargingProfile is empty file
  9899. /*------ Read the file ----------------*/
  9900. fptr1=fopen(chargingProfiles[k],"r");
  9901. ch=fgetc(fptr1);
  9902. rewind(fptr1);
  9903. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9904. if(ch!=EOF)
  9905. {
  9906. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9907. {
  9908. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9909. if(sLineWord[0]=='\0')
  9910. {
  9911. isEmptyFile = TRUE;
  9912. break;
  9913. }
  9914. else
  9915. {
  9916. isEmptyFile = FALSE;
  9917. break;
  9918. }
  9919. }
  9920. }
  9921. else
  9922. isEmptyFile = TRUE;
  9923. fclose(fptr1);
  9924. if(isEmptyFile == TRUE)
  9925. {
  9926. memset(str, 0, ARRAY_SIZE(str));
  9927. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9928. system(str);
  9929. }
  9930. /*------- End of reading ---------------*/
  9931. }
  9932. } // while(int k=0; k < ChargeProfileCount; k++)
  9933. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  9934. end:
  9935. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  9936. {
  9937. if(connectorIdInt == 0)
  9938. {
  9939. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  9940. {
  9941. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  9942. }
  9943. }
  9944. else
  9945. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1], 0, TRUE);
  9946. }
  9947. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  9948. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  9949. return result;
  9950. }
  9951. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  9952. {
  9953. mtrace();
  9954. int result = FAIL;
  9955. json_object *ClearDisplayMessage;
  9956. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  9957. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  9958. ClearDisplayMessage = json_tokener_parse(payload);
  9959. if(!is_error(ClearDisplayMessage))
  9960. {
  9961. // Required data
  9962. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  9963. {
  9964. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  9965. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  9966. }
  9967. }
  9968. json_object_put(ClearDisplayMessage);
  9969. sendCostUpdatedConfirmation(uuid);
  9970. return result;
  9971. }
  9972. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  9973. {
  9974. mtrace();
  9975. int result = FAIL;
  9976. json_object *ClearVariableMonitorin;
  9977. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  9978. ClearVariableMonitorin = json_tokener_parse(payload);
  9979. if(!is_error(ClearVariableMonitorin))
  9980. {
  9981. // Required data
  9982. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  9983. {
  9984. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  9985. {
  9986. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  9987. /*
  9988. * TODO:
  9989. * 1. Check response
  9990. */
  9991. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  9992. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  9993. }
  9994. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  9995. }
  9996. }
  9997. json_object_put(ClearVariableMonitorin);
  9998. return result;
  9999. }
  10000. int handleCostUpdatedRequest(char *uuid, char *payload)
  10001. {
  10002. mtrace();
  10003. int result = FAIL;
  10004. json_object *CostUpdate;
  10005. DEBUG_INFO("handleCostUpdatedRequest...\n");
  10006. CostUpdate = json_tokener_parse(payload);
  10007. if(!is_error(CostUpdate))
  10008. {
  10009. // Required data
  10010. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  10011. {
  10012. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  10013. }
  10014. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  10015. {
  10016. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  10017. }
  10018. }
  10019. json_object_put(CostUpdate);
  10020. sendCostUpdatedConfirmation(uuid);
  10021. return result;
  10022. }
  10023. int handleCustomerInformationRequest(char *uuid, char *payload)
  10024. {
  10025. mtrace();
  10026. int result = FAIL;
  10027. json_object *CustomerInformation;
  10028. DEBUG_INFO("handleCustomerInformationRequest...\n");
  10029. CustomerInformation = json_tokener_parse(payload);
  10030. if(!is_error(CustomerInformation))
  10031. {
  10032. // Required data
  10033. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  10034. {
  10035. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  10036. }
  10037. if(json_object_object_get(CustomerInformation, "report") != NULL)
  10038. {
  10039. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  10040. }
  10041. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  10042. {
  10043. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  10044. }
  10045. // Optional data
  10046. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  10047. {
  10048. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  10049. {
  10050. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  10051. }
  10052. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  10053. {
  10054. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  10055. }
  10056. }
  10057. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  10058. {
  10059. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  10060. {
  10061. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  10062. }
  10063. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  10064. {
  10065. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  10066. }
  10067. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  10068. {
  10069. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  10070. }
  10071. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  10072. {
  10073. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  10074. }
  10075. }
  10076. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  10077. }
  10078. else
  10079. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  10080. json_object_put(CustomerInformation);
  10081. sendCustomerInformationConfirmation(uuid);
  10082. return result;
  10083. }
  10084. void createFirmwareVersionByDataTransfer(void)
  10085. {
  10086. json_object *FirmwareDataTransfer = json_object_new_object();
  10087. // AC & DC model
  10088. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  10089. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  10090. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  10091. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  10092. // DC model
  10093. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O')
  10094. {
  10095. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  10096. {
  10097. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  10098. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  10099. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  10100. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  10101. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  10102. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  10103. }
  10104. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  10105. ((gunType[1] != GUN_TYPE_UNKNOWN) || (gunType[2] != GUN_TYPE_UNKNOWN) || (gunType[3] != GUN_TYPE_UNKNOWN)))
  10106. {
  10107. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  10108. }
  10109. }
  10110. else
  10111. {
  10112. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  10113. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  10114. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  10115. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  10116. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  10117. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  10118. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  10119. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  10120. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  10121. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  10122. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  10123. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  10124. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  10125. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  10126. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  10127. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  10128. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  10129. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  10130. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  10131. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  10132. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  10133. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  10134. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  10135. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  10136. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  10137. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  10138. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  10139. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  10140. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  10141. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  10142. json_object_object_add(FirmwareDataTransfer, "DD1_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  10143. }
  10144. // 4G model
  10145. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  10146. {
  10147. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  10148. }
  10149. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  10150. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  10151. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
  10152. }
  10153. int handleDataTransferRequest(char *uuid, char *payload)
  10154. {
  10155. mtrace();
  10156. int result = PASS;
  10157. DEBUG_INFO("handleDataTransferRequest...\n");
  10158. if((uuid != NULL) && (payload != NULL))
  10159. {
  10160. json_object *DataTransfer;
  10161. DataTransfer = json_tokener_parse(payload);
  10162. if(!is_error(DataTransfer))
  10163. {
  10164. // Required data
  10165. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  10166. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  10167. // Optional data
  10168. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  10169. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  10170. if(json_object_object_get(DataTransfer, "data") != NULL)
  10171. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  10172. result = PASS;
  10173. }
  10174. json_object_put(DataTransfer);
  10175. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  10176. {
  10177. // Send all moudle firmware version on EVSE
  10178. createFirmwareVersionByDataTransfer();
  10179. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  10180. }
  10181. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  10182. {
  10183. system("/usr/bin/run_tmate_restart.sh &");
  10184. }
  10185. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  10186. {
  10187. json_object *data;
  10188. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  10189. if(!is_error(data))
  10190. {
  10191. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  10192. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  10193. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  10194. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  10195. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  10196. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  10197. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  10198. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  10199. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  10200. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  10201. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  10202. }
  10203. else
  10204. {
  10205. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  10206. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  10207. }
  10208. json_object_put(data);
  10209. }
  10210. else
  10211. {
  10212. // Can not find valid message id
  10213. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  10214. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  10215. ,ShmOCPP20Data->DataTransfer[0].vendorId
  10216. ,ShmOCPP20Data->DataTransfer[0].messageId
  10217. ,ShmOCPP20Data->DataTransfer[0].data);
  10218. }
  10219. }
  10220. else
  10221. {
  10222. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  10223. result = FAIL;
  10224. }
  10225. sendDataTransferConfirmation(uuid, 0);
  10226. return result;
  10227. }
  10228. int handleDeleteCertificateRequest(char *uuid, char *payload)
  10229. {
  10230. mtrace();
  10231. int result = FAIL;
  10232. json_object *DeleteCertificate;
  10233. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  10234. DeleteCertificate = json_tokener_parse(payload);
  10235. if(!is_error(DeleteCertificate))
  10236. {
  10237. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  10238. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  10239. // Required data
  10240. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  10241. {
  10242. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  10243. {
  10244. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  10245. }
  10246. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  10247. {
  10248. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  10249. }
  10250. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  10251. {
  10252. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  10253. }
  10254. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  10255. {
  10256. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  10257. }
  10258. /*
  10259. * TODO:
  10260. * 1. Delete certification and response
  10261. */
  10262. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  10263. }
  10264. }
  10265. else
  10266. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  10267. json_object_put(DeleteCertificate);
  10268. sendDeleteCertificateConfirmation(uuid);
  10269. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10270. return result;
  10271. }
  10272. int handleGetBaseReportRequest(char *uuid, char *payload)
  10273. {
  10274. mtrace();
  10275. int result = FAIL;
  10276. json_object *GetBaseRepor;
  10277. DEBUG_INFO("handleGetBaseReportRequest...\n");
  10278. GetBaseRepor = json_tokener_parse(payload);
  10279. if(!is_error(GetBaseRepor))
  10280. {
  10281. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  10282. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  10283. // Required data
  10284. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  10285. {
  10286. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  10287. }
  10288. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  10289. {
  10290. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  10291. }
  10292. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_SummaryInventory]) == 0)
  10293. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  10294. else
  10295. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10296. }
  10297. else
  10298. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  10299. json_object_put(GetBaseRepor);
  10300. sendGetBaseReportConfirmation(uuid);
  10301. return result;
  10302. }
  10303. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  10304. {
  10305. mtrace();
  10306. int result = FAIL;
  10307. int gun_index = -1;
  10308. json_object *GetChargingProfiles;
  10309. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  10310. GetChargingProfiles = json_tokener_parse(payload);
  10311. if(!is_error(GetChargingProfiles))
  10312. {
  10313. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  10314. {
  10315. 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;
  10316. }
  10317. if(gun_index >-1)
  10318. {
  10319. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  10320. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  10321. // Required data
  10322. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  10323. {
  10324. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  10325. }
  10326. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  10327. {
  10328. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  10329. {
  10330. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  10331. }
  10332. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  10333. {
  10334. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  10335. }
  10336. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  10337. {
  10338. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  10339. {
  10340. 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)));
  10341. }
  10342. }
  10343. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  10344. {
  10345. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  10346. {
  10347. 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));
  10348. }
  10349. }
  10350. }
  10351. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  10352. }
  10353. else
  10354. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  10355. }
  10356. json_object_put(GetChargingProfiles);
  10357. sendGetChargingProfilesConfirmation(uuid, gun_index);
  10358. return result;
  10359. }
  10360. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  10361. {
  10362. mtrace();
  10363. int result = FAIL;
  10364. int connectorIdInt, durationInt;
  10365. char chargingRateUnitStr[4]={0};
  10366. char comfirmstr[20];
  10367. int confirmPeriods = 0;
  10368. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  10369. json_object *GetCompositeSchedule;
  10370. GetCompositeSchedule = json_tokener_parse(payload);
  10371. if(!is_error(GetCompositeSchedule))
  10372. {
  10373. // Required data
  10374. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  10375. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  10376. else
  10377. connectorIdInt = -1;
  10378. if(json_object_object_get(GetCompositeSchedule, "duration"))
  10379. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  10380. else
  10381. durationInt = 86400;
  10382. // Optional data
  10383. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  10384. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  10385. }
  10386. json_object_put(GetCompositeSchedule);
  10387. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  10388. if((connectorIdInt == 0) ||
  10389. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  10390. {
  10391. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  10392. struct ChargingProfileType tmpProfile[1];
  10393. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  10394. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  10395. if(strstr(chargingRateUnitStr, "W") != NULL)
  10396. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, FALSE);
  10397. else
  10398. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, TRUE);
  10399. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  10400. {
  10401. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  10402. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  10403. }
  10404. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  10405. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  10406. {
  10407. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  10408. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  10409. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  10410. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0))
  10411. {
  10412. confirmPeriods = idx;
  10413. break;
  10414. }
  10415. }
  10416. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10417. }
  10418. else
  10419. {
  10420. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  10421. }
  10422. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  10423. return result;
  10424. }
  10425. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  10426. {
  10427. mtrace();
  10428. int result = FAIL;
  10429. json_object *GetDisplayMessages;
  10430. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  10431. GetDisplayMessages = json_tokener_parse(payload);
  10432. if(!is_error(GetDisplayMessages))
  10433. {
  10434. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  10435. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  10436. // Required data
  10437. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  10438. {
  10439. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  10440. }
  10441. // Optional data
  10442. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  10443. {
  10444. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  10445. }
  10446. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  10447. {
  10448. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  10449. }
  10450. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  10451. {
  10452. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  10453. {
  10454. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  10455. }
  10456. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  10457. }
  10458. else
  10459. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  10460. }
  10461. json_object_put(GetDisplayMessages);
  10462. return result;
  10463. }
  10464. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  10465. {
  10466. mtrace();
  10467. int result = FAIL;
  10468. json_object *GetInstalledCertificateIds;
  10469. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  10470. GetInstalledCertificateIds = json_tokener_parse(payload);
  10471. if(!is_error(GetInstalledCertificateIds))
  10472. {
  10473. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  10474. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  10475. // Optional data
  10476. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  10477. {
  10478. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  10479. {
  10480. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  10481. /*
  10482. * TODO:
  10483. * 1. Get installed certificate info for response
  10484. */
  10485. }
  10486. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  10487. }
  10488. else
  10489. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  10490. }
  10491. json_object_put(GetInstalledCertificateIds);
  10492. sendInstallCertificateConfirmation(uuid);
  10493. return result;
  10494. }
  10495. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  10496. {
  10497. mtrace();
  10498. int result = FAIL;
  10499. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  10500. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  10501. {
  10502. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  10503. localversion = -1;
  10504. }
  10505. else
  10506. {
  10507. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  10508. DB_getListVerion();
  10509. }
  10510. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  10511. sendGetLocalListVersionConfirmation(uuid);
  10512. return result;
  10513. }
  10514. static char fnamePlusPath[100]={0};
  10515. static char fnamePWithNoPath[60]={0};
  10516. void checkUploadLog(void)
  10517. {
  10518. FILE *fp;
  10519. /* Open the command for reading. */
  10520. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  10521. if (fp == NULL) {
  10522. printf("Failed to run command\n" );
  10523. exit(1);
  10524. }
  10525. int ftppathlen = 0;
  10526. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  10527. int i = 0;
  10528. /* Read the output a line at a time - output it. */
  10529. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  10530. if(i==0)
  10531. {
  10532. ftppathlen = strlen(fnamePlusPath);
  10533. printf("%s\n", fnamePlusPath);
  10534. fnamePlusPath[ftppathlen]='\0';
  10535. break;
  10536. }
  10537. i= i+1;
  10538. }
  10539. /* close */
  10540. pclose(fp);
  10541. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  10542. {
  10543. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  10544. {
  10545. fnamePlusPath[k]='\0';
  10546. }
  10547. }
  10548. i=1;
  10549. //char fname[60]={0};
  10550. while(i < ftppathlen)
  10551. {
  10552. int len=ftppathlen-i;
  10553. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  10554. {
  10555. printf("compare '/' all right\n");
  10556. break;
  10557. }
  10558. i=i+1;
  10559. }
  10560. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  10561. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  10562. fnamePWithNoPath[i+1] = '\0';
  10563. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  10564. {
  10565. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  10566. {
  10567. fnamePWithNoPath[j]='\0';
  10568. }
  10569. }
  10570. FILE* fp1 = fopen(fnamePlusPath, "r");
  10571. if (fp1)
  10572. {
  10573. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  10574. // file exists
  10575. fclose(fp1);
  10576. }
  10577. else
  10578. {
  10579. // file doesn't exist
  10580. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  10581. }
  10582. }
  10583. void* GetLogProcess(void* data)
  10584. {
  10585. pthread_detach(pthread_self());
  10586. mtrace();
  10587. int requestId, retriesInt=0, retryIntervalInt=0;
  10588. char logType[32], remoteLocation[512]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  10589. 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};
  10590. int port=0;
  10591. int isSuccess = FALSE;
  10592. char ftpbuf[200]={0};
  10593. char cmdBuf[2048];
  10594. struct tm *tmNow;
  10595. time_t CurrentTime;
  10596. struct tm tmStart;
  10597. struct tm tmStop;
  10598. CurrentTime = time(NULL);
  10599. tmNow=localtime(&CurrentTime);
  10600. uint16_t targetYear, targetMonth;
  10601. json_object *GetLog;
  10602. DEBUG_INFO("GetGetProcess...\n");
  10603. GetLog = json_tokener_parse(data);
  10604. if(!is_error(GetLog))
  10605. {
  10606. // Required data
  10607. if(json_object_object_get(GetLog, "requestId") != NULL)
  10608. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  10609. if(json_object_object_get(GetLog, "logType") != NULL)
  10610. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  10611. if(json_object_object_get(GetLog, "log") != NULL)
  10612. {
  10613. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  10614. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  10615. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  10616. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  10617. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  10618. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  10619. }
  10620. // Optional data
  10621. if(json_object_object_get(GetLog, "retries") != NULL)
  10622. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  10623. else
  10624. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  10625. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  10626. retryIntervalInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  10627. else
  10628. retryIntervalInt = 30;
  10629. }
  10630. json_object_put(GetLog);
  10631. ShmOCPP20Data->GetLog.requestId = requestId;
  10632. // Pack log to compress file
  10633. if((sscanf((char*)oldestTimestamp, "%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) &&
  10634. (sscanf((char*)latestTimestamp, "%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))
  10635. {
  10636. // Pack system log
  10637. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  10638. sprintf(cmdBuf, "exec zip -9 --password %04d%02d%s /mnt/system.zip", tmNow->tm_year+1900, tmNow->tm_mon+1, ShmSysConfigAndInfo->SysConfig.SerialNumber);
  10639. targetYear = tmStart.tm_year;
  10640. targetMonth = tmStart.tm_mon;
  10641. do
  10642. {
  10643. sprintf(cmdBuf, "%s /Storage/SystemLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  10644. sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  10645. if(targetMonth+1>=13)
  10646. {
  10647. targetYear += 1;
  10648. targetMonth = 1;
  10649. }
  10650. else
  10651. {
  10652. targetMonth += 1;
  10653. }
  10654. }while((targetYear < (tmNow->tm_year+1900)) ||
  10655. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  10656. sprintf(cmdBuf, "%s /Storage/CCS*.zip", cmdBuf);
  10657. system(cmdBuf);
  10658. // Pack charging & event log
  10659. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  10660. sprintf(cmdBuf, "exec zip -9 /mnt/charging_event.zip");
  10661. targetYear = tmStart.tm_year;
  10662. targetMonth = tmStart.tm_mon;
  10663. do
  10664. {
  10665. sprintf(cmdBuf, "%s /Storage/EventLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  10666. if(targetMonth+1>=13)
  10667. {
  10668. targetYear += 1;
  10669. targetMonth = 1;
  10670. }
  10671. else
  10672. {
  10673. targetMonth += 1;
  10674. }
  10675. }while((targetYear < (tmNow->tm_year+1900)) ||
  10676. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  10677. sprintf(cmdBuf, "%s /Storage/ChargeLog/*.db", cmdBuf);
  10678. sprintf(cmdBuf, "%s /Storage/EventLog/*.db", cmdBuf);
  10679. system(cmdBuf);
  10680. // Combine log file
  10681. system("exec zip -9 /mnt/log.zip /mnt/system.zip /mnt/charging_event.zip");
  10682. system("exec rm -f /mnt/system.zip /mnt/charging_event.zip");
  10683. }
  10684. else
  10685. {
  10686. system("exec /root/logPackTools 'log' 6");
  10687. }
  10688. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", ShmOCPP20Data->GetLog.Response_filename);
  10689. system(cmdBuf);
  10690. checkUploadLog();
  10691. //****************location*******************/
  10692. if(strcmp(remoteLocation,"")==0)
  10693. {
  10694. DEBUG_INFO("remoteLocation is <Empty>!\n");
  10695. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10696. goto end;
  10697. }
  10698. memset(protocol, 0, ARRAY_SIZE(protocol));
  10699. memset(user, 0, ARRAY_SIZE(user) );
  10700. memset(password, 0, ARRAY_SIZE(password));
  10701. memset(host, 0, ARRAY_SIZE(host));
  10702. memset(path, 0, ARRAY_SIZE(path));
  10703. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  10704. memset(host1, 0, ARRAY_SIZE(host1));
  10705. memset(path1, 0, ARRAY_SIZE(path1));
  10706. /*location: ftp://user:password@host:port/path*/
  10707. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  10708. if((access(fnamePlusPath,F_OK))!=-1)
  10709. {
  10710. DEBUG_INFO("fnamePlusPath exist.\n");
  10711. }
  10712. else
  10713. {
  10714. DEBUG_INFO("fnamePlusPath not exist!\n");
  10715. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10716. goto end;
  10717. }
  10718. if(strchr(remoteLocation,'@')==NULL)
  10719. {
  10720. sscanf(remoteLocation,
  10721. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  10722. protocol, host, &port, path);
  10723. strcpy(user,"anonymous");
  10724. strcpy(password,"");
  10725. }
  10726. else
  10727. {
  10728. //DEBUG_INFO("pch=%s\n", pch);
  10729. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  10730. protocol, user, password, host, &port, path);
  10731. }
  10732. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
  10733. {
  10734. DEBUG_INFO("protocol is not ftp/http ! \n");
  10735. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10736. goto end;
  10737. }
  10738. if(strncmp(remoteLocation,"http", 4) == 0)
  10739. {
  10740. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  10741. sprintf(ftppath,"/%s", path);
  10742. do
  10743. {
  10744. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10745. sleep(3);
  10746. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  10747. if(!isSuccess)
  10748. {
  10749. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10750. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10751. sleep(retryIntervalInt);
  10752. }
  10753. else
  10754. {
  10755. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10756. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10757. }
  10758. retriesInt--;
  10759. }while((isSuccess == 0)&&(retriesInt >= 0));
  10760. }
  10761. else
  10762. {
  10763. sscanf(host,"%[^/]%s",host1, path1);
  10764. if(strlen(path) > 0)
  10765. sprintf(ftppath,"/%s", path);
  10766. else
  10767. sprintf(ftppath,"/%s", path1);
  10768. int ftppathlen=strlen(ftppath);
  10769. int i=1;
  10770. char filenametemp[50];
  10771. while(i < ftppathlen)
  10772. {
  10773. int len=ftppathlen-i;
  10774. if(ftppath[len]== 47) // '/' ascll code: 47
  10775. {
  10776. DEBUG_INFO("find '/' all right\n");
  10777. break;
  10778. }
  10779. i=i+1;
  10780. }
  10781. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  10782. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  10783. filenametemp[i+1] = 0;
  10784. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  10785. if(port == 0)
  10786. port = 21;
  10787. do
  10788. {
  10789. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10790. sleep(3);
  10791. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  10792. if(!isSuccess)
  10793. {
  10794. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10795. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10796. sleep(retryIntervalInt);
  10797. }
  10798. else
  10799. {
  10800. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10801. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10802. }
  10803. retriesInt--;
  10804. }while((!isSuccess)&&(retriesInt >= 0));
  10805. }
  10806. end:
  10807. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  10808. pthread_exit(NULL);
  10809. }
  10810. int handleGetLogRequest(char *uuid, char *payload)
  10811. {
  10812. mtrace();
  10813. int result = FAIL;
  10814. char fName[258];
  10815. time_t CurrentTime;
  10816. struct tm *tm;
  10817. pthread_t th_Status;
  10818. CurrentTime = time(NULL);
  10819. tm = localtime(&CurrentTime);
  10820. 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);
  10821. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  10822. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  10823. sendGetLogConfirmation(uuid);
  10824. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  10825. return result;
  10826. }
  10827. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  10828. {
  10829. mtrace();
  10830. int result = FAIL;
  10831. json_object *GetMonitoringReport;
  10832. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  10833. GetMonitoringReport = json_tokener_parse(payload);
  10834. if(!is_error(GetMonitoringReport))
  10835. {
  10836. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  10837. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  10838. // Required data
  10839. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  10840. {
  10841. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  10842. }
  10843. // Optional data
  10844. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  10845. {
  10846. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  10847. }
  10848. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  10849. {
  10850. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  10851. {
  10852. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  10853. {
  10854. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  10855. {
  10856. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  10857. {
  10858. 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")));
  10859. }
  10860. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10861. {
  10862. 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")));
  10863. }
  10864. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10865. {
  10866. 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)
  10867. {
  10868. 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"));
  10869. }
  10870. 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)
  10871. {
  10872. 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"));
  10873. }
  10874. }
  10875. }
  10876. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  10877. {
  10878. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10879. {
  10880. 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")));
  10881. }
  10882. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10883. {
  10884. 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")));
  10885. }
  10886. }
  10887. }
  10888. }
  10889. }
  10890. }
  10891. json_object_put(GetMonitoringReport);
  10892. /*
  10893. * TODO:
  10894. * 1. Response result
  10895. */
  10896. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10897. sendGetMonitoringReportConfirmation(uuid);
  10898. return result;
  10899. }
  10900. int handleGetReportRequest(char *uuid, char *payload)
  10901. {
  10902. mtrace();
  10903. int result = FAIL;
  10904. json_object *GetReport;
  10905. DEBUG_INFO("handleGetReportRequest...\n");
  10906. GetReport = json_tokener_parse(payload);
  10907. if(!is_error(GetReport))
  10908. {
  10909. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  10910. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  10911. // Required data
  10912. if(json_object_object_get(GetReport, "requestId") != NULL)
  10913. {
  10914. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  10915. }
  10916. // Optional data
  10917. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  10918. {
  10919. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  10920. }
  10921. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  10922. {
  10923. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  10924. {
  10925. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  10926. {
  10927. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  10928. {
  10929. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  10930. {
  10931. 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")));
  10932. }
  10933. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10934. {
  10935. 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")));
  10936. }
  10937. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10938. {
  10939. 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)
  10940. {
  10941. 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"));
  10942. }
  10943. 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)
  10944. {
  10945. 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"));
  10946. }
  10947. }
  10948. }
  10949. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  10950. {
  10951. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10952. {
  10953. 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")));
  10954. }
  10955. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10956. {
  10957. 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")));
  10958. }
  10959. }
  10960. }
  10961. }
  10962. }
  10963. }
  10964. json_object_put(GetReport);
  10965. /*
  10966. * TODO:
  10967. * 1. Response result
  10968. */
  10969. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10970. sendGetReportConfirmation(uuid);
  10971. return result;
  10972. }
  10973. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  10974. {
  10975. mtrace();
  10976. int result = FAIL;
  10977. int8_t gun_index = -1;
  10978. json_object *GetTransactionStatus;
  10979. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  10980. GetTransactionStatus = json_tokener_parse(payload);
  10981. if(!is_error(GetTransactionStatus))
  10982. {
  10983. /*
  10984. * TODO:
  10985. * 1. Check transaction locate which connector
  10986. */
  10987. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  10988. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  10989. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  10990. {
  10991. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  10992. }
  10993. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  10994. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  10995. }
  10996. json_object_put(GetTransactionStatus);
  10997. sendGetTransactionStatusConfirmation(uuid, gun_index);
  10998. return result;
  10999. }
  11000. int handleGetVariablesRequest(char *uuid, char *payload)
  11001. {
  11002. mtrace();
  11003. int result = FAIL;
  11004. json_object *GetVariables;
  11005. DEBUG_INFO("handleGetVariablesRequest...\n");
  11006. GetVariables = json_tokener_parse(payload);
  11007. if(!is_error(GetVariables))
  11008. {
  11009. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  11010. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  11011. // Required data
  11012. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  11013. {
  11014. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  11015. {
  11016. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  11017. {
  11018. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  11019. {
  11020. 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")));
  11021. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  11022. }
  11023. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  11024. {
  11025. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  11026. {
  11027. 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")));
  11028. }
  11029. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  11030. {
  11031. 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")));
  11032. }
  11033. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  11034. {
  11035. 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)
  11036. {
  11037. 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"));
  11038. }
  11039. 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)
  11040. {
  11041. 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"));
  11042. }
  11043. }
  11044. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  11045. }
  11046. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  11047. {
  11048. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  11049. {
  11050. 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")));
  11051. }
  11052. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  11053. {
  11054. 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")));
  11055. }
  11056. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  11057. }
  11058. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  11059. {
  11060. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
  11061. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance) == 0) &&
  11062. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
  11063. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance) == 0))
  11064. {
  11065. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  11066. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  11067. break;
  11068. }
  11069. else
  11070. {
  11071. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  11072. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  11073. }
  11074. }
  11075. }
  11076. }
  11077. }
  11078. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  11079. }
  11080. json_object_put(GetVariables);
  11081. return result;
  11082. }
  11083. int handleInstallCertificateRequest(char *uuid, char *payload)
  11084. {
  11085. mtrace();
  11086. int result = FAIL;
  11087. json_object *InstallCertificate;
  11088. DEBUG_INFO("handleInstallCertificateRequest...\n");
  11089. InstallCertificate = json_tokener_parse(payload);
  11090. if(!is_error(InstallCertificate))
  11091. {
  11092. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  11093. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  11094. // Required data
  11095. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  11096. {
  11097. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  11098. }
  11099. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  11100. {
  11101. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  11102. }
  11103. }
  11104. json_object_put(InstallCertificate);
  11105. /*
  11106. * TODO:
  11107. * 1. Install certification preocess and response
  11108. */
  11109. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  11110. sendInstallCertificateConfirmation(uuid);
  11111. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11112. return result;
  11113. }
  11114. int handlePublishFirmwareRequest(char *uuid, char *payload)
  11115. {
  11116. mtrace();
  11117. int result = FAIL;
  11118. json_object *PublishFirmware;
  11119. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  11120. PublishFirmware = json_tokener_parse(payload);
  11121. if(!is_error(PublishFirmware))
  11122. {
  11123. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  11124. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  11125. // Required data
  11126. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  11127. {
  11128. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  11129. }
  11130. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  11131. {
  11132. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  11133. }
  11134. // Optional data
  11135. if(json_object_object_get(PublishFirmware, "location") != NULL)
  11136. {
  11137. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  11138. }
  11139. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  11140. {
  11141. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  11142. }
  11143. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  11144. {
  11145. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  11146. }
  11147. }
  11148. json_object_put(PublishFirmware);
  11149. /*
  11150. * TODO:
  11151. * 1. Publish firmware preocess and response
  11152. */
  11153. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  11154. sendPublishFirmwareConfirmation(uuid);
  11155. return result;
  11156. }
  11157. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  11158. {
  11159. mtrace();
  11160. int result = FAIL;
  11161. int8_t gun_index = -1;
  11162. uint8_t isPeriodOverMax = FALSE;
  11163. uint8_t isProfileOverMax = FALSE;
  11164. uint8_t isConnectorMismatch = FALSE;
  11165. uint8_t isTxProfile = FALSE;
  11166. uint8_t existProfileQuantity = 0;
  11167. uint8_t filename[128]={0};
  11168. uint8_t word[2048]={0};
  11169. FILE *filePtr;
  11170. json_object *RemoteStartTransaction;
  11171. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  11172. RemoteStartTransaction = json_tokener_parse(payload);
  11173. if(!is_error(RemoteStartTransaction))
  11174. {
  11175. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  11176. {
  11177. gun_index = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  11178. }
  11179. else
  11180. {
  11181. /*
  11182. * TODO:
  11183. * 1. Selected connector process
  11184. */
  11185. gun_index = 0;
  11186. }
  11187. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  11188. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  11189. // Required data
  11190. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  11191. {
  11192. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  11193. }
  11194. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  11195. {
  11196. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  11197. {
  11198. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  11199. }
  11200. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  11201. {
  11202. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  11203. }
  11204. }
  11205. // Optional data
  11206. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  11207. {
  11208. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  11209. {
  11210. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  11211. }
  11212. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  11213. {
  11214. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  11215. }
  11216. }
  11217. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  11218. {
  11219. // Check periods is over max configuration
  11220. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  11221. {
  11222. isPeriodOverMax = TRUE;
  11223. }
  11224. // Check periods is over max configuration
  11225. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  11226. {
  11227. if(gun_index > 0)
  11228. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  11229. else
  11230. isConnectorMismatch = TRUE;
  11231. if(!isConnectorMismatch)
  11232. {
  11233. filePtr = fopen((char*)filename, "r");
  11234. if (!filePtr)
  11235. {
  11236. DEBUG_INFO("%s not exist, create it.\n", filename);
  11237. filePtr = fopen((char*)filename, "w+");
  11238. }
  11239. else
  11240. {
  11241. //Check Charging Profile Count
  11242. while(fscanf(filePtr, "%s", word) != EOF)
  11243. {
  11244. //DEBUG_INFO("word=%s\n",word);
  11245. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11246. {
  11247. existProfileQuantity += 1;
  11248. }
  11249. }
  11250. }
  11251. fclose(filePtr);
  11252. }
  11253. }
  11254. else
  11255. {
  11256. }
  11257. if(existProfileQuantity > 3)
  11258. isProfileOverMax = TRUE;
  11259. }
  11260. // Profile replace or add info
  11261. if((gun_index > 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTxProfile)
  11262. {
  11263. FILE *infile;
  11264. FILE *outfile;
  11265. char tmpProfileName[32];
  11266. char rmFileCmd[128];
  11267. char tempchargingProfilePurposeStr[30]={0};
  11268. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  11269. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  11270. infile = fopen ((char*)filename, "r");
  11271. outfile = fopen ((char*)tmpProfileName, "w");
  11272. int d = fgetc(infile);
  11273. rewind(infile);
  11274. if(d == EOF)
  11275. {
  11276. // Profile is empty
  11277. fprintf(outfile,"%s\n", payload);
  11278. fclose(infile);
  11279. fclose(outfile);
  11280. sprintf(rmFileCmd,"rm -f %s",filename);
  11281. system(rmFileCmd);
  11282. rename((char*)tmpProfileName, (char*)filename);
  11283. }
  11284. else
  11285. {
  11286. // Profile is not empty
  11287. char buf[2048]={0};
  11288. int ChargingProfileAdded = FALSE;
  11289. while (fgets(buf, sizeof(buf), infile) != NULL)
  11290. {
  11291. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  11292. json_object *tmpChargingProfile;
  11293. tmpChargingProfile = json_tokener_parse(buf);
  11294. if(!is_error(tmpChargingProfile))
  11295. {
  11296. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  11297. {
  11298. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  11299. }
  11300. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  11301. {
  11302. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  11303. {
  11304. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  11305. }
  11306. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  11307. {
  11308. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  11309. }
  11310. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  11311. {
  11312. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  11313. }
  11314. }
  11315. }
  11316. json_object_put(tmpChargingProfile);
  11317. if((tempconnectorIdInt == gun_index) &&
  11318. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  11319. {
  11320. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  11321. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  11322. {
  11323. if(ChargingProfileAdded == FALSE)
  11324. {
  11325. fprintf(outfile,"%s\n",payload);
  11326. ChargingProfileAdded = TRUE;
  11327. }
  11328. }
  11329. else
  11330. {
  11331. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  11332. {
  11333. if(ChargingProfileAdded == FALSE)
  11334. {
  11335. fprintf(outfile,"%s\n",buf);
  11336. fprintf(outfile,"%s\n",payload);
  11337. ChargingProfileAdded = TRUE;
  11338. }
  11339. else
  11340. {
  11341. fprintf(outfile,"%s\n",buf);
  11342. }
  11343. }
  11344. else
  11345. {
  11346. if(ChargingProfileAdded == FALSE)
  11347. {
  11348. fprintf(outfile,"%s\n",buf);
  11349. fprintf(outfile,"%s\n",payload);
  11350. ChargingProfileAdded = TRUE;
  11351. }
  11352. else
  11353. {
  11354. fprintf(outfile,"%s\n",buf);
  11355. }
  11356. }
  11357. }
  11358. }
  11359. else
  11360. {
  11361. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  11362. {
  11363. if(ChargingProfileAdded == FALSE)
  11364. {
  11365. fprintf(outfile,"%s\n",buf);
  11366. fprintf(outfile,"%s\n",payload);
  11367. ChargingProfileAdded = TRUE;
  11368. }
  11369. else
  11370. {
  11371. fprintf(outfile,"%s\n",buf);
  11372. }
  11373. }
  11374. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  11375. {
  11376. if(ChargingProfileAdded == FALSE)
  11377. {
  11378. fprintf(outfile,"%s\n",buf);
  11379. fprintf(outfile,"%s\n",payload);
  11380. ChargingProfileAdded = TRUE;
  11381. }
  11382. else
  11383. {
  11384. fprintf(outfile,"%s\n",buf);
  11385. }
  11386. }
  11387. else
  11388. {
  11389. if(ChargingProfileAdded == FALSE)
  11390. {
  11391. fprintf(outfile,"%s\n",buf);
  11392. fprintf(outfile,"%s\n",payload);
  11393. ChargingProfileAdded = TRUE;
  11394. }
  11395. else
  11396. {
  11397. fprintf(outfile,"%s\n",buf);
  11398. }
  11399. }
  11400. }
  11401. } // end of while loop
  11402. fclose(infile);
  11403. fclose(outfile);
  11404. sprintf(rmFileCmd,"rm -f %s",filename);
  11405. system(rmFileCmd);
  11406. rename((char*)tmpProfileName, (char*)filename);
  11407. }
  11408. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  11409. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_transactionId);
  11410. result = PASS;
  11411. }
  11412. else
  11413. {
  11414. if(gun_index <= 0)
  11415. DEBUG_WARN("Connector id is wrong.\n");
  11416. if(isConnectorMismatch)
  11417. DEBUG_WARN("Connector id is mismatch.\n");
  11418. if(isPeriodOverMax)
  11419. DEBUG_WARN("Profile periods quantity is over spec.\n");
  11420. if(isProfileOverMax)
  11421. DEBUG_WARN("Profile quantity is over spec.\n");
  11422. if(!isTxProfile)
  11423. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  11424. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  11425. }
  11426. }
  11427. json_object_put(RemoteStartTransaction);
  11428. sendRemoteStartTransactionConfirmation(uuid, gun_index);
  11429. return result;
  11430. }
  11431. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  11432. {
  11433. mtrace();
  11434. int result = FAIL;
  11435. int match = FALSE;
  11436. int GunNO = 0;
  11437. int tempIndex = 0;
  11438. char transactionIdStr[37];
  11439. int transactionIdIsNULL= TRUE;
  11440. json_object *RemoteStopTransaction;
  11441. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  11442. if(server_pending == TRUE)
  11443. {
  11444. return 0;
  11445. }
  11446. RemoteStopTransaction = json_tokener_parse(payload);
  11447. if(!is_error(RemoteStopTransaction))
  11448. {
  11449. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  11450. {
  11451. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  11452. transactionIdIsNULL = FALSE;
  11453. }
  11454. }
  11455. json_object_put(RemoteStopTransaction);
  11456. if(transactionIdIsNULL == FALSE)
  11457. {
  11458. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  11459. {
  11460. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  11461. {
  11462. //check Transaction active
  11463. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  11464. {
  11465. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11466. {
  11467. tempIndex = ((gun_index==2) ? 1: 0);
  11468. }
  11469. else
  11470. {
  11471. tempIndex = gun_index;
  11472. }
  11473. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11474. {
  11475. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  11476. {
  11477. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11478. {
  11479. match = TRUE;
  11480. GunNO = gun_index;
  11481. }
  11482. }
  11483. }// END FOR CHAdeMO_QUANTITY
  11484. }
  11485. else if(gunType[gun_index] == GUN_TYPE_CCS)
  11486. {
  11487. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11488. {
  11489. tempIndex = ((gun_index==2) ? 1: 0);
  11490. }
  11491. else
  11492. {
  11493. tempIndex = gun_index;
  11494. }
  11495. for (int index = 0; index < CCS_QUANTITY; index++)
  11496. {
  11497. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  11498. {
  11499. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11500. {
  11501. match = TRUE;
  11502. GunNO = gun_index;
  11503. }
  11504. }
  11505. }// END FOR CCS_QUANTITY
  11506. }
  11507. else if(gunType[gun_index] == GUN_TYPE_GBT)
  11508. {
  11509. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11510. {
  11511. tempIndex = ((gun_index==2) ? 1: 0);
  11512. }
  11513. else
  11514. {
  11515. tempIndex = gun_index;
  11516. }
  11517. for (int index = 0; index < GB_QUANTITY; index++)
  11518. {
  11519. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  11520. {
  11521. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11522. {
  11523. match = TRUE;
  11524. GunNO = gun_index;
  11525. }
  11526. }
  11527. }// END FOR GB_QUANTITY
  11528. }
  11529. else if(gunType[gun_index] == GUN_TYPE_DO)
  11530. {
  11531. tempIndex = gun_index;
  11532. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11533. {
  11534. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  11535. {
  11536. 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
  11537. {
  11538. match = TRUE;
  11539. GunNO = gun_index;
  11540. }
  11541. }
  11542. }// END FOR GB_QUANTITY
  11543. }
  11544. else
  11545. {
  11546. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11547. {
  11548. tempIndex = 2;
  11549. }
  11550. else
  11551. {
  11552. tempIndex = gun_index;
  11553. }
  11554. for (int index = 0; index < AC_QUANTITY; index++)
  11555. {
  11556. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11557. {
  11558. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11559. {
  11560. match = TRUE;
  11561. GunNO = gun_index;
  11562. }
  11563. }
  11564. }// END FOR CHAdeMO_QUANTITY
  11565. } // END FOR AC ELSE
  11566. }// CHECK IF ResponseTransactionId == transactionIdInt
  11567. }//END FOR
  11568. if( match == TRUE)
  11569. {
  11570. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  11571. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  11572. }
  11573. else
  11574. {
  11575. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  11576. }
  11577. }
  11578. else
  11579. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  11580. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  11581. return result;
  11582. }
  11583. int handleReserveNowRequest(char *uuid, char *payload)
  11584. {
  11585. mtrace();
  11586. int result = FAIL;
  11587. int connectorIdInt=0, reservationIdInt=0;
  11588. int tempIndex = 0;
  11589. json_object *ReserveNow;
  11590. DEBUG_INFO("handleReserveNowRequest ...\n");
  11591. ReserveNow = json_tokener_parse(payload);
  11592. if(!is_error(ReserveNow))
  11593. {
  11594. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  11595. {
  11596. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  11597. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  11598. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  11599. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  11600. }
  11601. // Required data
  11602. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  11603. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  11604. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  11605. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  11606. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  11607. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  11608. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  11609. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  11610. // Optional data
  11611. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  11612. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  11613. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  11614. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  11615. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  11616. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  11617. result = PASS;
  11618. }
  11619. json_object_put(ReserveNow);
  11620. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11621. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  11622. {
  11623. //check Transaction active
  11624. if(gunType[connectorIdInt -1] == GUN_TYPE_CHAdeMO)
  11625. {
  11626. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11627. {
  11628. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11629. }
  11630. else
  11631. {
  11632. tempIndex = connectorIdInt -1;
  11633. }
  11634. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11635. {
  11636. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  11637. {
  11638. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11639. {
  11640. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11641. {
  11642. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11643. {
  11644. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11645. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11646. }
  11647. 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'))
  11648. {
  11649. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11650. }
  11651. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11652. {
  11653. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11654. }
  11655. else
  11656. {
  11657. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11658. }
  11659. }
  11660. 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
  11661. {
  11662. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11663. }
  11664. }
  11665. else
  11666. {
  11667. //replace reservation
  11668. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11669. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11670. }
  11671. }
  11672. } // END FOR CHAdeMO_QUANTITY
  11673. }
  11674. else if(gunType[connectorIdInt -1] == GUN_TYPE_CCS)
  11675. {
  11676. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11677. {
  11678. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11679. }
  11680. else
  11681. {
  11682. tempIndex = connectorIdInt -1;
  11683. }
  11684. for (int index = 0; index < CCS_QUANTITY; index++)
  11685. {
  11686. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  11687. {
  11688. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11689. {
  11690. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11691. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11692. {
  11693. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11694. {
  11695. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11696. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11697. }
  11698. 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'))
  11699. {
  11700. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11701. }
  11702. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  11703. {
  11704. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11705. }
  11706. else
  11707. {
  11708. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11709. }
  11710. }
  11711. 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
  11712. {
  11713. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11714. }
  11715. }
  11716. else
  11717. {
  11718. //replace reservation
  11719. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11720. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11721. }
  11722. }
  11723. } // END FOR CCS_QUANTITY
  11724. }
  11725. else if(gunType[connectorIdInt -1] == GUN_TYPE_GBT)
  11726. {
  11727. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11728. {
  11729. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11730. }
  11731. else
  11732. {
  11733. tempIndex = connectorIdInt -1;
  11734. }
  11735. for (int index = 0; index < GB_QUANTITY; index++)
  11736. {
  11737. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  11738. {
  11739. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11740. {
  11741. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11742. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11743. {
  11744. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11745. {
  11746. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11747. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11748. }
  11749. 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'))
  11750. {
  11751. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11752. }
  11753. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11754. {
  11755. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11756. }
  11757. else
  11758. {
  11759. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11760. }
  11761. }
  11762. 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
  11763. {
  11764. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11765. }
  11766. }
  11767. else
  11768. {
  11769. //replace reservation
  11770. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11771. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11772. }
  11773. }
  11774. }// END FOR GB_QUANTITY
  11775. }
  11776. else if(gunType[connectorIdInt -1] == GUN_TYPE_DO)
  11777. {
  11778. tempIndex = connectorIdInt -1;
  11779. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11780. {
  11781. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  11782. {
  11783. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId)
  11784. {
  11785. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11786. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11787. {
  11788. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11789. {
  11790. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11791. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11792. }
  11793. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '9'))
  11794. {
  11795. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11796. }
  11797. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11798. {
  11799. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11800. }
  11801. else
  11802. {
  11803. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11804. }
  11805. }
  11806. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus ==SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus ==SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_TERMINATING)) //SYS_MODE_FAULT, SYS_MODE_ALARM ,SYS_MODE_TERMINATING ---> SuspendedEV
  11807. {
  11808. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11809. }
  11810. }
  11811. else
  11812. {
  11813. //replace reservation
  11814. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11815. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11816. }
  11817. }
  11818. }// END FOR DO_QUANTITY
  11819. }
  11820. else
  11821. {
  11822. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11823. {
  11824. tempIndex = 2;
  11825. }
  11826. else
  11827. {
  11828. tempIndex = (connectorIdInt -1);
  11829. }
  11830. for (int index = 0; index < AC_QUANTITY; index++)
  11831. {
  11832. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11833. {
  11834. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11835. {
  11836. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11837. {
  11838. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11839. {
  11840. 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))
  11841. {
  11842. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11843. }
  11844. else
  11845. {
  11846. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11847. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11848. }
  11849. }
  11850. 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'))
  11851. {
  11852. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11853. }
  11854. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11855. {
  11856. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11857. }
  11858. else
  11859. {
  11860. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11861. }
  11862. }
  11863. 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
  11864. {
  11865. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11866. }
  11867. }
  11868. else
  11869. {
  11870. //replace reservation
  11871. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11872. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11873. }
  11874. }
  11875. } // END FOR AC_QUANTITY
  11876. }
  11877. }
  11878. else if(connectorIdInt == 0)
  11879. {
  11880. //check Transaction active
  11881. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11882. {
  11883. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11884. {
  11885. 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'))
  11886. {
  11887. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11888. goto end;
  11889. }
  11890. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11891. {
  11892. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11893. goto end;
  11894. }
  11895. 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
  11896. {
  11897. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11898. goto end;
  11899. }
  11900. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11901. {
  11902. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11903. goto end;
  11904. }
  11905. }
  11906. }// END FOR CHAdeMO_QUANTITY
  11907. for (int index = 0; index < CCS_QUANTITY; index++)
  11908. {
  11909. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11910. {
  11911. 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'))
  11912. {
  11913. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11914. goto end;
  11915. }
  11916. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  11917. {
  11918. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11919. goto end;
  11920. }
  11921. 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
  11922. {
  11923. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11924. goto end;
  11925. }
  11926. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11927. {
  11928. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11929. goto end;
  11930. }
  11931. }
  11932. } // END FOR CCS_QUANTITY
  11933. for (int index = 0; index < GB_QUANTITY; index++)
  11934. {
  11935. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11936. {
  11937. 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'))
  11938. {
  11939. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11940. goto end;
  11941. }
  11942. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11943. {
  11944. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11945. goto end;
  11946. }
  11947. 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
  11948. {
  11949. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11950. goto end;
  11951. }
  11952. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11953. {
  11954. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11955. goto end;
  11956. }
  11957. }
  11958. } // END FOR GB_QUANTITY
  11959. for (int index = 0; index < AC_QUANTITY; index++)
  11960. {
  11961. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11962. {
  11963. 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'))
  11964. {
  11965. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11966. goto end;
  11967. }
  11968. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11969. {
  11970. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11971. goto end;
  11972. }
  11973. 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
  11974. {
  11975. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11976. goto end;
  11977. }
  11978. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11979. {
  11980. 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))
  11981. {
  11982. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11983. goto end;
  11984. }
  11985. }
  11986. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11987. {
  11988. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11989. goto end;
  11990. }
  11991. }
  11992. }// END FOR AC_QUANTITY
  11993. //The connectorId is 0
  11994. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  11995. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11996. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  11997. result = TRUE;
  11998. return result;
  11999. }
  12000. else
  12001. {
  12002. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  12003. }
  12004. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  12005. {
  12006. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  12007. result = TRUE;
  12008. return result;
  12009. }
  12010. end:
  12011. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  12012. return result;
  12013. }
  12014. int handleResetRequest(char *uuid, char *payload)
  12015. {
  12016. mtrace();
  12017. int result = FAIL;
  12018. json_object *Reset = json_object_new_object();
  12019. DEBUG_INFO("handleResetRequest...\n");
  12020. Reset = json_tokener_parse(payload);
  12021. if(!is_error(Reset))
  12022. {
  12023. // Required data
  12024. if(json_object_object_get(Reset, "type") != NULL)
  12025. {
  12026. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  12027. }
  12028. if(json_object_object_get(Reset, "evseId") != NULL)
  12029. {
  12030. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  12031. }
  12032. }
  12033. json_object_put(Reset);
  12034. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  12035. {
  12036. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  12037. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  12038. if(!GetServerSign())
  12039. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]);
  12040. result = TRUE;
  12041. }
  12042. else
  12043. {
  12044. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  12045. }
  12046. if(strlen((char*)ShmOCPP20Data->Reset.Response_status) > 0)
  12047. sendResetConfirmation(uuid);
  12048. return result;
  12049. }
  12050. int handleSendLocalListRequest(char *uuid, char *payload)
  12051. {
  12052. mtrace();
  12053. int result = FAIL;
  12054. char updateTypestr[15]={0};
  12055. int checkState_Faulted = FALSE;
  12056. json_object *SendLocalList;
  12057. DEBUG_INFO("handleSendLocalListRequest...\n");
  12058. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  12059. {
  12060. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  12061. goto end;
  12062. }
  12063. SendLocalList = json_tokener_parse(payload);
  12064. if(!is_error(SendLocalList))
  12065. {
  12066. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  12067. // Required data
  12068. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  12069. {
  12070. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  12071. }
  12072. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  12073. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  12074. // Optional data
  12075. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  12076. {
  12077. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  12078. {
  12079. // Required data
  12080. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  12081. {
  12082. 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")));
  12083. 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")));
  12084. }
  12085. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  12086. {
  12087. 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")));
  12088. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  12089. 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")));
  12090. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  12091. 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"));
  12092. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  12093. {
  12094. 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")));
  12095. 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")));
  12096. }
  12097. }
  12098. }
  12099. }
  12100. }
  12101. json_object_put(SendLocalList);
  12102. //check Charge Point state
  12103. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12104. {
  12105. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  12106. {
  12107. checkState_Faulted = TRUE; //OCPP Status: Faulted
  12108. }
  12109. }
  12110. for (int index = 0; index < CCS_QUANTITY; index++)
  12111. {
  12112. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  12113. {
  12114. checkState_Faulted = TRUE; //OCPP Status
  12115. }
  12116. }
  12117. for (int index = 0; index < GB_QUANTITY; index++)
  12118. {
  12119. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  12120. {
  12121. checkState_Faulted = TRUE; //OCPP Status: Faulted
  12122. }
  12123. }
  12124. for (int index = 0; index < AC_QUANTITY; index++)
  12125. {
  12126. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  12127. {
  12128. checkState_Faulted = TRUE; //OCPP Status: Faulted
  12129. }
  12130. }
  12131. if(checkState_Faulted == TRUE)
  12132. {
  12133. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  12134. goto end;
  12135. }
  12136. // Check update type
  12137. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  12138. {
  12139. //Local list full update
  12140. DEBUG_INFO("Local list full update.\n");
  12141. DB_getListVerion();
  12142. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  12143. {
  12144. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  12145. goto end;
  12146. }
  12147. DB_cleanLocalList();
  12148. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  12149. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  12150. }
  12151. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  12152. {
  12153. //Local list different update
  12154. DEBUG_INFO("Local list different update.\n");
  12155. DB_getListVerion();
  12156. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  12157. {
  12158. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  12159. goto end;
  12160. }
  12161. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  12162. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  12163. }
  12164. else
  12165. {
  12166. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  12167. goto end;
  12168. }
  12169. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  12170. end:
  12171. sendSendLocalListConfirmation(uuid);
  12172. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  12173. return result;
  12174. }
  12175. int handleSetChargingProfileRequest(char *uuid, char *payload)
  12176. {
  12177. mtrace();
  12178. int result = FAIL;
  12179. int8_t gun_index = -1;
  12180. uint8_t isPeriodOverMax = FALSE;
  12181. uint8_t isProfileOverMax = FALSE;
  12182. uint8_t isConnectorMismatch = FALSE;
  12183. uint8_t existProfileQuantity = 0;
  12184. uint8_t filename[128]={0};
  12185. uint8_t word[2048]={0};
  12186. FILE *filePtr;
  12187. json_object *SetChargingProfile;
  12188. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  12189. SetChargingProfile = json_tokener_parse(payload);
  12190. if(!is_error(SetChargingProfile))
  12191. {
  12192. // Required data
  12193. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  12194. {
  12195. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  12196. }
  12197. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  12198. {
  12199. // Check periods is over max configuration
  12200. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  12201. {
  12202. isPeriodOverMax = TRUE;
  12203. }
  12204. // Check periods is over max configuration
  12205. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  12206. {
  12207. if(gun_index == 0)
  12208. {
  12209. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  12210. filePtr = fopen((char*)filename, "r");
  12211. if (!filePtr)
  12212. {
  12213. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  12214. filePtr = fopen((char*)filename, "w+");
  12215. }
  12216. else
  12217. {
  12218. //Check Charging Profile Count
  12219. while(fscanf(filePtr, "%s", word) != EOF)
  12220. {
  12221. //DEBUG_INFO("word=%s\n",word);
  12222. if(strstr((char*)word, "chargingProfileId")!= NULL)
  12223. {
  12224. existProfileQuantity += 1;
  12225. }
  12226. }
  12227. }
  12228. fclose(filePtr);
  12229. }
  12230. else
  12231. isConnectorMismatch = TRUE;
  12232. }
  12233. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  12234. {
  12235. if(gun_index < 5)
  12236. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  12237. else
  12238. isConnectorMismatch = TRUE;
  12239. if(!isConnectorMismatch)
  12240. {
  12241. filePtr = fopen((char*)filename, "r");
  12242. if (!filePtr)
  12243. {
  12244. DEBUG_INFO("%s not exist, create it.\n", filename);
  12245. filePtr = fopen((char*)filename, "w+");
  12246. }
  12247. else
  12248. {
  12249. //Check Charging Profile Count
  12250. while(fscanf(filePtr, "%s", word) != EOF)
  12251. {
  12252. //DEBUG_INFO("word=%s\n",word);
  12253. if(strstr((char*)word, "chargingProfileId")!= NULL)
  12254. {
  12255. existProfileQuantity += 1;
  12256. }
  12257. }
  12258. }
  12259. fclose(filePtr);
  12260. }
  12261. }
  12262. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  12263. {
  12264. if(gun_index>0)
  12265. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  12266. else
  12267. isConnectorMismatch = TRUE;
  12268. if(!isConnectorMismatch)
  12269. {
  12270. filePtr = fopen((char*)filename, "r");
  12271. if (!filePtr)
  12272. {
  12273. DEBUG_INFO("%s not exist, create it.\n", filename);
  12274. filePtr = fopen((char*)filename, "w+");
  12275. }
  12276. else
  12277. {
  12278. //Check Charging Profile Count
  12279. while(fscanf(filePtr, "%s", word) != EOF)
  12280. {
  12281. //DEBUG_INFO("word=%s\n",word);
  12282. if(strstr((char*)word, "chargingProfileId")!= NULL)
  12283. {
  12284. existProfileQuantity += 1;
  12285. }
  12286. }
  12287. }
  12288. fclose(filePtr);
  12289. }
  12290. }
  12291. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  12292. {
  12293. }
  12294. else
  12295. {
  12296. }
  12297. if(existProfileQuantity > 3)
  12298. isProfileOverMax = TRUE;
  12299. }
  12300. // Profile replace or add info
  12301. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  12302. {
  12303. FILE *infile;
  12304. FILE *outfile;
  12305. char tmpProfileName[32];
  12306. char rmFileCmd[128];
  12307. char tempchargingProfilePurposeStr[30]={0};
  12308. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  12309. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  12310. infile = fopen ((char*)filename, "r");
  12311. outfile = fopen ((char*)tmpProfileName, "w");
  12312. int d = fgetc(infile);
  12313. rewind(infile);
  12314. if(d == EOF)
  12315. {
  12316. // Profile is empty
  12317. fprintf(outfile,"%s\n", payload);
  12318. fclose(infile);
  12319. fclose(outfile);
  12320. sprintf(rmFileCmd,"rm -f %s",filename);
  12321. system(rmFileCmd);
  12322. rename((char*)tmpProfileName, (char*)filename);
  12323. }
  12324. else
  12325. {
  12326. // Profile is not empty
  12327. char buf[2048]={0};
  12328. int ChargingProfileAdded = FALSE;
  12329. while (fgets(buf, sizeof(buf), infile) != NULL)
  12330. {
  12331. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  12332. json_object *tmpChargingProfile;
  12333. tmpChargingProfile = json_tokener_parse(buf);
  12334. if(!is_error(tmpChargingProfile))
  12335. {
  12336. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  12337. {
  12338. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  12339. }
  12340. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  12341. {
  12342. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  12343. {
  12344. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  12345. }
  12346. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  12347. {
  12348. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  12349. }
  12350. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  12351. {
  12352. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  12353. }
  12354. }
  12355. }
  12356. json_object_put(tmpChargingProfile);
  12357. if((tempconnectorIdInt == gun_index) &&
  12358. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  12359. {
  12360. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  12361. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  12362. {
  12363. //DEBUG_INFO("update set chargingProfile to file -0\n");
  12364. if(ChargingProfileAdded == FALSE)
  12365. {
  12366. fprintf(outfile,"%s\n",payload);
  12367. ChargingProfileAdded = TRUE;
  12368. }
  12369. }
  12370. else
  12371. {
  12372. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  12373. {
  12374. if(ChargingProfileAdded == FALSE)
  12375. {
  12376. fprintf(outfile,"%s\n",buf);
  12377. fprintf(outfile,"%s\n",payload);
  12378. ChargingProfileAdded = TRUE;
  12379. }
  12380. else
  12381. {
  12382. fprintf(outfile,"%s\n",buf);
  12383. }
  12384. }
  12385. else
  12386. {
  12387. if(ChargingProfileAdded == FALSE)
  12388. {
  12389. fprintf(outfile,"%s\n",buf);
  12390. fprintf(outfile,"%s\n",payload);
  12391. ChargingProfileAdded = TRUE;
  12392. }
  12393. else
  12394. {
  12395. fprintf(outfile,"%s\n",buf);
  12396. }
  12397. }
  12398. }
  12399. }
  12400. else
  12401. {
  12402. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
  12403. {
  12404. if(ChargingProfileAdded == FALSE)
  12405. {
  12406. fprintf(outfile,"%s\n",buf);
  12407. fprintf(outfile,"%s\n",payload);
  12408. ChargingProfileAdded = TRUE;
  12409. }
  12410. else
  12411. {
  12412. fprintf(outfile,"%s\n",buf);
  12413. }
  12414. }
  12415. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  12416. {
  12417. if(ChargingProfileAdded == FALSE)
  12418. {
  12419. fprintf(outfile,"%s\n",buf);
  12420. fprintf(outfile,"%s\n",payload);
  12421. ChargingProfileAdded = TRUE;
  12422. }
  12423. else
  12424. {
  12425. fprintf(outfile,"%s\n",buf);
  12426. }
  12427. }
  12428. else
  12429. {
  12430. if(ChargingProfileAdded == FALSE)
  12431. {
  12432. fprintf(outfile,"%s\n",buf);
  12433. fprintf(outfile,"%s\n",payload);
  12434. ChargingProfileAdded = TRUE;
  12435. }
  12436. else
  12437. {
  12438. fprintf(outfile,"%s\n",buf);
  12439. }
  12440. }
  12441. }
  12442. } // end of while loop
  12443. fclose(infile);
  12444. fclose(outfile);
  12445. sprintf(rmFileCmd,"rm -f %s",filename);
  12446. system(rmFileCmd);
  12447. rename((char*)tmpProfileName, (char*)filename);
  12448. }
  12449. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  12450. result = PASS;
  12451. }
  12452. else
  12453. {
  12454. if(gun_index == -1)
  12455. DEBUG_WARN("Connector id is wrong.\n");
  12456. if(isConnectorMismatch)
  12457. DEBUG_WARN("Connector id is mismatch.\n");
  12458. if(isPeriodOverMax)
  12459. DEBUG_WARN("Profile periods quantity is over spec.\n");
  12460. if(isProfileOverMax)
  12461. DEBUG_WARN("Profile quantity is over spec.\n");
  12462. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  12463. }
  12464. }
  12465. json_object_put(SetChargingProfile);
  12466. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  12467. {
  12468. if(gun_index == 0)
  12469. {
  12470. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  12471. {
  12472. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  12473. }
  12474. }
  12475. else
  12476. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1], 0, TRUE);
  12477. }
  12478. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  12479. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  12480. return result;
  12481. }
  12482. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  12483. {
  12484. mtrace();
  12485. int result = FAIL;
  12486. json_object *SetDisplayMessage;
  12487. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  12488. SetDisplayMessage = json_tokener_parse(payload);
  12489. if(!is_error(SetDisplayMessage))
  12490. {
  12491. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  12492. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  12493. // Required data
  12494. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  12495. {
  12496. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  12497. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  12498. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  12499. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  12500. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  12501. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  12502. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  12503. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  12504. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  12505. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  12506. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  12507. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  12508. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  12509. {
  12510. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  12511. 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")));
  12512. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  12513. 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")));
  12514. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  12515. 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")));
  12516. }
  12517. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  12518. {
  12519. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  12520. 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")));
  12521. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  12522. 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")));
  12523. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  12524. {
  12525. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  12526. 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"));
  12527. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  12528. 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"));
  12529. }
  12530. }
  12531. }
  12532. }
  12533. json_object_put(SetDisplayMessage);
  12534. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  12535. sendSetMonitoringBaseConfirmation(uuid);
  12536. // Anouce CSU there is display request come from server
  12537. ShmOCPP20Data->MsMsg.bits.SetDisplayMessageReq = ON;
  12538. return result;
  12539. }
  12540. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  12541. {
  12542. mtrace();
  12543. int result = FAIL;
  12544. json_object *SetMonitoringBase;
  12545. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  12546. SetMonitoringBase = json_tokener_parse(payload);
  12547. if(!is_error(SetMonitoringBase))
  12548. {
  12549. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  12550. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  12551. // Required data
  12552. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  12553. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  12554. }
  12555. json_object_put(SetMonitoringBase);
  12556. /*
  12557. * TODO:
  12558. * 1. Configure monitor base and response
  12559. */
  12560. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12561. sendSetMonitoringBaseConfirmation(uuid);
  12562. return result;
  12563. }
  12564. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  12565. {
  12566. mtrace();
  12567. int result = FAIL;
  12568. json_object *SetMonitoringLevel;
  12569. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  12570. SetMonitoringLevel = json_tokener_parse(payload);
  12571. if(!is_error(SetMonitoringLevel))
  12572. {
  12573. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  12574. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  12575. // Required data
  12576. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  12577. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  12578. }
  12579. json_object_put(SetMonitoringLevel);
  12580. /*
  12581. * TODO:
  12582. * Configure monitor status and response
  12583. */
  12584. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12585. sendSetMonitoringLevelConfirmation(uuid);
  12586. return result;
  12587. }
  12588. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  12589. {
  12590. mtrace();
  12591. int result = FAIL;
  12592. json_object *SetNetworkProfile;
  12593. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  12594. SetNetworkProfile = json_tokener_parse(payload);
  12595. if(!is_error(SetNetworkProfile))
  12596. {
  12597. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  12598. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  12599. // Required data
  12600. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  12601. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  12602. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  12603. {
  12604. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  12605. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  12606. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  12607. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  12608. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  12609. {
  12610. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  12611. memcpy((char*)ShmOCPP20Data->OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  12612. }
  12613. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  12614. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  12615. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  12616. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  12617. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  12618. {
  12619. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  12620. 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")));
  12621. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  12622. 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")));
  12623. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  12624. 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")));
  12625. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  12626. 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")));
  12627. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  12628. 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")));
  12629. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  12630. 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")));
  12631. }
  12632. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  12633. {
  12634. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  12635. {
  12636. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  12637. 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")));
  12638. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  12639. }
  12640. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  12641. {
  12642. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  12643. 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")));
  12644. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  12645. }
  12646. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  12647. {
  12648. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  12649. 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")));
  12650. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  12651. }
  12652. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  12653. 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"));
  12654. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  12655. 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")));
  12656. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  12657. 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"));
  12658. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  12659. 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")));
  12660. }
  12661. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  12662. }
  12663. }
  12664. json_object_put(SetNetworkProfile);
  12665. /*
  12666. * TODO:
  12667. * 1. Process network configuration and response
  12668. */
  12669. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  12670. {
  12671. }
  12672. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  12673. {
  12674. }
  12675. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  12676. {
  12677. }
  12678. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  12679. {
  12680. }
  12681. else
  12682. {
  12683. }
  12684. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  12685. {
  12686. }
  12687. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  12688. {
  12689. }
  12690. else
  12691. {
  12692. }
  12693. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  12694. {
  12695. }
  12696. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  12697. {
  12698. }
  12699. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  12700. {
  12701. }
  12702. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  12703. {
  12704. }
  12705. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  12706. {
  12707. }
  12708. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  12709. {
  12710. }
  12711. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  12712. {
  12713. }
  12714. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  12715. {
  12716. }
  12717. else
  12718. {
  12719. }
  12720. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  12721. {
  12722. }
  12723. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  12724. {
  12725. }
  12726. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  12727. {
  12728. }
  12729. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  12730. {
  12731. }
  12732. else
  12733. {
  12734. }
  12735. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  12736. {
  12737. }
  12738. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  12739. {
  12740. }
  12741. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  12742. {
  12743. }
  12744. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  12745. {
  12746. }
  12747. else
  12748. {
  12749. }
  12750. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  12751. sendSetNetworkProfileConfirmation(uuid);
  12752. return result;
  12753. }
  12754. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  12755. {
  12756. mtrace();
  12757. int result = FAIL;
  12758. json_object *SetVariableMonitoring;
  12759. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  12760. SetVariableMonitoring = json_tokener_parse(payload);
  12761. if(!is_error(SetVariableMonitoring))
  12762. {
  12763. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  12764. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  12765. // Required data
  12766. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  12767. {
  12768. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  12769. {
  12770. 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"));
  12771. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  12772. }
  12773. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  12774. {
  12775. 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"));
  12776. /*
  12777. * TODO:
  12778. * 1. Check monitor value status
  12779. */
  12780. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, MonitorEnumTypeStr[MonitorEnumType_Delta]);
  12781. }
  12782. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  12783. {
  12784. 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")));
  12785. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  12786. }
  12787. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  12788. {
  12789. 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"));
  12790. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  12791. }
  12792. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  12793. {
  12794. 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"));
  12795. }
  12796. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  12797. {
  12798. 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)
  12799. {
  12800. 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")));
  12801. }
  12802. 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)
  12803. {
  12804. 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")));
  12805. }
  12806. 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)
  12807. {
  12808. 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)
  12809. {
  12810. 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"));
  12811. }
  12812. 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)
  12813. {
  12814. 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"));
  12815. }
  12816. }
  12817. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  12818. }
  12819. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  12820. {
  12821. 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)
  12822. {
  12823. 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")));
  12824. }
  12825. 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)
  12826. {
  12827. 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")));
  12828. }
  12829. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  12830. }
  12831. }
  12832. }
  12833. json_object_put(SetVariableMonitoring);
  12834. return result;
  12835. }
  12836. int handleSetVariablesRequest(char *uuid, char *payload)
  12837. {
  12838. mtrace();
  12839. int result = FAIL;
  12840. json_object *SetVariables;
  12841. DEBUG_INFO("handleSetVariablesRequest...\n");
  12842. SetVariables = json_tokener_parse(payload);
  12843. if(!is_error(SetVariables))
  12844. {
  12845. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  12846. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  12847. // Required data
  12848. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  12849. {
  12850. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  12851. {
  12852. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  12853. {
  12854. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  12855. {
  12856. 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")));
  12857. }
  12858. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  12859. {
  12860. 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")));
  12861. }
  12862. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  12863. {
  12864. 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)
  12865. {
  12866. 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"));
  12867. }
  12868. 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)
  12869. {
  12870. 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"));
  12871. }
  12872. }
  12873. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  12874. }
  12875. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  12876. {
  12877. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  12878. {
  12879. 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")));
  12880. }
  12881. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  12882. {
  12883. 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")));
  12884. }
  12885. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  12886. }
  12887. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  12888. {
  12889. 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")));
  12890. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  12891. }
  12892. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  12893. {
  12894. 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")));
  12895. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  12896. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  12897. {
  12898. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  12899. (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) &&
  12900. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  12901. (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))
  12902. {
  12903. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  12904. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  12905. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  12906. {
  12907. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  12908. }
  12909. else
  12910. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  12911. }
  12912. }
  12913. }
  12914. }
  12915. }
  12916. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  12917. }
  12918. json_object_put(SetVariables);
  12919. return result;
  12920. }
  12921. int handleTriggerMessageRequest(char *uuid, char *payload)
  12922. {
  12923. mtrace();
  12924. int result = FAIL;
  12925. int connectorIdIsNULL = FALSE;
  12926. int connectorIdInt =0;
  12927. char requestedMessagestr[40]={0};
  12928. json_object *TriggerMessage;
  12929. DEBUG_INFO("handleTriggerMessageRequest\n");
  12930. TriggerMessage = json_tokener_parse(payload);
  12931. if(!is_error(TriggerMessage))
  12932. {
  12933. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  12934. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  12935. // Required data
  12936. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  12937. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  12938. // Optional data
  12939. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  12940. {
  12941. // Required data
  12942. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  12943. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  12944. // Optional data
  12945. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  12946. {
  12947. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  12948. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  12949. }
  12950. else
  12951. connectorIdIsNULL = TRUE;
  12952. }
  12953. }
  12954. json_object_put(TriggerMessage);
  12955. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  12956. {
  12957. if((strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  12958. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  12959. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  12960. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  12961. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  12962. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  12963. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  12964. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  12965. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  12966. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  12967. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  12968. {
  12969. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  12970. sendTriggerMessageConfirmation(uuid);
  12971. return TRUE;
  12972. }
  12973. else
  12974. {
  12975. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  12976. sendTriggerMessageConfirmation(uuid);
  12977. }
  12978. }
  12979. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  12980. {
  12981. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  12982. sendTriggerMessageConfirmation(uuid);
  12983. return TRUE;
  12984. }
  12985. //==========================
  12986. // Trigger message
  12987. //==========================
  12988. if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  12989. {
  12990. if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
  12991. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
  12992. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
  12993. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
  12994. {
  12995. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  12996. }
  12997. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
  12998. }
  12999. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  13000. {
  13001. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
  13002. }
  13003. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  13004. {
  13005. if(DB_updateBootType(BootReasonEnumType_Triggered))
  13006. server_sign = FALSE;
  13007. }
  13008. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  13009. {
  13010. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  13011. }
  13012. else if (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  13013. {
  13014. if(connectorIdIsNULL == FALSE)
  13015. {
  13016. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  13017. {
  13018. //sendMeterValuesRequest((connectorIdInt -1), ReadingContext_Trigger);
  13019. cpinitateMsg.bits[connectorIdInt -1].TriggerMeterValueReq = ON;
  13020. }
  13021. }
  13022. else
  13023. {
  13024. for(int idx=0;idx< gunTotalNumber;idx++)
  13025. {
  13026. //sendMeterValuesRequest(idx, ReadingContext_Trigger);
  13027. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  13028. }
  13029. }
  13030. }
  13031. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  13032. {
  13033. if(connectorIdIsNULL == FALSE)
  13034. {
  13035. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  13036. {
  13037. cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = ON;
  13038. }
  13039. }
  13040. else
  13041. {
  13042. for(int idx=0;idx< gunTotalNumber;idx++)
  13043. cpinitateMsg.bits[idx].StatusNotificationReq = ON;
  13044. }
  13045. }
  13046. return result;
  13047. }
  13048. int handleUnlockConnectorRequest(char *uuid, char *payload)
  13049. {
  13050. mtrace();
  13051. int result = FAIL;
  13052. int connectorIdInt =0;
  13053. int tempIndex = 0;
  13054. json_object *UnlockConnector;
  13055. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  13056. UnlockConnector = json_tokener_parse(payload);
  13057. if(!is_error(UnlockConnector))
  13058. {
  13059. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  13060. {
  13061. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  13062. }
  13063. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  13064. {
  13065. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  13066. }
  13067. }
  13068. json_object_put(UnlockConnector);
  13069. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  13070. if(gunTotalNumber == 0)
  13071. {
  13072. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  13073. goto end;
  13074. }
  13075. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  13076. {
  13077. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  13078. goto end;
  13079. }
  13080. else
  13081. {
  13082. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  13083. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  13084. //check Transaction active
  13085. if(gunType[connectorIdInt-1] == GUN_TYPE_CHAdeMO)
  13086. {
  13087. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13088. {
  13089. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  13090. }
  13091. else
  13092. {
  13093. tempIndex = connectorIdInt -1;
  13094. }
  13095. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13096. {
  13097. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  13098. {
  13099. //stop Transaction
  13100. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  13101. }
  13102. }
  13103. }
  13104. else if(gunType[connectorIdInt-1] == GUN_TYPE_CCS)
  13105. {
  13106. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13107. {
  13108. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  13109. }
  13110. else
  13111. {
  13112. tempIndex = connectorIdInt -1;
  13113. }
  13114. for (int index = 0; index < CCS_QUANTITY; index++)
  13115. {
  13116. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  13117. {
  13118. //stop Transaction
  13119. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  13120. }
  13121. }
  13122. }
  13123. else if(gunType[connectorIdInt-1] == GUN_TYPE_GBT)
  13124. {
  13125. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13126. {
  13127. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  13128. }
  13129. else
  13130. {
  13131. tempIndex = connectorIdInt -1;
  13132. }
  13133. for (int index = 0; index < GB_QUANTITY; index++)
  13134. {
  13135. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  13136. {
  13137. //stop Transaction
  13138. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  13139. }
  13140. }
  13141. }
  13142. else if(gunType[connectorIdInt-1] == GUN_TYPE_DO)
  13143. {
  13144. tempIndex = connectorIdInt -1;
  13145. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13146. {
  13147. if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)))
  13148. {
  13149. //stop Transaction
  13150. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  13151. }
  13152. }
  13153. }
  13154. else
  13155. {
  13156. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  13157. {
  13158. tempIndex = 2;
  13159. }
  13160. else
  13161. {
  13162. tempIndex = connectorIdInt-1;
  13163. }
  13164. for (int index = 0; index < AC_QUANTITY; index++)
  13165. {
  13166. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  13167. {
  13168. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  13169. }
  13170. }
  13171. }
  13172. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  13173. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  13174. result = TRUE;
  13175. return result;
  13176. }
  13177. end:
  13178. //json_object_put(obj); --- remove temporally
  13179. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  13180. return result;
  13181. }
  13182. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  13183. {
  13184. mtrace();
  13185. int result = FAIL;
  13186. json_object *UnpublishFirmware;
  13187. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  13188. UnpublishFirmware = json_tokener_parse(payload);
  13189. if(!is_error(UnpublishFirmware))
  13190. {
  13191. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  13192. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  13193. // Required data
  13194. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  13195. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  13196. }
  13197. json_object_put(UnpublishFirmware);
  13198. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  13199. /*
  13200. * TODO:
  13201. * 1. Check unpublished status
  13202. */
  13203. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  13204. sendUnpublishFirmwareConfirmation(uuid);
  13205. return result;
  13206. }
  13207. static char UpdateFirmwarepayloadData[512]={0};
  13208. void *UpdateFirmwareProcess(void *data)
  13209. {
  13210. pthread_detach(pthread_self());
  13211. mtrace();
  13212. int retriesInt =0, retryIntervalInt=0;
  13213. char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
  13214. int port=0;
  13215. char locationstr[160]={0}, retrieveDatestr[30]={0};
  13216. int isSuccess = 0;
  13217. char ftpbuf[200];
  13218. char temp[100];
  13219. char * pch;
  13220. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  13221. json_object *UpdateFirmware;
  13222. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  13223. if(!is_error(UpdateFirmware))
  13224. {
  13225. // Required data
  13226. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  13227. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  13228. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  13229. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  13230. // Optional data
  13231. if(json_object_object_get(UpdateFirmware, "retries"))
  13232. {
  13233. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  13234. }
  13235. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  13236. {
  13237. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  13238. }
  13239. }
  13240. json_object_put(UpdateFirmware);
  13241. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  13242. memset(path, 0, ARRAY_SIZE(path));
  13243. system("rm -f /mnt/*");
  13244. if(strncmp(locationstr,"http", 4) == 0)
  13245. {
  13246. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  13247. //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
  13248. // protocol, user, password, host, path);
  13249. sprintf(ftppath,"/%s", path);
  13250. DEBUG_INFO("locationstr: %s\n", locationstr);
  13251. DEBUG_INFO("protocol: %s\n",protocol);
  13252. DEBUG_INFO("host: %s\n",host);
  13253. DEBUG_INFO("path: %s\n",path);
  13254. DEBUG_INFO("ftppath: %s\n",ftppath);
  13255. int ftppathlen=strlen(ftppath);
  13256. int i=1;
  13257. char filenametemp[50];
  13258. while(i < ftppathlen)
  13259. {
  13260. int len=ftppathlen-i;
  13261. if(ftppath[len]== 47) // '/' ascll code: 47
  13262. {
  13263. DEBUG_INFO("compare '/' all right\n");
  13264. break;
  13265. }
  13266. i=i+1;
  13267. }
  13268. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  13269. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  13270. filenametemp[i+1] = 0;
  13271. do
  13272. {
  13273. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  13274. sleep(3);
  13275. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  13276. if(!isSuccess)
  13277. {
  13278. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  13279. sleep(retryIntervalInt);
  13280. }
  13281. else
  13282. {
  13283. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  13284. }
  13285. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
  13286. }
  13287. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  13288. {
  13289. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13290. memset(temp, 0, ARRAY_SIZE(temp));
  13291. //DEBUG_INFO("locationstr=%s\n",locationstr);
  13292. strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
  13293. int ftppathlen=strlen(ftpbuf);
  13294. int i=1;
  13295. char filenametemp[50];
  13296. while(i < ftppathlen)
  13297. {
  13298. int len=ftppathlen-i;
  13299. if(ftpbuf[len]== 47) // '/' ascll code: 47
  13300. {
  13301. DEBUG_INFO(" compare '/' all right\n");
  13302. break;
  13303. }
  13304. i=i+1;
  13305. }
  13306. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  13307. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  13308. filenametemp[i+1] = 0;
  13309. strncpy(temp, ftpbuf, ftppathlen-i+1);
  13310. pch=strchr(temp,'@');
  13311. if(pch==NULL)
  13312. {
  13313. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  13314. protocol, host, &port, path);
  13315. strcpy(user,"anonymous");
  13316. strcpy(password,"");
  13317. }
  13318. else
  13319. {
  13320. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  13321. protocol, user, password, host, &port, path);
  13322. }
  13323. sscanf(host,"%[^/]%s",host1, path1);
  13324. sprintf(ftppath,"%s", path1);
  13325. //DEBUG_INFO("protocol =%s\n",protocol);
  13326. //DEBUG_INFO("user =%s\n",user);
  13327. //DEBUG_INFO("password =%s\n",password);
  13328. //DEBUG_INFO("host1 =%s\n",host1);
  13329. //DEBUG_INFO("port =%d\n",port);
  13330. //DEBUG_INFO("path1 =%s\n",path1);
  13331. //DEBUG_INFO("ftppath=%s\n",ftppath);
  13332. //ftpFile(host, user, password, port, ftppath, fname);
  13333. //download firmware pthred
  13334. if(port == 0)
  13335. {
  13336. port = 21;
  13337. }
  13338. do
  13339. {
  13340. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  13341. sleep(3);
  13342. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  13343. if(!isSuccess)
  13344. {
  13345. //BulldogUtil.sleepMs(interval*1000);
  13346. DEBUG_INFO("Update firmware request and download file fail.\n");
  13347. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  13348. sleep(retryIntervalInt);
  13349. }
  13350. else
  13351. {
  13352. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  13353. }
  13354. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  13355. }
  13356. else
  13357. {
  13358. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  13359. }
  13360. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  13361. pthread_exit(NULL);
  13362. }
  13363. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  13364. {
  13365. mtrace();
  13366. int result = FAIL;
  13367. pthread_t t;
  13368. sendUpdateFirmwareConfirmation(uuid);
  13369. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  13370. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  13371. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  13372. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  13373. ////pthread_join(t, NULL); //
  13374. //pthread_detach(t);
  13375. //sendUpdateFirmwareConfirmation(uuid);
  13376. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  13377. return result;
  13378. }
  13379. int handleUnknownRequest(char *uuid, char *payload)
  13380. {
  13381. mtrace();
  13382. int result = FAIL;
  13383. DEBUG_INFO("handleUnknownRequest...\n");
  13384. sendUnknownConfirmation(uuid);
  13385. result = PASS;
  13386. return result;
  13387. }
  13388. //==========================================
  13389. // Handle server response routine
  13390. //==========================================
  13391. void handleAuthorizeResponse(char *payload, int gun_index)
  13392. {
  13393. mtrace();
  13394. DEBUG_INFO("handleAuthorizeResponse...\n");
  13395. json_object *Authorize;
  13396. Authorize = json_tokener_parse(payload);
  13397. if(!is_error(Authorize))
  13398. {
  13399. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  13400. {
  13401. // Required data
  13402. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  13403. // Optional data
  13404. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  13405. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  13406. else
  13407. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  13408. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  13409. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  13410. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  13411. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  13412. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  13413. {
  13414. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  13415. {
  13416. 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));
  13417. }
  13418. }
  13419. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  13420. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  13421. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  13422. {
  13423. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  13424. 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")));
  13425. else
  13426. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  13427. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  13428. 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")));
  13429. }
  13430. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  13431. {
  13432. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  13433. 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")));
  13434. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  13435. 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")));
  13436. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  13437. 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")));
  13438. }
  13439. }
  13440. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  13441. {
  13442. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  13443. }
  13444. }
  13445. json_object_put(Authorize);
  13446. //Update idTag information to authorization cache if supported
  13447. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  13448. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  13449. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  13450. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  13451. {
  13452. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  13453. }
  13454. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  13455. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  13456. authorizeRetryTimes = 0;
  13457. }
  13458. void handleBootNotificationResponse(char *payload, int gun_index)
  13459. {
  13460. mtrace();
  13461. char statusStr[12]={0};
  13462. char currentTimeStr[30]={0};
  13463. int intervalInt = 0;
  13464. DEBUG_INFO("handleBootNotificationResponse...\n");
  13465. json_object *BootNotification;
  13466. BootNotification = json_tokener_parse(payload);
  13467. if(!is_error(BootNotification))
  13468. {
  13469. // Required data
  13470. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  13471. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  13472. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  13473. }
  13474. json_object_put(BootNotification);
  13475. DEBUG_INFO("statusStr: %s\n", statusStr);
  13476. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  13477. BootNotificationInterval = intervalInt;
  13478. HeartBeatWaitTime = intervalInt;
  13479. //write back to ShmOCPP20Data->BootNotification
  13480. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  13481. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  13482. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  13483. {
  13484. server_sign = TRUE;
  13485. server_pending =FALSE;
  13486. DB_updateBootType(BootReasonEnumType_PowerUp);
  13487. }
  13488. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  13489. {
  13490. server_pending = TRUE;
  13491. }
  13492. syncDateTimeRTC(ShmOCPP20Data->BootNotification.Response_currentTime);
  13493. srand(time(NULL));
  13494. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  13495. SetOcppConnStatus(TRUE);
  13496. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  13497. }
  13498. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  13499. {
  13500. mtrace();
  13501. json_object *ClearedChargingLimit;
  13502. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  13503. ClearedChargingLimit = json_tokener_parse(payload);
  13504. if(!is_error(ClearedChargingLimit))
  13505. {
  13506. // Required data
  13507. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  13508. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  13509. }
  13510. json_object_put(ClearedChargingLimit);
  13511. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  13512. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitConf = ON;
  13513. }
  13514. void handleDataTransferResponse(char *payload, int gun_index)
  13515. {
  13516. mtrace();
  13517. json_object *DataTrans;
  13518. DEBUG_INFO("handleDataTransferResponse...\n");
  13519. DataTrans = json_tokener_parse(payload);
  13520. if(!is_error(DataTrans))
  13521. {
  13522. // Required data
  13523. if(json_object_object_get(DataTrans,"status") != NULL)
  13524. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  13525. // Optional data
  13526. if(json_object_object_get(DataTrans,"data") != NULL)
  13527. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  13528. }
  13529. json_object_put(DataTrans);
  13530. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  13531. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  13532. }
  13533. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  13534. {
  13535. mtrace();
  13536. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  13537. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  13538. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  13539. }
  13540. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  13541. {
  13542. mtrace();
  13543. json_object *Get15118EVCertificate;
  13544. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  13545. Get15118EVCertificate = json_tokener_parse(payload);
  13546. if(!is_error(Get15118EVCertificate))
  13547. {
  13548. // Required data
  13549. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  13550. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  13551. // Optional data
  13552. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  13553. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  13554. }
  13555. json_object_put(Get15118EVCertificate);
  13556. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  13557. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  13558. }
  13559. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  13560. {
  13561. mtrace();
  13562. json_object *GetCertificateStatus;
  13563. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  13564. GetCertificateStatus = json_tokener_parse(payload);
  13565. if(!is_error(GetCertificateStatus))
  13566. {
  13567. // Required data
  13568. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  13569. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  13570. // Optional data
  13571. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  13572. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  13573. }
  13574. json_object_put(GetCertificateStatus);
  13575. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  13576. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  13577. }
  13578. void handleHeartbeatResponse(char *payload, int gun_index)
  13579. {
  13580. mtrace();
  13581. DEBUG_INFO("handleHeartbeatResponse...\n");
  13582. json_object *Heartbeat;
  13583. Heartbeat = json_tokener_parse(payload);
  13584. if(!is_error(Heartbeat))
  13585. {
  13586. // Required data
  13587. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  13588. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  13589. }
  13590. json_object_put(Heartbeat);
  13591. if(FirstHeartBeat == OFF)
  13592. {
  13593. FirstHeartBeat = ON;
  13594. DEBUG_INFO("FirstHeartBeat \n");
  13595. }
  13596. HeartBeatWithNOResponse = 0;
  13597. clientTime.Heartbeat=time((time_t*)NULL);
  13598. syncDateTimeRTC(ShmOCPP20Data->Heartbeat.Response_currentTime);
  13599. }
  13600. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  13601. {
  13602. mtrace();
  13603. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  13604. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  13605. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  13606. }
  13607. void handleMeterValuesResponse(char *payload, int gun_index)
  13608. {
  13609. mtrace();
  13610. DEBUG_INFO("handleMeterValuesResponse...\n");
  13611. }
  13612. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  13613. {
  13614. mtrace();
  13615. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  13616. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  13617. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  13618. }
  13619. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  13620. {
  13621. mtrace();
  13622. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  13623. }
  13624. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  13625. {
  13626. mtrace();
  13627. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  13628. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  13629. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  13630. }
  13631. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  13632. {
  13633. mtrace();
  13634. json_object *NotifyEVChargingNeeds;
  13635. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  13636. NotifyEVChargingNeeds = json_tokener_parse(payload);
  13637. if(!is_error(NotifyEVChargingNeeds))
  13638. {
  13639. // Required data
  13640. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  13641. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  13642. }
  13643. json_object_put(NotifyEVChargingNeeds);
  13644. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  13645. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  13646. }
  13647. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  13648. {
  13649. mtrace();
  13650. json_object *NotifyEVChargingSchedule;
  13651. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  13652. NotifyEVChargingSchedule = json_tokener_parse(payload);
  13653. if(!is_error(NotifyEVChargingSchedule))
  13654. {
  13655. // Required data
  13656. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  13657. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  13658. }
  13659. json_object_put(NotifyEVChargingSchedule);
  13660. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  13661. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  13662. }
  13663. void hanldeNotifyEventResponse(char *payload, int gun_index)
  13664. {
  13665. mtrace();
  13666. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  13667. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  13668. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  13669. }
  13670. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  13671. {
  13672. mtrace();
  13673. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  13674. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  13675. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  13676. }
  13677. void hanldeNotifyReportResponse(char *payload, int gun_index)
  13678. {
  13679. mtrace();
  13680. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  13681. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  13682. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  13683. }
  13684. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  13685. {
  13686. mtrace();
  13687. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  13688. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  13689. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  13690. }
  13691. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  13692. {
  13693. mtrace();
  13694. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  13695. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  13696. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  13697. }
  13698. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  13699. {
  13700. mtrace();
  13701. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  13702. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  13703. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  13704. }
  13705. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  13706. {
  13707. mtrace();
  13708. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  13709. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  13710. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  13711. }
  13712. void hanldeSignCertificateResponse(char *payload, int gun_index)
  13713. {
  13714. mtrace();
  13715. json_object *SignCertificate;
  13716. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  13717. SignCertificate = json_tokener_parse(payload);
  13718. if(!is_error(SignCertificate))
  13719. {
  13720. // Required data
  13721. if(json_object_object_get(SignCertificate,"status") != NULL)
  13722. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  13723. }
  13724. json_object_put(SignCertificate);
  13725. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  13726. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  13727. }
  13728. void handleStatusNotificationResponse(char *payload, int gun_index)
  13729. {
  13730. mtrace();
  13731. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  13732. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13733. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  13734. }
  13735. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  13736. {
  13737. mtrace();
  13738. json_object *TransactionEven;
  13739. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  13740. TransactionEven = json_tokener_parse(payload);
  13741. if(!is_error(TransactionEven))
  13742. {
  13743. // Required data
  13744. // Optional data
  13745. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  13746. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  13747. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  13748. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  13749. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  13750. {
  13751. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  13752. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  13753. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  13754. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  13755. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  13756. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  13757. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  13758. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  13759. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  13760. {
  13761. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  13762. 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")));
  13763. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  13764. 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")));
  13765. }
  13766. }
  13767. }
  13768. json_object_put(TransactionEven);
  13769. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  13770. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  13771. }
  13772. //==========================================
  13773. // Handle Error routine
  13774. //==========================================
  13775. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  13776. {
  13777. mtrace();
  13778. #ifdef SystemLogMessage
  13779. DEBUG_INFO("errorCode: %s\n", errorCode);
  13780. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  13781. DEBUG_INFO("errorDetails: %s\n", payload);
  13782. #endif
  13783. }
  13784. //===============================================
  13785. // Common routine
  13786. //===============================================
  13787. int initialConfigurationTable(void)
  13788. {
  13789. DEBUG_INFO("initialConfigurationTable...\n");
  13790. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  13791. DB_variableIsCreate();
  13792. DB_variableLoadFromDb();
  13793. DB_getNetworkProfileFromDb();
  13794. return 0;
  13795. }
  13796. int TransactionMessageAttemptsGet(void)
  13797. {
  13798. return TransactionMessageAttemptsValue;
  13799. }
  13800. int FirstHeartBeatResponse(void)
  13801. {
  13802. return FirstHeartBeat;
  13803. }
  13804. int TransactionMessageRetryIntervalGet(void)
  13805. {
  13806. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  13807. }
  13808. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  13809. {
  13810. int result = TRUE;
  13811. char rmFileCmd[100]={0};
  13812. char FilePath[100]={0};
  13813. char ftpbuf[200];
  13814. int systemresult;
  13815. //DEBUG_INFO("filename=%s\n",filename);
  13816. //DEBUG_INFO("url=%s\n",url);
  13817. sprintf(FilePath,"/mnt/%s",filename);
  13818. system("ping 8.8.8.8 &");
  13819. if((access(FilePath,F_OK))!=-1)
  13820. {
  13821. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13822. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13823. system(rmFileCmd);
  13824. }
  13825. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13826. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13827. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13828. systemresult = system(ftpbuf);
  13829. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13830. if(systemresult != 0)
  13831. {
  13832. DEBUG_INFO("http DownLoad error!\n");
  13833. result = FALSE;
  13834. }
  13835. system("pkill ping");
  13836. return result;
  13837. }
  13838. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  13839. {
  13840. int result = TRUE;
  13841. char rmFileCmd[100]={0};
  13842. char FilePath[100]={0};
  13843. char ftpbuf[200];
  13844. int systemresult;
  13845. //char temp[100];
  13846. sprintf(FilePath,"/mnt/%s",filename);
  13847. system("ping 8.8.8.8 &");
  13848. if((access(FilePath,F_OK))!=-1)
  13849. {
  13850. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13851. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13852. system(rmFileCmd);
  13853. }
  13854. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13855. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13856. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  13857. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13858. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13859. systemresult = system(ftpbuf);
  13860. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13861. if(systemresult != 0)
  13862. {
  13863. printf("wget error!\n");
  13864. result = FALSE;
  13865. }
  13866. system("pkill ping");
  13867. return result;
  13868. }
  13869. int httpUploadFile(char *location, char *path, char *filename,char *url)
  13870. {
  13871. char rmFileCmd[100]={0};
  13872. char FilePath[100]={0};
  13873. char buf[512];
  13874. int systemresult = 0;
  13875. //DEBUG_INFO("filename=%s\n",filename);
  13876. //DEBUG_INFO("url=%s\n",url);
  13877. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  13878. if((access(FilePath,F_OK))!=-1)
  13879. {
  13880. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13881. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13882. system(rmFileCmd);
  13883. }
  13884. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  13885. if(fp == NULL)
  13886. {
  13887. DEBUG_INFO("log is NULL\n");
  13888. return FALSE;
  13889. }
  13890. else
  13891. {
  13892. fprintf(fp, "%s\n", url);
  13893. fprintf(fp, "%s\n", filename);
  13894. fclose(fp);
  13895. }
  13896. FILE *phpFP = popen("/bin/php-cgi /var/www/ocpp_upload.php", "r");
  13897. if(phpFP == NULL)
  13898. {
  13899. DEBUG_INFO("PHP upload fail.\n");
  13900. return FALSE;
  13901. }
  13902. else
  13903. {
  13904. while(fgets(buf, sizeof(buf), phpFP) != NULL)
  13905. {
  13906. if(strstr(buf, "result") != NULL)
  13907. {
  13908. sscanf(buf, "result: %d", &systemresult);
  13909. DEBUG_INFO("PHP HTTP upload result: %d\n", systemresult);
  13910. }
  13911. }
  13912. pclose(phpFP);
  13913. }
  13914. if(systemresult != 1)
  13915. {
  13916. DEBUG_INFO("HTTP upload error!\n");
  13917. return FALSE;
  13918. }
  13919. return TRUE;
  13920. }
  13921. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  13922. {
  13923. struct hostent* server;
  13924. char *IPbuffer;
  13925. char ftpbuf[200];
  13926. int systemresult;
  13927. // To retrieve host information
  13928. server = gethostbyname(location);
  13929. // To convert an Internet network
  13930. // address into ASCII string
  13931. IPbuffer = inet_ntoa(*((struct in_addr*)
  13932. server->h_addr_list[0]));
  13933. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13934. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  13935. /* format : ftpput -u username -p passwd IP target source*/
  13936. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  13937. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13938. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13939. systemresult = system(ftpbuf);
  13940. DEBUG_INFO("systemresult=%d\n",systemresult);
  13941. if(systemresult != 0)
  13942. {
  13943. DEBUG_INFO("ftpput error!\n");
  13944. return FALSE;
  13945. }
  13946. return TRUE;
  13947. }
  13948. //=========================================
  13949. // Routine
  13950. //=========================================
  13951. int GetOcppServerURL()
  13952. {
  13953. int result = FALSE;
  13954. struct yuarel url;
  13955. char urlStr[512];
  13956. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  13957. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  13958. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  13959. if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  13960. {
  13961. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  13962. if(yuarel_parse(&url, urlStr) != -1)
  13963. {
  13964. sprintf(OcppProtocol, "%s", url.scheme);
  13965. sprintf(OcppHost, "%s", url.host);
  13966. if(url.path == NULL)
  13967. OcppTempPath[0] = '\0';
  13968. else
  13969. sprintf(OcppTempPath, "%s", url.path);
  13970. if(url.port == 0)
  13971. {
  13972. if(strcmp(OcppProtocol, "wss") == 0)
  13973. OcppPort = 443;
  13974. else
  13975. OcppPort = 80;
  13976. }
  13977. else
  13978. OcppPort = url.port;
  13979. result = TRUE;
  13980. }
  13981. }
  13982. else
  13983. {
  13984. strcpy(OcppHost,"");
  13985. }
  13986. return result;
  13987. }
  13988. int GetOcppPath()
  13989. {
  13990. int result = FALSE;
  13991. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  13992. {
  13993. if(OcppTempPath == NULL)
  13994. {
  13995. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13996. }
  13997. else
  13998. {
  13999. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  14000. }
  14001. result = TRUE;
  14002. }
  14003. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  14004. {
  14005. if(OcppTempPath == NULL)
  14006. {
  14007. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  14008. }
  14009. else
  14010. {
  14011. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  14012. }
  14013. result = TRUE;
  14014. }
  14015. else
  14016. {
  14017. strcpy(OcppPath,"");
  14018. }
  14019. return result;
  14020. }
  14021. int GetOcppPort()
  14022. {
  14023. return OcppPort;
  14024. }
  14025. int GetOcppConnStatus(void)
  14026. {
  14027. return ShmOCPP20Data->OcppConnStatus;
  14028. }
  14029. void SetOcppConnStatus(uint8_t status)
  14030. {
  14031. ShmOCPP20Data->OcppConnStatus = status;
  14032. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  14033. }
  14034. int GetHeartBeatWithNOResponse(void)
  14035. {
  14036. return HeartBeatWithNOResponse;
  14037. }
  14038. void SetHeartBeatWithNOResponse(void)
  14039. {
  14040. HeartBeatWithNOResponse = 0;
  14041. }
  14042. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  14043. void storeTempStopTransaction(int gun_index)
  14044. {
  14045. char TempStopTransaction[256];
  14046. char message[1024*20]={0};
  14047. char guid[37]={0};
  14048. uint8_t tempIndex;
  14049. json_object *TransactionEvent = json_object_new_object();
  14050. json_object *transactionInfo = json_object_new_object();
  14051. json_object *idToken = json_object_new_object();
  14052. json_object *evse = json_object_new_object();
  14053. json_object *meterValues = json_object_new_array();
  14054. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  14055. DEBUG_INFO("storeTempStopTransaction...\n");
  14056. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  14057. {
  14058. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14059. {
  14060. tempIndex = ((gun_index==2) ? 1: 0);
  14061. }
  14062. else
  14063. {
  14064. tempIndex = gun_index;
  14065. }
  14066. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14067. {
  14068. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  14069. {
  14070. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  14071. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  14072. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  14073. else
  14074. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  14075. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  14076. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  14077. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  14078. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  14079. {
  14080. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  14081. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  14082. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  14083. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  14084. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  14085. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  14086. {
  14087. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  14088. }
  14089. else
  14090. {
  14091. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  14092. }
  14093. }
  14094. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  14095. {
  14096. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  14097. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  14098. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  14099. }
  14100. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  14101. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  14102. ) //S_PRECHARGE
  14103. {
  14104. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  14105. {
  14106. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  14107. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  14108. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  14109. }
  14110. if(ShmOCPP20Data->TransactionEvent[gun_index].eventType[0] == '\0')
  14111. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  14112. else
  14113. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  14114. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  14115. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14116. }
  14117. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  14118. {
  14119. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  14120. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  14121. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14122. }
  14123. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  14124. {
  14125. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  14126. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  14127. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14128. }
  14129. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  14130. {
  14131. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  14132. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  14133. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14134. }
  14135. 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
  14136. {
  14137. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  14138. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  14139. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  14140. }
  14141. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  14142. {
  14143. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  14144. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  14145. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  14146. }
  14147. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  14148. {
  14149. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  14150. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  14151. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  14152. }
  14153. } //end of the same index
  14154. }//end of for CHAdeMO_QUANTITY
  14155. }
  14156. else if(gunType[gun_index] == GUN_TYPE_CCS)
  14157. {
  14158. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14159. {
  14160. tempIndex = ((gun_index==2) ? 1: 0);
  14161. }
  14162. else
  14163. {
  14164. tempIndex = gun_index;
  14165. }
  14166. for (int index = 0; index < CCS_QUANTITY; index++)
  14167. {
  14168. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  14169. {
  14170. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  14171. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  14172. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  14173. else
  14174. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  14175. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  14176. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  14177. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  14178. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14179. {
  14180. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  14181. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  14182. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  14183. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  14184. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  14185. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  14186. {
  14187. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  14188. }
  14189. else
  14190. {
  14191. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  14192. }
  14193. }
  14194. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  14195. {
  14196. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  14197. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  14198. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  14199. }
  14200. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  14201. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  14202. ) //S_PRECHARGE
  14203. {
  14204. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  14205. {
  14206. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  14207. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  14208. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  14209. }
  14210. if(ShmOCPP20Data->TransactionEvent[gun_index].eventType[0] == '\0')
  14211. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  14212. else
  14213. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  14214. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  14215. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14216. }
  14217. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  14218. {
  14219. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  14220. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  14221. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14222. }
  14223. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  14224. {
  14225. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  14226. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  14227. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14228. }
  14229. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  14230. {
  14231. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  14232. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  14233. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14234. }
  14235. 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
  14236. {
  14237. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  14238. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  14239. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  14240. }
  14241. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  14242. {
  14243. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  14244. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  14245. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  14246. }
  14247. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  14248. {
  14249. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  14250. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  14251. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  14252. }
  14253. } //end of the same index
  14254. } // end of for CCS_QUANTITY
  14255. }
  14256. else if(gunType[gun_index] == GUN_TYPE_GBT)
  14257. {
  14258. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14259. {
  14260. tempIndex = ((gun_index==2) ? 1: 0);
  14261. }
  14262. else
  14263. {
  14264. tempIndex = gun_index;
  14265. }
  14266. for (int index = 0; index < GB_QUANTITY; index++)
  14267. {
  14268. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  14269. {
  14270. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  14271. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  14272. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  14273. else
  14274. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  14275. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  14276. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  14277. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  14278. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  14279. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  14280. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14281. } //end of the same index
  14282. } // end of for GB_QUANTITY
  14283. }
  14284. else if(gunType[gun_index] == GUN_TYPE_DO)
  14285. {
  14286. tempIndex = gun_index;
  14287. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  14288. {
  14289. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  14290. {
  14291. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  14292. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  14293. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  14294. else
  14295. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  14296. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  14297. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  14298. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  14299. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  14300. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  14301. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14302. } //end of the same index
  14303. }
  14304. }
  14305. else
  14306. {
  14307. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  14308. {
  14309. tempIndex = 2;
  14310. }
  14311. else
  14312. {
  14313. tempIndex = gun_index;
  14314. }
  14315. for (int index = 0; index < AC_QUANTITY; index++)
  14316. {
  14317. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  14318. {
  14319. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  14320. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  14321. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  14322. else
  14323. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  14324. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  14325. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  14326. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  14327. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  14328. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  14329. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  14330. }//end of the same index
  14331. }//end of for AC_QUANTITY
  14332. }
  14333. // Message
  14334. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  14335. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  14336. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  14337. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  14338. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  14339. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  14340. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  14341. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  14342. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  14343. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  14344. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  14345. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  14346. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  14347. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  14348. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  14349. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  14350. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  14351. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  14352. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  14353. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  14354. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  14355. {
  14356. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  14357. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  14358. json_object_object_add(TransactionEvent, "idToken", idToken);
  14359. }
  14360. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  14361. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  14362. json_object_object_add(TransactionEvent, "evse", evse);
  14363. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  14364. {
  14365. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  14366. {
  14367. json_object *meterValue = json_object_new_object();
  14368. json_object *sampledValues = json_object_new_array();
  14369. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  14370. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  14371. {
  14372. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  14373. ((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) == 0)))
  14374. {
  14375. json_object *sampledValue = json_object_new_object();
  14376. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  14377. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  14378. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  14379. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  14380. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  14381. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  14382. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  14383. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  14384. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  14385. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  14386. {
  14387. json_object *unitOfMeasure = json_object_new_object();
  14388. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  14389. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  14390. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  14391. }
  14392. json_object_array_add(sampledValues, sampledValue);
  14393. }
  14394. }
  14395. json_object_object_add(meterValue, "sampledValue", sampledValues);
  14396. json_object_array_add(meterValues, meterValue);
  14397. }
  14398. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  14399. }
  14400. random_uuid(guid);
  14401. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL
  14402. , guid
  14403. , "TransactionEvent"
  14404. , json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  14405. json_object_put(TransactionEvent);
  14406. // open file for writing
  14407. FILE *outfile;
  14408. outfile = fopen (TempStopTransaction, "w+");
  14409. //DEBUG_INFO("data = %s\n", queuedata);
  14410. fputs(message, outfile);
  14411. fputs("\n", outfile);
  14412. fclose (outfile);
  14413. }
  14414. void checkTempStopTransaction(int gun_index)
  14415. {
  14416. FILE *fptr1;
  14417. char ch;
  14418. char str[QUEUE_MESSAGE_LENGTH]={0};
  14419. char guid[37]={0};
  14420. char tempdata[65]={0};
  14421. char TempStopTransaction[256];
  14422. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  14423. fptr1 = fopen(TempStopTransaction, "r");
  14424. if (!fptr1)
  14425. {
  14426. //DEBUG_INFO("TempStopTransaction_%d not found or unable to open the input file!\n", (gun_index+1));
  14427. return ;
  14428. }
  14429. ch=fgetc(fptr1);
  14430. rewind(fptr1);
  14431. if(ch!=EOF)
  14432. {
  14433. // copy all contents to the temporary file except the specific line
  14434. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  14435. {
  14436. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  14437. if(str[0]=='\0')
  14438. {
  14439. break;
  14440. }
  14441. strncpy(guid, str+4, 36); //copy guid
  14442. sprintf(tempdata, "TransactionEvent,%d", (gun_index));
  14443. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  14444. {
  14445. //DEBUG_INFO("StopTransaction mapitem pass\n");
  14446. }
  14447. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  14448. memset(str,0,ARRAY_SIZE(str));
  14449. }
  14450. }
  14451. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  14452. fclose(fptr1);
  14453. remove(TempStopTransaction); // remove the original file
  14454. }
  14455. int GetWebSocketPingInterval(void)
  14456. {
  14457. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  14458. }
  14459. int GetServerSign(void)
  14460. {
  14461. return server_sign;
  14462. }
  14463. uint8_t GetOcppSecurityProfile()
  14464. {
  14465. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  14466. }
  14467. void GetOcppChargerBoxId(uint8_t *data)
  14468. {
  14469. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  14470. }
  14471. void GetOcppSecurityPassword(uint8_t *data)
  14472. {
  14473. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  14474. }
  14475. void SetServerSign(int value)
  14476. {
  14477. server_sign = value;
  14478. }
  14479. int GetBootNotificationInterval(void)
  14480. {
  14481. return BootNotificationInterval;
  14482. }
  14483. int GetInternetConn(void)
  14484. {
  14485. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  14486. }
  14487. int isConnectorInitMode(int gun_index)
  14488. {
  14489. int tempIndex = 0;
  14490. int result = TRUE;
  14491. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  14492. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  14493. {
  14494. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14495. {
  14496. tempIndex = ((gun_index==2) ? 1: 0);
  14497. }
  14498. else
  14499. {
  14500. tempIndex = gun_index;
  14501. }
  14502. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14503. {
  14504. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  14505. {
  14506. result = (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  14507. } //end of the same index
  14508. }//end of for CHAdeMO_QUANTITY
  14509. }
  14510. else if(gunType[gun_index] == GUN_TYPE_CCS)
  14511. {
  14512. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14513. {
  14514. tempIndex = ((gun_index==2) ? 1: 0);
  14515. }
  14516. else
  14517. {
  14518. tempIndex = gun_index;
  14519. }
  14520. for (int index = 0; index < CCS_QUANTITY; index++)
  14521. {
  14522. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  14523. {
  14524. result = (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  14525. } //end of the same index
  14526. } // end of for CCS_QUANTITY
  14527. }
  14528. else if(gunType[gun_index] == GUN_TYPE_GBT)
  14529. {
  14530. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14531. {
  14532. tempIndex = ((gun_index==2) ? 1: 0);
  14533. }
  14534. else
  14535. {
  14536. tempIndex = gun_index;
  14537. }
  14538. for (int index = 0; index < GB_QUANTITY; index++)
  14539. {
  14540. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  14541. {
  14542. result = (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  14543. } //end of the same index
  14544. } // end of for GB_QUANTITY
  14545. }
  14546. else if(gunType[gun_index] == GUN_TYPE_DO)
  14547. {
  14548. tempIndex = gun_index;
  14549. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  14550. {
  14551. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  14552. {
  14553. result = (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  14554. } //end of the same index
  14555. }
  14556. }
  14557. else
  14558. {
  14559. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  14560. {
  14561. tempIndex = 2;
  14562. }
  14563. else
  14564. {
  14565. tempIndex = gun_index;
  14566. }
  14567. for (int index = 0; index < AC_QUANTITY; index++)
  14568. {
  14569. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  14570. {
  14571. result = (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  14572. }//end of the same index
  14573. }//end of for AC_QUANTITY
  14574. }
  14575. return result;
  14576. }
  14577. void refreshProcDogTimer()
  14578. {
  14579. ShmOCPP20Data->procDogTime = time((time_t*)NULL);
  14580. }
  14581. void InitialSystemValue(void)
  14582. {
  14583. int connectorIndex = 0;
  14584. gunTotalNumber=0;
  14585. SystemInitial = 0;
  14586. localversion=0;
  14587. BootNotificationInterval = 10;
  14588. authorizeRetryTimes = 0;
  14589. GunStatusInterval = 10;
  14590. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  14591. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  14592. //Hear Beat
  14593. HeartBeatWithNOResponse = 0;
  14594. HeartBeatCountPerHour = 0;
  14595. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  14596. FirstHeartBeat = 0;
  14597. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  14598. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  14599. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  14600. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  14601. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  14602. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  14603. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  14604. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  14605. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  14606. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  14607. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  14608. memset(gunType, 0, ARRAY_SIZE(gunType));
  14609. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  14610. {
  14611. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  14612. {
  14613. // DO series
  14614. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  14615. {
  14616. SystemInitial = SystemInitial + 1;
  14617. gunTotalNumber = gunTotalNumber + 1;
  14618. gunType[connectorIndex] = GUN_TYPE_DO;
  14619. connectorIndex = connectorIndex + 1;
  14620. }
  14621. }
  14622. else
  14623. {
  14624. // DM, DW, DS series
  14625. //check connector / socket type (index: 8, 9, 10)
  14626. for(int index=7; index <10 ; index++)
  14627. {
  14628. if(index != 8)
  14629. {
  14630. // DC Connector
  14631. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'J'))
  14632. {
  14633. SystemInitial = SystemInitial + 1;
  14634. gunTotalNumber = gunTotalNumber + 1;
  14635. gunType[connectorIndex] = GUN_TYPE_CHAdeMO;
  14636. connectorIndex = connectorIndex + 1;
  14637. }
  14638. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'D') ||
  14639. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'E') ||
  14640. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'F') ||
  14641. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'U') ||
  14642. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'T') ||
  14643. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'V'))
  14644. {
  14645. SystemInitial = SystemInitial + 1;
  14646. gunTotalNumber = gunTotalNumber + 1;
  14647. gunType[connectorIndex] = GUN_TYPE_CCS;
  14648. connectorIndex = connectorIndex + 1;
  14649. }
  14650. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'G'))
  14651. {
  14652. SystemInitial = SystemInitial + 1;
  14653. gunTotalNumber = gunTotalNumber + 1;
  14654. gunType[connectorIndex] = GUN_TYPE_GBT;
  14655. connectorIndex = connectorIndex + 1;
  14656. }
  14657. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'O'))
  14658. {
  14659. SystemInitial = SystemInitial + 1;
  14660. gunTotalNumber = gunTotalNumber + 1;
  14661. gunType[connectorIndex] = GUN_TYPE_DO;
  14662. connectorIndex = connectorIndex + 1;
  14663. }
  14664. }
  14665. else
  14666. {
  14667. // AC Connector
  14668. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  14669. {
  14670. SystemInitial = SystemInitial + 1;
  14671. gunTotalNumber = gunTotalNumber + 1;
  14672. gunType[connectorIndex] = GUN_TYPE_AC;
  14673. connectorIndex = connectorIndex + 1;
  14674. }
  14675. }
  14676. }
  14677. }
  14678. //DEBUG_INFO("DC ...\n");
  14679. }
  14680. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  14681. {
  14682. //check connector / socket type (index: 8, 9, 10)
  14683. for(int index=7; index <10 ; index++)
  14684. {
  14685. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  14686. {
  14687. SystemInitial = SystemInitial + 1;
  14688. gunTotalNumber = gunTotalNumber + 1;
  14689. gunType[connectorIndex] = GUN_TYPE_AC;
  14690. connectorIndex = connectorIndex + 1;
  14691. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  14692. }
  14693. }
  14694. }
  14695. //Status && ConnectorPlugIn Setting
  14696. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14697. {
  14698. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  14699. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  14700. }
  14701. for (int index = 0; index < CCS_QUANTITY; index++)
  14702. {
  14703. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  14704. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  14705. }
  14706. for (int index = 0; index < GB_QUANTITY; index++)
  14707. {
  14708. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  14709. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  14710. }
  14711. for (int index = 0; index < AC_QUANTITY; index++)
  14712. {
  14713. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  14714. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  14715. }
  14716. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  14717. {
  14718. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  14719. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  14720. }
  14721. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  14722. {
  14723. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  14724. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  14725. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  14726. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  14727. }
  14728. clientTime.Heartbeat=time((time_t*)NULL);
  14729. sleep(1);
  14730. }
  14731. void LWS_Send(char * str)
  14732. {
  14733. //=====================================================
  14734. // Check InternetConn 0: disconnected, 1: connected
  14735. //====================================================
  14736. if(GetOcppConnStatus() == 0)
  14737. {
  14738. DEBUG_INFO("offline now !!!\n");
  14739. return;
  14740. }
  14741. pthread_mutex_lock(&lock_send);
  14742. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  14743. sprintf((char *)SendBuffer, "%s", str);
  14744. SendBufLen = strlen(str);
  14745. pthread_mutex_unlock(&lock_send);
  14746. lws_callback_on_writable(wsi_client);
  14747. //lws_service(context, 0);
  14748. //sleep(1);
  14749. }
  14750. void LWS_SendNow(char * str)
  14751. {
  14752. //=====================================================
  14753. // Check InternetConn 0: disconnected, 1: connected
  14754. //====================================================
  14755. if(GetOcppConnStatus() == 0)
  14756. {
  14757. DEBUG_INFO("offline now !!!\n");
  14758. return;
  14759. }
  14760. pthread_mutex_lock(&lock_send);
  14761. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  14762. sprintf((char *)SendBuffer, "%s", str);
  14763. SendBufLen = strlen(str);
  14764. pthread_mutex_unlock(&lock_send);
  14765. lws_callback_on_writable(wsi_client);
  14766. lws_service(context, 0);
  14767. //sleep(1);
  14768. }