MessageHandler.c 962 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619
  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. // Variable Version
  686. //===============================
  687. static int variableVersion=2;
  688. //===============================
  689. // OCPP sign variable
  690. //===============================
  691. static int server_sign = FALSE;
  692. int server_pending = FALSE;
  693. static int BootNotificationInterval = 10;
  694. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  695. //===============================
  696. // OCPP auth variable
  697. //===============================
  698. static int authorizeRetryTimes = 0; //number of Retry times
  699. //===============================
  700. // OCPP other variables
  701. //===============================
  702. static int HeartBeatWaitTime = 10;
  703. static int FirstHeartBeat = 0;
  704. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  705. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  706. static char CurrentChargingProfileScheduleStr[30] = {0};
  707. //========================================
  708. // OCPP status/previous related variables
  709. //========================================
  710. static int GunStatusInterval = 10;
  711. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  712. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  713. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  714. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  715. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  716. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  717. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  718. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  719. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  720. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  721. static int TransactionMessageAttemptsValue = 0;
  722. static int TransactionMessageRetryIntervalValue = 0;
  723. static struct AuthorizationData idTagQuery;
  724. //=============================================
  725. // OCPP HeartBeat Response Not Receive Counts
  726. //============================================
  727. static int HeartBeatWithNOResponse = 0;
  728. static int HeartBeatCountPerHour = 0;
  729. sqlite3 *db;
  730. extern void ChageWebSocketPingInterval(int WebSocketPingInterval);
  731. int TransactionMessageAttemptsGet(void);
  732. int TransactionMessageRetryIntervalGet(void);
  733. int GetOcppConnStatus(void);
  734. void SetOcppConnStatus(uint8_t status);
  735. int setKeyValue(char *key, char *value);
  736. void OCPP_get_TableAuthlocalAllData(void);
  737. void processUnkownKey(void);
  738. struct InterLock
  739. {
  740. unsigned char isGetLogGoing:1;
  741. unsigned char isUpdateFirmwareGoing:1;
  742. }interLock;
  743. struct ClientTime
  744. {
  745. unsigned int Heartbeat;
  746. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  747. unsigned int StartTransaction;
  748. unsigned int StopTransaction;
  749. unsigned int MeterValues[CONNECTOR_QUANTITY];
  750. }clientTime;
  751. typedef union
  752. {
  753. //Operations Initiated by Central System
  754. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  755. struct
  756. {
  757. //CsMsgValue[0]
  758. unsigned char StatusNotificationReq:1; //bit 0,
  759. unsigned char StatusNotificationConf:1; //bit 1,
  760. unsigned char TriggerMeterValueReq:1; //bit 2,
  761. unsigned char SampleMeterReq:1; //bit 3,
  762. unsigned char ClockAlignMeterReq:1; //bit 4,
  763. unsigned char TriggerStatusNotificationReq:1; //bit 5,
  764. unsigned char isOnCharging:1; //bit6,
  765. unsigned char :1; //bit7
  766. }bits[CONNECTOR_QUANTITY];
  767. }CpinitiateMsg;
  768. CpinitiateMsg cpinitateMsg;
  769. //=========================================
  770. // Save configuration
  771. //=========================================
  772. int runShellCmd(const char*cmd)
  773. {
  774. int result = FAIL;
  775. char buf[256];
  776. FILE *fp;
  777. fp = popen(cmd, "r");
  778. if(fp != NULL)
  779. {
  780. while(fgets(buf, sizeof(buf), fp) != NULL)
  781. {
  782. DEBUG_INFO("%s\n", buf);
  783. }
  784. result = PASS;
  785. }
  786. pclose(fp);
  787. return result;
  788. }
  789. int StoreUsrConfigData(struct SysConfigData *UsrData)
  790. {
  791. int result = PASS;
  792. int fd,wrd;
  793. unsigned int i,Chk;
  794. unsigned char *ptr, *BufTmp;
  795. int MtdBlockSize = 0x300000;
  796. Chk=0;
  797. ptr=(unsigned char *)UsrData;
  798. if((BufTmp=malloc(MtdBlockSize))!=NULL)
  799. {
  800. memset(BufTmp,0,MtdBlockSize);
  801. memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
  802. for(i=ARRAY_SIZE(UsrData->CsuBootLoadFwRev);i<MtdBlockSize-4;i++)
  803. Chk+=*(BufTmp+i);
  804. memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
  805. // Output configuration to file.
  806. fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
  807. if (fd < 0)
  808. {
  809. DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
  810. free(BufTmp);
  811. return 0;
  812. }
  813. wrd=write(fd, BufTmp, MtdBlockSize);
  814. close(fd);
  815. if(wrd<MtdBlockSize)
  816. {
  817. DEBUG_ERROR("write /mnt/EvseConfig.bin NG\n");
  818. free(BufTmp);
  819. return 0;
  820. }
  821. DEBUG_INFO("EvseConfig write to file in /mnt OK.\n");
  822. DEBUG_INFO("Erase /dev/mtd10.\n");
  823. runShellCmd("flash_erase /dev/mtd10 0 0");
  824. DEBUG_INFO("Write /dev/mtd10.\n");
  825. runShellCmd("nandwrite -p /dev/mtd10 /mnt/EvseConfig.bin");
  826. DEBUG_INFO("Erase /dev/mtd11.\n");
  827. runShellCmd("flash_erase /dev/mtd11 0 0");
  828. DEBUG_INFO("Write /dev/mtd11.\n");
  829. runShellCmd("nandwrite -p /dev/mtd11 /mnt/EvseConfig.bin");
  830. system("rm -f /mnt/EvseConfig.bin");
  831. DEBUG_INFO("EvseConfig write to flash OK\n");
  832. }
  833. else
  834. {
  835. DEBUG_ERROR("alloc BlockSize NG\r\n");
  836. result = FAIL;
  837. }
  838. if(BufTmp!=NULL)
  839. free(BufTmp);
  840. return result;
  841. }
  842. //=========================================
  843. // Date time related function
  844. //=========================================
  845. void getNowDatetime(uint8_t *data)
  846. {
  847. time_t t = time(NULL);
  848. struct tm tm = *localtime(&t);
  849. 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);
  850. }
  851. //=========================================
  852. // Sqlite3 related function
  853. //=========================================
  854. int DB_Initial()
  855. {
  856. int result = PASS;
  857. char* errMsg = NULL;
  858. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  859. "idToken text UNIQUE,"
  860. "type text,"
  861. "status text,"
  862. "cacheExpiryDateTime text,"
  863. "chargingPriority integer,"
  864. "language1 text,"
  865. "evseId text,"
  866. "language2 text,"
  867. "groupIdToken_idToken text,"
  868. "groupIdToken_type text,"
  869. "personalMessage text);";
  870. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  871. "idToken text UNIQUE,"
  872. "type text,"
  873. "status text,"
  874. "cacheExpiryDateTime text,"
  875. "chargingPriority integer,"
  876. "language1 text,"
  877. "evseId text,"
  878. "language2 text,"
  879. "groupIdToken_idToken text,"
  880. "groupIdToken_type text,"
  881. "personalMessage text,"
  882. "version text);";
  883. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  884. "componentName text NOT NULL ,"
  885. "componentInstance text, "
  886. "variableName text NOT NULL, "
  887. "variableInstance text, "
  888. "variableCharacteristicsDataType integer, "
  889. "variableCharacteristicsUnit text, "
  890. "variableCharacteristicsMaxLimit real,"
  891. "variableAttributesType text, "
  892. "variableAttributesTypeMutability text, "
  893. "variableAttributesTypeValue text, "
  894. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  895. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  896. "type text);";
  897. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  898. "slot integer UNIQUE, connectionData text);";
  899. char *sqlTransaction = "create table if not exists ocpp20_transaction_record (idx integer primary key,"
  900. "occurDatetime text,"
  901. "message_type text,"
  902. "message_content text)";
  903. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  904. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  905. {
  906. result = FAIL;
  907. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  908. sqlite3_close(db);
  909. }
  910. else
  911. {
  912. DEBUG_INFO( "OCPP local database open successfully.\n");
  913. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  914. {
  915. result = FAIL;
  916. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  917. }
  918. else
  919. {
  920. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  921. }
  922. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  923. {
  924. result = FAIL;
  925. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  926. }
  927. else
  928. {
  929. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  930. }
  931. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  932. {
  933. result = FAIL;
  934. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  935. }
  936. else
  937. {
  938. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  939. }
  940. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  941. {
  942. result = FAIL;
  943. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  944. }
  945. else
  946. {
  947. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  948. }
  949. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  950. {
  951. result = FAIL;
  952. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  953. }
  954. else
  955. {
  956. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  957. }
  958. if (sqlite3_exec(db, sqlTransaction, 0, 0, &errMsg) != SQLITE_OK)
  959. {
  960. result = FAIL;
  961. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_transaction_record table error message: %s\n", errMsg);
  962. }
  963. else
  964. {
  965. DEBUG_INFO( "Create OCPP 2.0 ocpp20_transaction_record table successfully\n");
  966. }
  967. //sqlite3_close(db);
  968. }
  969. return result;
  970. }
  971. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  972. {
  973. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  974. return 0;
  975. }
  976. void DB_getListVerion()
  977. {
  978. char sql[256];
  979. char* errMsg = NULL;
  980. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  981. /* Execute SQL statement */
  982. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  983. {
  984. DEBUG_INFO("SQL error: %s", errMsg);
  985. }
  986. }
  987. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  988. {
  989. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  990. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  991. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  992. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  993. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  994. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  995. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  996. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  997. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  998. return 0;
  999. }
  1000. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  1001. {
  1002. char sql[256];
  1003. char* errMsg = NULL;
  1004. memset(&idTagQuery, 0, sizeof(idTagQuery));
  1005. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  1006. if(isQueryFromCache)
  1007. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  1008. else
  1009. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  1010. /* Execute SQL statement */
  1011. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  1012. {
  1013. DEBUG_INFO("SQL error: %s", errMsg);
  1014. }
  1015. }
  1016. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  1017. {
  1018. for (int i = 0; i < columnCount; i++)
  1019. {
  1020. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  1021. }
  1022. return 0;
  1023. }
  1024. void DB_get_TableAuthlocalAllData(void)
  1025. {
  1026. char sql[256];
  1027. char* errMsg = NULL;
  1028. sprintf(sql,"select * from ocpp20_auth_local;");
  1029. /* Execute SQL statement */
  1030. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  1031. {
  1032. DEBUG_INFO("SQL error: %s", errMsg);
  1033. }
  1034. }
  1035. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  1036. {
  1037. for(int i = 0; i<columnCount; i++)
  1038. {
  1039. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1040. }
  1041. return 0;
  1042. }
  1043. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  1044. {
  1045. int result = PASS;
  1046. char sql[512];
  1047. char* errMsg = NULL;
  1048. 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;",
  1049. data->idToken.idToken,
  1050. data->idToken.type,
  1051. data->idTokenInfo.status,
  1052. data->idTokenInfo.cacheExpiryDateTime,
  1053. data->idTokenInfo.chargingPriority,
  1054. data->idTokenInfo.language1,
  1055. data->idTokenInfo.language2,
  1056. data->idTokenInfo.groupIdToken.idToken,
  1057. data->idTokenInfo.groupIdToken.type,
  1058. listVersion);
  1059. //* Execute SQL statement */
  1060. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1061. {
  1062. DEBUG_INFO("SQL error: %s\n", errMsg);
  1063. result = FAIL;
  1064. }
  1065. else
  1066. {
  1067. memset(sql, 0, ARRAY_SIZE(sql));
  1068. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  1069. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  1070. {
  1071. DEBUG_INFO("SQL error: %s\n", errMsg);
  1072. result = FAIL;
  1073. }
  1074. }
  1075. return result;
  1076. }
  1077. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  1078. {
  1079. int result = PASS;
  1080. char sql[512];
  1081. char* errMsg = NULL;
  1082. 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;",
  1083. idToken->idToken,
  1084. idToken->type,
  1085. idTokenInfo->status,
  1086. idTokenInfo->cacheExpiryDateTime,
  1087. idTokenInfo->chargingPriority,
  1088. idTokenInfo->language1,
  1089. idTokenInfo->language2,
  1090. idTokenInfo->groupIdToken.idToken,
  1091. idTokenInfo->groupIdToken.type);
  1092. //* Execute SQL statement */
  1093. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1094. {
  1095. DEBUG_INFO("SQL error: %s\n", errMsg);
  1096. result = FAIL;
  1097. }
  1098. return result;
  1099. }
  1100. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1101. {
  1102. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1103. // printf("localversion=%d\n", localversion);
  1104. return 0;
  1105. }
  1106. void DB_deleteIdTag(char idTag[])
  1107. {
  1108. char sql[512];
  1109. char* errMsg = NULL;
  1110. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1111. //* Execute SQL statement */
  1112. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1113. {
  1114. DEBUG_INFO("SQL error: %s", errMsg);
  1115. }
  1116. }
  1117. int DB_cleanLocalList()
  1118. {
  1119. int result = PASS;
  1120. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1121. char *errMsg = 0;
  1122. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1123. {
  1124. DEBUG_INFO("%s\n", errMsg);
  1125. result = FAIL;
  1126. }
  1127. return result;
  1128. }
  1129. int DB_cleanLocalCache()
  1130. {
  1131. int result = PASS;
  1132. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1133. char *errMsg = 0;
  1134. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1135. {
  1136. DEBUG_INFO("%s\n", errMsg);
  1137. result = FAIL;
  1138. }
  1139. return result;
  1140. }
  1141. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1142. {
  1143. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1144. return 0;
  1145. }
  1146. void DB_getBooType()
  1147. {
  1148. char sql[256];
  1149. char* errMsg = NULL;
  1150. sprintf(sql,"select * from ocpp20_boot_type;");
  1151. /* Execute SQL statement */
  1152. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1153. {
  1154. DEBUG_INFO("SQL error: %s\n", errMsg);
  1155. }
  1156. }
  1157. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1158. {
  1159. for(int i = 0; i<columnCount; i++)
  1160. {
  1161. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1162. }
  1163. return 0;
  1164. }
  1165. int DB_updateBootType(BootReasonEnumType reason)
  1166. {
  1167. int result = PASS;
  1168. char sql[512];
  1169. char* errMsg = NULL;
  1170. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1171. //* Execute SQL statement */
  1172. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1173. {
  1174. DEBUG_INFO("SQL error: %s\n", errMsg);
  1175. result = FAIL;
  1176. }
  1177. return result;
  1178. }
  1179. int DB_variableClear()
  1180. {
  1181. int result = PASS;
  1182. char * sqlcleanLocalList = "delete from ocpp20_variable";
  1183. char *errMsg = 0;
  1184. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1185. {
  1186. DEBUG_INFO("%s\n", errMsg);
  1187. result = FAIL;
  1188. }
  1189. return result;
  1190. }
  1191. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1192. {
  1193. for(int i = 0; i<columnCount; i++)
  1194. {
  1195. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1196. }
  1197. return 0;
  1198. }
  1199. int DB_variableSaveToDb(struct ReportDataType *variable)
  1200. {
  1201. int result = FAIL;
  1202. char sql[4096];
  1203. char* errMsg = NULL;
  1204. 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;",
  1205. variable->component.name,
  1206. variable->component.instance,
  1207. variable->variable.name,
  1208. variable->variable.instance,
  1209. variable->variableCharacteristics.dataType,
  1210. variable->variableCharacteristics.unit,
  1211. variable->variableCharacteristics.maxLimit,
  1212. variable->variableAttribute[0].type,
  1213. variable->variableAttribute[0].mutability,
  1214. variable->variableAttribute[0].value);
  1215. //* Execute SQL statement */
  1216. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1217. {
  1218. DEBUG_INFO("SQL error: %s\n", errMsg);
  1219. result = FAIL;
  1220. }
  1221. return result;
  1222. }
  1223. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1224. {
  1225. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1226. if(atoi(columnValue[0]) == 0)
  1227. {
  1228. DB_updateBootType(BootReasonEnumType_PowerUp);
  1229. // Create variable table content
  1230. /* AlignedDataCtrlr Required item */
  1231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1237. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1244. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1248. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.maxLimit = 20;
  1249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1251. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,"
  1253. "Energy.Active.Import.Register,"
  1254. "Energy.Active.Import.Interval,"
  1255. "Power.Active.Import,"
  1256. "Voltage,"
  1257. "SoC,"
  1258. "Current.Offered,"
  1259. "Power.Offered");
  1260. else
  1261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,"
  1262. "Energy.Active.Import.Register,"
  1263. "Energy.Active.Import.Interval,"
  1264. "Power.Active.Import,"
  1265. "Voltage,"
  1266. "Current.Offered");
  1267. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1272. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 10;
  1273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1276. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1283. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1290. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1294. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1297. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1299. "Energy.Active.Import.Register,"
  1300. "Energy.Active.Import.Interval,"
  1301. "Power.Active.Import,"
  1302. "Voltage,"
  1303. "SoC");
  1304. else
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1306. "Energy.Active.Import.Register,"
  1307. "Energy.Active.Import.Interval,"
  1308. "Power.Active.Import,"
  1309. "Voltage");
  1310. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1318. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1319. /* AuthCtrlrVariable Required item */
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1326. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1333. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1340. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1347. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1354. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1361. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1365. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1369. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1370. /* AuthCacheCtrlr Variable Required item*/
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1377. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1384. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1392. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1396. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1400. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1407. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1408. /* ClockCtrlr Variable Required item */
  1409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1414. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1415. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1422. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1430. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1437. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1444. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1452. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1459. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1466. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1467. /* ChargingStation Required item */
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1474. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1481. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1488. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1489. /* Connector Required item */
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1496. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1503. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1510. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1511. /* CustomizationCtrlr Required item */
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1518. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1519. /* DeviceDataCtrlr Required item */
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1527. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1535. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1543. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1551. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1554. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1559. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1562. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1567. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1575. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1583. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1584. /* DisplayMessageCtrlr Required item */
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1591. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1598. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1602. ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.maxLimit = 1;
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "1");
  1606. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1613. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1620. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1621. /* EVSE Required item */
  1622. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1628. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1635. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1642. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1649. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1650. /* LocalAuthListCtrlr Required item */
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1657. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1659. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1660. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1661. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.maxLimit = 5000;
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1665. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1672. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1675. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "500");
  1680. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "20480");
  1688. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1692. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "100000");
  1696. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1697. /* MonitoringCtrlr Required item */
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1704. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1711. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1719. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1720. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1727. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1730. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1735. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1743. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1750. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1751. /* OCPPCommCtrlr Required item */
  1752. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1758. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1767. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1774. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1782. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1788. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1789. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1796. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1804. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1807. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1811. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1820. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1821. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1829. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1836. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1843. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1844. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1850. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1851. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1857. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1858. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].component.name, "OCPPCommCtrlr");
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variable.name, "VariableVersion");
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].value, "%d", variableVersion);
  1865. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion]);
  1866. /* ReservationCtrlr Required item */
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1871. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1873. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1878. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1880. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1887. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1888. /* SampledDataCtrlr Required item */
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1892. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1895. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1899. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1902. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1909. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1913. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1916. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1918. "Energy.Active.Import.Register,"
  1919. "Energy.Active.Import.Interval,"
  1920. "Power.Active.Import,"
  1921. "Voltage,"
  1922. "SoC");
  1923. else
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1925. "Energy.Active.Import.Register,"
  1926. "Energy.Active.Import.Interval,"
  1927. "Power.Active.Import,"
  1928. "Voltage");
  1929. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1937. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1941. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.maxLimit = 10;
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1944. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1945. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1949. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.maxLimit = 0;
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1952. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, "Current.Import,"
  1954. "Energy.Active.Import.Register,"
  1955. "Energy.Active.Import.Interval,"
  1956. "Power.Active.Import,"
  1957. "Voltage,"
  1958. "SoC,"
  1959. "Current.Offered,"
  1960. "Power.Offered");
  1961. else
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, "Current.Import,"
  1963. "Energy.Active.Import.Register,"
  1964. "Energy.Active.Import.Interval,"
  1965. "Power.Active.Import,"
  1966. "Voltage,"
  1967. "Current.Offered");
  1968. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1973. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 10;
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
  1977. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1978. /* SecurityCtrlr Required item */
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1982. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]);
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword);
  1986. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1988. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1990. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1992. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  1994. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2000. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  2001. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2005. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.maxLimit = 1;
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  2009. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
  2016. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2019. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2020. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2021. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  2023. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2027. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.maxLimit = 10000;
  2028. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].value, "10000");
  2031. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize]);
  2032. /* SmartChargingCtrlr Required item */
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2036. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  2039. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2043. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2044. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2045. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  2046. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  2047. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2048. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2051. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  2053. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  2060. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2065. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2066. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  2067. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  2074. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  2081. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  2088. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  2095. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2099. ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.maxLimit = 10;
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "10");
  2103. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  2110. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  2111. /* TariffCostCtrlr Required item */
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  2119. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  2127. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2131. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  2135. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  2143. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  2151. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2155. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  2159. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2163. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  2167. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  2168. /* TxCtrlr Required item */
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2175. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2183. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2190. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2197. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2204. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2211. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "0");
  2219. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2226. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2227. }
  2228. else
  2229. {
  2230. // Variable name init
  2231. /* AlignedDataCtrlr Required item */
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2248. /* AuthCtrlrVariable Required item */
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2263. /* AuthCacheCtrlr Variable Required item */
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2274. /* ClockCtrlr Variable Required item */
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2293. /* ChargingStation Required item */
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2300. /* Connector Required item */
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2307. /* CustomizationCtrlr Required item */
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  2310. /* DeviceDataCtrlr Required item */
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2333. /* DisplayMessageCtrlr Required item */
  2334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2344. /* EVSE Required item */
  2345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2353. /* LocalAuthListCtrlr Required item */
  2354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2368. /* MonitoringCtrlr Required item */
  2369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2387. /* OCPPCommCtrlr Required item */
  2388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].component.name, "OCPPCommCtrlr");
  2420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variable.name, "VariableVersion");
  2421. /* ReservationCtrlr Required item */
  2422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2428. /* SampledDataCtrlr Required item */
  2429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2445. /* SecurityCtrlr Required item */
  2446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
  2459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
  2460. /* SmartChargingCtrlr Required item */
  2461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2483. /* TariffCostCtrlr Required item */
  2484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2502. /* TxCtrlr Required item */
  2503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2519. }
  2520. return 0;
  2521. }
  2522. void DB_variableIsCreate()
  2523. {
  2524. char sql[512];
  2525. char* errMsg = NULL;
  2526. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2527. /* Execute SQL statement */
  2528. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2529. {
  2530. DEBUG_INFO("SQL error: %s\n", errMsg);
  2531. }
  2532. }
  2533. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2534. {
  2535. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2536. {
  2537. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) == 0) &&
  2538. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) == 0) &&
  2539. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) == 0) &&
  2540. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) == 0))
  2541. {
  2542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2544. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2548. }
  2549. }
  2550. return 0;
  2551. }
  2552. void DB_variableLoadFromDb()
  2553. {
  2554. char sql[512];
  2555. char* errMsg = NULL;
  2556. sprintf(sql,"select * from ocpp20_variable order by idx;");
  2557. /* Execute SQL statement */
  2558. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2559. {
  2560. DEBUG_INFO("SQL error: %s\n", errMsg);
  2561. }
  2562. }
  2563. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2564. {
  2565. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2566. if(columnCount > 0)
  2567. {
  2568. for(int idx=0;idx<columnCount;idx++)
  2569. {
  2570. json_object *SetNetworkProfile;
  2571. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2572. if(!is_error(SetNetworkProfile))
  2573. {
  2574. // Required data
  2575. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2576. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2577. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2578. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2579. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2580. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2581. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2582. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2583. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2584. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2585. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2586. {
  2587. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2588. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2589. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2590. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2591. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2592. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2593. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2594. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2595. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2596. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2597. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2598. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2599. }
  2600. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2601. {
  2602. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2603. {
  2604. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2605. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2606. }
  2607. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2608. {
  2609. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2610. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2611. }
  2612. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2613. {
  2614. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2615. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2616. }
  2617. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2618. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2619. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2620. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2621. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2622. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2623. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2624. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2625. }
  2626. }
  2627. json_object_put(SetNetworkProfile);
  2628. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2629. }
  2630. }
  2631. return 0;
  2632. }
  2633. void DB_getNetworkProfileFromDb()
  2634. {
  2635. char sql[512];
  2636. char* errMsg = NULL;
  2637. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2638. /* Execute SQL statement */
  2639. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2640. {
  2641. DEBUG_INFO("SQL error: %s\n", errMsg);
  2642. }
  2643. }
  2644. int DB_addNetworkProfile(int slot, char *data)
  2645. {
  2646. int result = PASS;
  2647. char sql[512];
  2648. char* errMsg = NULL;
  2649. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2650. slot,
  2651. data);
  2652. //* Execute SQL statement */
  2653. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2654. {
  2655. DEBUG_INFO("SQL error: %s\n", errMsg);
  2656. result = FAIL;
  2657. }
  2658. return result;
  2659. }
  2660. int DB_deleteNetworkProfile(int slot)
  2661. {
  2662. int result = PASS;
  2663. char sql[512];
  2664. char* errMsg = NULL;
  2665. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2666. //* Execute SQL statement */
  2667. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2668. {
  2669. DEBUG_INFO("SQL error: %s", errMsg);
  2670. result = FAIL;
  2671. }
  2672. return result;
  2673. }
  2674. int getCurrentYear()
  2675. {
  2676. int result = 0;
  2677. time_t CurrentTime;
  2678. struct tm *tm;
  2679. CurrentTime = time(NULL);
  2680. tm=localtime(&CurrentTime);
  2681. result = (tm->tm_year + 1900);
  2682. return result;
  2683. }
  2684. int OCPP_insert_transaction_msg(uint8_t isStartTransaction, char *transactionMsg)
  2685. {
  2686. int result = PASS;
  2687. char* errMsg = NULL;
  2688. char sqlStr[8192];
  2689. sprintf(sqlStr, "insert into ocpp20_transaction_record(occurDatetime, message_type, message_content) values(CURRENT_TIMESTAMP, '%s', '%s');", (isStartTransaction?"startTransaction":"stopTransaction"), transactionMsg);
  2690. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2691. {
  2692. result = FAIL;
  2693. DEBUG_INFO( "Insert local transaction record error message: %s\n", errMsg);
  2694. }
  2695. 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));
  2696. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2697. {
  2698. result = FAIL;
  2699. DEBUG_INFO( "delete local transaction record error message: %s\n", errMsg);
  2700. }
  2701. return result;
  2702. }
  2703. //==========================================
  2704. // Check time passed since today
  2705. //==========================================
  2706. long long DiffTimebWithNow(struct timeb ST)
  2707. {
  2708. //return milli-second
  2709. struct timeb ET;
  2710. long long StartTime,StopTime;
  2711. ftime(&ET);
  2712. StartTime=(long long)ST.time;
  2713. StopTime=(long long)ET.time;
  2714. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2715. }
  2716. int getTimePassSinceToday(uint8_t gun_index)
  2717. {
  2718. int result = -1;
  2719. static time_t lastTime[4];
  2720. time_t t;
  2721. struct tm *tmStartToday;
  2722. struct timeb tbStartToday;
  2723. t=time(NULL);
  2724. if(difftime(t, lastTime[gun_index])>0)
  2725. {
  2726. tmStartToday=localtime(&t);
  2727. tmStartToday->tm_hour = 0;
  2728. tmStartToday->tm_min = 0;
  2729. tmStartToday->tm_sec = 0;
  2730. tbStartToday.time = mktime(tmStartToday);
  2731. tbStartToday.millitm = 0;
  2732. result = DiffTimebWithNow(tbStartToday)/1000;
  2733. lastTime[gun_index] = t;
  2734. }
  2735. return result;
  2736. }
  2737. int syncDateTimeRTC(uint8_t *data)
  2738. {
  2739. struct ParsingResult
  2740. {
  2741. int result;
  2742. int scanedElement;
  2743. int year;
  2744. int month;
  2745. int mday;
  2746. int hour;
  2747. int min;
  2748. int sec;
  2749. int tz_hour;
  2750. int tz_min;
  2751. float minSec;
  2752. }result;
  2753. struct tm tmOrg;
  2754. struct tm *tmTarget;
  2755. struct timeb tbTarget;
  2756. char buf[128];
  2757. memset(&result, 0x00, sizeof(struct ParsingResult));
  2758. result.result = PASS;
  2759. if(strstr((char*)data, ".") != NULL)
  2760. {
  2761. // Original data with mini second
  2762. if(strstr((char*)data, "Z") != NULL)
  2763. {
  2764. // Original data with Z
  2765. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%fZ",
  2766. &result.year,
  2767. &result.month,
  2768. &result.mday,
  2769. &result.hour,
  2770. &result.min,
  2771. &result.sec,
  2772. &result.minSec);
  2773. }
  2774. else
  2775. {
  2776. // Original data without Z
  2777. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  2778. &result.year,
  2779. &result.month,
  2780. &result.mday,
  2781. &result.hour,
  2782. &result.min,
  2783. &result.sec,
  2784. &result.minSec,
  2785. &result.tz_hour,
  2786. &result.tz_min);
  2787. }
  2788. }
  2789. else
  2790. {
  2791. // Original data without mini second
  2792. if(strstr((char*)data, "Z") != NULL)
  2793. {
  2794. // Original data with Z
  2795. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%dZ",
  2796. &result.year,
  2797. &result.month,
  2798. &result.mday,
  2799. &result.hour,
  2800. &result.min,
  2801. &result.sec);
  2802. }
  2803. else
  2804. {
  2805. // Original data without Z
  2806. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d%d:%d",
  2807. &result.year,
  2808. &result.month,
  2809. &result.mday,
  2810. &result.hour,
  2811. &result.min,
  2812. &result.sec,
  2813. &result.tz_hour,
  2814. &result.tz_min);
  2815. }
  2816. }
  2817. tmOrg.tm_year = result.year - 1900;
  2818. tmOrg.tm_mon = result.month - 1;
  2819. tmOrg.tm_mday = result.mday;
  2820. tmOrg.tm_hour = result.hour;
  2821. tmOrg.tm_min = result.min;
  2822. tmOrg.tm_sec = result.sec;
  2823. tmOrg.tm_gmtoff = 0;
  2824. tbTarget.time = mktime(&tmOrg);
  2825. tbTarget.timezone = 0;
  2826. tbTarget.time -= (result.tz_hour*3600) + (result.tz_min*60*(result.tz_hour>=0?1:-1));
  2827. tmTarget = gmtime(&tbTarget.time);
  2828. 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);
  2829. //DEBUG_INFO(" org date time: %s\n", data);
  2830. //DEBUG_INFO("parse date time: %s\n", buf);
  2831. system(buf);
  2832. system("/sbin/hwclock -w --systohc");
  2833. if(result.scanedElement < 6)
  2834. result.result = FAIL;
  2835. return result.result;
  2836. }
  2837. //==========================================
  2838. // GetCompositeSchedule logic related function
  2839. //==========================================
  2840. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2841. {
  2842. //return milli-second
  2843. unsigned int StartTime,StopTime;
  2844. StartTime=(unsigned int)ST.time;
  2845. StopTime=(unsigned int)ET.time;
  2846. return (StopTime-StartTime);
  2847. }
  2848. int DiffTimebWithNowSec(struct timeb ST)
  2849. {
  2850. //return milli-second
  2851. struct timeb ET;
  2852. unsigned int StartTime,StopTime;
  2853. ftime(&ET);
  2854. StartTime=(unsigned int)ST.time;
  2855. StopTime=(unsigned int)ET.time;
  2856. return (StopTime-StartTime);
  2857. }
  2858. int getStartStop(uint8_t *start, uint8_t *stop)
  2859. {
  2860. int result = -1;
  2861. struct tm tmStart;
  2862. struct timeb tbStart;
  2863. struct tm tmStop;
  2864. struct timeb tbStop;
  2865. 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) &&
  2866. (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))
  2867. {
  2868. //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);
  2869. //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);
  2870. tmStart.tm_year -= 1900;
  2871. tmStart.tm_mon -= 1;
  2872. tbStart.time = mktime(&tmStart);
  2873. tbStart.millitm = 0;
  2874. tmStop.tm_year -= 1900;
  2875. tmStop.tm_mon -= 1;
  2876. tbStop.time = mktime(&tmStop);
  2877. tbStop.millitm = 0;
  2878. result = DiffTimebSec(tbStart, tbStop);
  2879. //DEBUG_INFO("getStartStop(): %d\n", result);
  2880. }
  2881. else
  2882. {
  2883. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2884. }
  2885. return result;
  2886. }
  2887. int isOvertNow(uint8_t *start)
  2888. {
  2889. int result = NO;
  2890. struct ParsingResult
  2891. {
  2892. int result;
  2893. int scanedElement;
  2894. int year;
  2895. int month;
  2896. int mday;
  2897. int hour;
  2898. int min;
  2899. int sec;
  2900. int tz_hour;
  2901. int tz_min;
  2902. float minSec;
  2903. }parsingResult;
  2904. struct tm tmStart;
  2905. struct timeb tbStart;
  2906. memset(&parsingResult, 0x00, sizeof(struct ParsingResult));
  2907. if(strstr((char*)start, ".") != NULL)
  2908. {
  2909. // Original data with mini second
  2910. if(strstr((char*)start, "Z") != NULL)
  2911. {
  2912. // Original data with Z
  2913. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
  2914. &parsingResult.year,
  2915. &parsingResult.month,
  2916. &parsingResult.mday,
  2917. &parsingResult.hour,
  2918. &parsingResult.min,
  2919. &parsingResult.sec,
  2920. &parsingResult.minSec);
  2921. }
  2922. else
  2923. {
  2924. // Original data without Z
  2925. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  2926. &parsingResult.year,
  2927. &parsingResult.month,
  2928. &parsingResult.mday,
  2929. &parsingResult.hour,
  2930. &parsingResult.min,
  2931. &parsingResult.sec,
  2932. &parsingResult.minSec,
  2933. &parsingResult.tz_hour,
  2934. &parsingResult.tz_min);
  2935. }
  2936. }
  2937. else
  2938. {
  2939. // Original data without mini second
  2940. if(strstr((char*)start, "Z") != NULL)
  2941. {
  2942. // Original data with Z
  2943. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
  2944. &parsingResult.year,
  2945. &parsingResult.month,
  2946. &parsingResult.mday,
  2947. &parsingResult.hour,
  2948. &parsingResult.min,
  2949. &parsingResult.sec);
  2950. }
  2951. else
  2952. {
  2953. // Original data without Z
  2954. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
  2955. &parsingResult.year,
  2956. &parsingResult.month,
  2957. &parsingResult.mday,
  2958. &parsingResult.hour,
  2959. &parsingResult.min,
  2960. &parsingResult.sec,
  2961. &parsingResult.tz_hour,
  2962. &parsingResult.tz_min);
  2963. }
  2964. }
  2965. if(parsingResult.scanedElement >= 6)
  2966. {
  2967. tmStart.tm_year = parsingResult.year - 1900;
  2968. tmStart.tm_mon = parsingResult.month - 1;
  2969. tmStart.tm_mday = parsingResult.mday;
  2970. tmStart.tm_hour = parsingResult.hour;
  2971. tmStart.tm_min = parsingResult.min;
  2972. tmStart.tm_sec = parsingResult.sec;
  2973. tmStart.tm_gmtoff = 0;
  2974. tbStart.time = mktime(&tmStart);
  2975. tbStart.timezone = 0;
  2976. tbStart.millitm = 0;
  2977. tbStart.time -= (parsingResult.tz_hour*3600) + (parsingResult.tz_min*60*(parsingResult.tz_hour>=0?1:-1));
  2978. if(DiffTimebWithNowSec(tbStart) <= 0)
  2979. result = NO;
  2980. else
  2981. result = YES;
  2982. }
  2983. else
  2984. {
  2985. DEBUG_WARN("Start date parsing error.\n");
  2986. }
  2987. return result;
  2988. }
  2989. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2990. {
  2991. int result = -1;
  2992. struct tm tmStart;
  2993. struct timeb tbStart;
  2994. struct tm tmStop;
  2995. struct timeb tbStop;
  2996. 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) &&
  2997. (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))
  2998. {
  2999. tmStart.tm_year -= 1900;
  3000. tmStart.tm_mon -= 1;
  3001. tbStart.time = mktime(&tmStart);
  3002. tbStart.millitm = 0;
  3003. tmStop.tm_year -= 1900;
  3004. tmStop.tm_mon -= 1;
  3005. tbStop.time = mktime(&tmStop);
  3006. tbStop.millitm = 0;
  3007. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  3008. }
  3009. return result;
  3010. }
  3011. void checkChargePointMaxProfile(uint32_t durationReq, struct ChargingProfileType *compositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  3012. {
  3013. FILE *fp;
  3014. char profileFileName[128];
  3015. char *line = NULL;
  3016. size_t len = 0;
  3017. time_t CurrentTime;
  3018. struct tm *tmComposite;
  3019. struct ChargingProfileType maxProfile;
  3020. uint8_t limitMax=0;
  3021. int compositePeriodIdx = 0;
  3022. CurrentTime = time(NULL);
  3023. tmComposite=localtime(&CurrentTime);
  3024. 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);
  3025. if(isUnitA)
  3026. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3027. else
  3028. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3029. compositeProfile->chargingSchedule[idxSchedule].duration = durationReq;
  3030. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3031. {
  3032. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3033. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3034. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3035. }
  3036. compositeProfile->id = 0;
  3037. compositeProfile->stackLevel = 99 ;
  3038. sprintf((char*)compositeProfile->chargingProfileKind ,"Absolute");
  3039. maxProfile.id = -1;
  3040. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  3041. system("rm -f /tmp/*.json");
  3042. system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
  3043. // Search max profile
  3044. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  3045. if((access(profileFileName, F_OK))!=-1)
  3046. {
  3047. fp = fopen(profileFileName, "r");
  3048. while(getline(&line, &len, fp) != -1)
  3049. {
  3050. json_object *obj = NULL;
  3051. obj = json_tokener_parse(line);
  3052. if(is_error(obj))
  3053. {
  3054. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3055. }
  3056. else
  3057. {
  3058. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != maxProfile.id) &&
  3059. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= maxProfile.stackLevel)
  3060. )
  3061. {
  3062. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  3063. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3064. )
  3065. {
  3066. struct tm tmFrom, tmTo;
  3067. struct timeb tbFrom, tbTo;
  3068. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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) &&
  3069. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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))
  3070. {
  3071. tmFrom.tm_year -= 1900;
  3072. tmFrom.tm_mon -= 1;
  3073. tbFrom.time = mktime(&tmFrom);
  3074. tmTo.tm_year -= 1900;
  3075. tmTo.tm_mon -= 1;
  3076. tbTo.time = mktime(&tmTo);
  3077. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3078. {
  3079. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3080. {
  3081. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3082. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3083. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3084. }
  3085. maxProfile.id = -1;
  3086. maxProfile.stackLevel = -1;
  3087. if(maxProfile.id == -1)
  3088. DEBUG_INFO("MaxProfile found.\n");
  3089. else
  3090. DEBUG_INFO("MaxProfile updated.\n");
  3091. // Required item
  3092. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3093. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3094. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3095. if(isUnitA)
  3096. {
  3097. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3098. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3099. {
  3100. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3101. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3102. 3:
  3103. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3104. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3105. }
  3106. }
  3107. else
  3108. {
  3109. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3110. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3111. {
  3112. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3113. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3114. 3:
  3115. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3116. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3117. }
  3118. }
  3119. // Optional item
  3120. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3121. {
  3122. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3123. }
  3124. else
  3125. {
  3126. sprintf((char*)maxProfile.validFrom, " ");
  3127. }
  3128. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3129. {
  3130. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3131. }
  3132. else
  3133. {
  3134. sprintf((char*)maxProfile.validTo, " ");
  3135. }
  3136. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3137. {
  3138. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3139. }
  3140. else
  3141. {
  3142. sprintf((char*)maxProfile.recurrencyKind, " ");
  3143. }
  3144. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3145. {
  3146. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3147. }
  3148. else
  3149. {
  3150. sprintf((char*)maxProfile.transactionId, " ");
  3151. }
  3152. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  3153. {
  3154. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  3155. }
  3156. else
  3157. {
  3158. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3159. }
  3160. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  3161. {
  3162. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule")));
  3163. }
  3164. else
  3165. {
  3166. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile->chargingSchedule[idxSchedule].startSchedule);
  3167. }
  3168. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  3169. {
  3170. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  3171. }
  3172. else
  3173. {
  3174. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3175. }
  3176. }
  3177. }
  3178. }
  3179. else
  3180. {
  3181. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3182. {
  3183. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3184. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3185. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3186. }
  3187. maxProfile.id = -1;
  3188. maxProfile.stackLevel = -1;
  3189. if(maxProfile.id == -1)
  3190. DEBUG_INFO("MaxProfile found.\n");
  3191. else
  3192. DEBUG_INFO("MaxProfile updated.\n");
  3193. // Required item
  3194. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3195. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3196. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3197. if(isUnitA)
  3198. {
  3199. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3200. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3201. {
  3202. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3203. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3204. 3:
  3205. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3206. 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, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3207. }
  3208. }
  3209. else
  3210. {
  3211. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3212. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3213. {
  3214. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3215. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3216. 3:
  3217. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3218. 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, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3219. }
  3220. }
  3221. // Optional item
  3222. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3223. {
  3224. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3225. }
  3226. else
  3227. {
  3228. sprintf((char*)maxProfile.validFrom, " ");
  3229. }
  3230. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3231. {
  3232. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3233. }
  3234. else
  3235. {
  3236. sprintf((char*)maxProfile.validTo, " ");
  3237. }
  3238. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3239. {
  3240. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3241. }
  3242. else
  3243. {
  3244. sprintf((char*)maxProfile.recurrencyKind, " ");
  3245. }
  3246. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3247. {
  3248. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3249. }
  3250. else
  3251. {
  3252. sprintf((char*)maxProfile.transactionId, " ");
  3253. }
  3254. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  3255. {
  3256. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  3257. }
  3258. else
  3259. {
  3260. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3261. }
  3262. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  3263. {
  3264. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule")));
  3265. }
  3266. else
  3267. {
  3268. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile->chargingSchedule[idxSchedule].startSchedule);
  3269. }
  3270. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  3271. {
  3272. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  3273. }
  3274. else
  3275. {
  3276. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3277. }
  3278. }
  3279. }
  3280. }
  3281. json_object_put(obj);
  3282. }
  3283. fclose(fp);
  3284. /*
  3285. if(maxProfile.id !=-1)
  3286. {
  3287. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  3288. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3289. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3290. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3291. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3292. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3293. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  3294. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  3295. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3296. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3297. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3298. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3299. {
  3300. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3301. {
  3302. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3303. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3304. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3305. }
  3306. }
  3307. }
  3308. else
  3309. DEBUG_INFO("MaxProfile not found.\n");
  3310. DEBUG_INFO("------------------------------------\n");*/
  3311. }
  3312. if(maxProfile.id != -1)
  3313. {
  3314. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3315. {
  3316. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3317. {
  3318. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3319. 0:
  3320. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3321. }
  3322. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3323. {
  3324. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3325. {
  3326. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3327. 0:
  3328. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3329. if(idxPeriod > 0)
  3330. {
  3331. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3332. {
  3333. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3334. }
  3335. }
  3336. }
  3337. }
  3338. }
  3339. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3340. {
  3341. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3342. {
  3343. maxProfile.chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
  3344. }
  3345. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3346. {
  3347. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3348. {
  3349. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod;
  3350. if(idxPeriod > 0)
  3351. {
  3352. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3353. {
  3354. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3355. }
  3356. }
  3357. }
  3358. }
  3359. }
  3360. else
  3361. {
  3362. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3363. {
  3364. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3365. {
  3366. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3367. 0:
  3368. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3369. }
  3370. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3371. {
  3372. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3373. {
  3374. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3375. 0:
  3376. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3377. if(idxPeriod > 0)
  3378. {
  3379. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3380. {
  3381. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3382. }
  3383. }
  3384. }
  3385. }
  3386. }
  3387. else
  3388. {
  3389. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3390. {
  3391. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3392. 0:
  3393. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3394. }
  3395. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3396. {
  3397. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3398. {
  3399. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3400. 0:
  3401. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3402. if(idxPeriod > 0)
  3403. {
  3404. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3405. {
  3406. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3407. }
  3408. }
  3409. }
  3410. }
  3411. }
  3412. }
  3413. /*
  3414. DEBUG_INFO("MaxProfile after align.\n");
  3415. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  3416. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3417. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3418. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3419. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3420. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3421. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  3422. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3423. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3424. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3425. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3426. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3427. {
  3428. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3429. {
  3430. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3431. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3432. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3433. }
  3434. }
  3435. DEBUG_INFO("------------------------------------\n");*/
  3436. }
  3437. // Find each profile period quantity
  3438. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  3439. {
  3440. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  3441. limitMax = idx+1;
  3442. }
  3443. if(maxProfile.id != -1)
  3444. {
  3445. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3446. {
  3447. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3448. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3449. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  3450. {
  3451. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3452. {
  3453. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3454. compositePeriodIdx++;
  3455. }
  3456. else
  3457. {
  3458. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3459. }
  3460. }
  3461. }
  3462. }
  3463. DEBUG_INFO("ChargePointMaxProfile ready.\n");
  3464. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[idxSchedule].startSchedule);
  3465. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[idxSchedule].duration);
  3466. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit);
  3467. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3468. {
  3469. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  3470. {
  3471. compositeProfile->id = 1;
  3472. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  3473. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  3474. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  3475. }
  3476. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  3477. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  3478. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  3479. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  3480. }
  3481. if(line)
  3482. free(line);
  3483. }
  3484. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  3485. {
  3486. FILE *fp;
  3487. char profileFileName[128];
  3488. char *line = NULL;
  3489. size_t len = 0;
  3490. time_t CurrentTime;
  3491. struct tm *tmComposite;
  3492. struct ChargingProfileType maxProfile;
  3493. struct ChargingProfileType defaultTxProfile;
  3494. struct ChargingProfileType txProfile;
  3495. struct ChargingSchedulePeriodType tmpPeriod;
  3496. uint8_t limitMax=0;
  3497. uint8_t limitDef=0;
  3498. uint8_t limitTx=0;
  3499. int compositePeriodIdx = 0;
  3500. CurrentTime = time(NULL);
  3501. tmComposite=localtime(&CurrentTime);
  3502. 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);
  3503. if(isUnitA)
  3504. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3505. else
  3506. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3507. compositeProfile->chargingSchedule[idxSchedule].duration = durationReq;
  3508. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3509. {
  3510. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3511. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3512. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3513. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  3514. }
  3515. compositeProfile->id = 0;
  3516. compositeProfile->stackLevel = 99 ;
  3517. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  3518. maxProfile.id = -1;
  3519. defaultTxProfile.id = -1;
  3520. txProfile.id = -1;
  3521. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  3522. defaultTxProfile.chargingSchedule[idxSchedule].duration = -1;
  3523. txProfile.chargingSchedule[idxSchedule].duration = -1;
  3524. system("rm -f /tmp/*.json");
  3525. system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
  3526. /*
  3527. * Search valid charging profile
  3528. */
  3529. //DEBUG_INFO("====================================\n");
  3530. // Search tx profile
  3531. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  3532. if((access(profileFileName, F_OK))!=-1)
  3533. {
  3534. fp = fopen(profileFileName, "r");
  3535. while(getline(&line, &len, fp) != -1)
  3536. {
  3537. json_object *obj = NULL;
  3538. obj = json_tokener_parse(line);
  3539. if(is_error(obj))
  3540. {
  3541. DEBUG_ERROR("Parse txProfile from file error.\n");
  3542. }
  3543. else
  3544. {
  3545. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != txProfile.id) &&
  3546. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= txProfile.stackLevel)
  3547. )
  3548. {
  3549. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  3550. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3551. )
  3552. {
  3553. struct tm tmFrom, tmTo;
  3554. struct timeb tbFrom, tbTo;
  3555. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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) &&
  3556. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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))
  3557. {
  3558. tmFrom.tm_year -= 1900;
  3559. tmFrom.tm_mon -= 1;
  3560. tbFrom.time = mktime(&tmFrom);
  3561. tmTo.tm_year -= 1900;
  3562. tmTo.tm_mon -= 1;
  3563. tbTo.time = mktime(&tmTo);
  3564. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3565. {
  3566. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3567. {
  3568. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3569. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3570. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3571. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3572. }
  3573. txProfile.id = -1;
  3574. txProfile.stackLevel = -1;
  3575. if(txProfile.id == -1)
  3576. DEBUG_INFO("TxProfile found.\n");
  3577. else
  3578. DEBUG_INFO("TxProfile updated.\n");
  3579. // Required item
  3580. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3581. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3582. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3583. if(isUnitA)
  3584. {
  3585. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3586. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3587. {
  3588. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3589. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3590. 3:
  3591. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3592. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3593. }
  3594. }
  3595. else
  3596. {
  3597. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3598. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3599. {
  3600. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3601. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3602. 3:
  3603. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3604. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3605. }
  3606. }
  3607. // Optional item
  3608. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3609. {
  3610. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3611. }
  3612. else
  3613. {
  3614. sprintf((char*)txProfile.validFrom, " ");
  3615. }
  3616. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3617. {
  3618. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3619. }
  3620. else
  3621. {
  3622. sprintf((char*)txProfile.validTo, " ");
  3623. }
  3624. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3625. {
  3626. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3627. }
  3628. else
  3629. {
  3630. sprintf((char*)txProfile.recurrencyKind, " ");
  3631. }
  3632. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3633. {
  3634. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3635. }
  3636. else
  3637. {
  3638. sprintf((char*)txProfile.transactionId, " ");
  3639. }
  3640. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  3641. {
  3642. txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  3643. }
  3644. else
  3645. {
  3646. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  3647. }
  3648. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  3649. {
  3650. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule")));
  3651. }
  3652. else
  3653. {
  3654. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3655. }
  3656. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  3657. {
  3658. txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  3659. }
  3660. else
  3661. {
  3662. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3663. }
  3664. }
  3665. }
  3666. }
  3667. else
  3668. {
  3669. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3670. {
  3671. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3672. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3673. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3674. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3675. }
  3676. txProfile.id = -1;
  3677. txProfile.stackLevel = -1;
  3678. if(txProfile.id == -1)
  3679. DEBUG_INFO("TxProfile found.\n");
  3680. else
  3681. DEBUG_INFO("TxProfile updated.\n");
  3682. // Required item
  3683. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3684. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3685. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3686. if(isUnitA)
  3687. {
  3688. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3689. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3690. {
  3691. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3692. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3693. 3:
  3694. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3695. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3696. }
  3697. }
  3698. else
  3699. {
  3700. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3701. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3702. {
  3703. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3704. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3705. 3:
  3706. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3707. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3708. }
  3709. }
  3710. // Optional item
  3711. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3712. {
  3713. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3714. }
  3715. else
  3716. {
  3717. sprintf((char*)txProfile.validFrom, " ");
  3718. }
  3719. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3720. {
  3721. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3722. }
  3723. else
  3724. {
  3725. sprintf((char*)txProfile.validTo, " ");
  3726. }
  3727. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3728. {
  3729. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3730. }
  3731. else
  3732. {
  3733. sprintf((char*)txProfile.recurrencyKind, " ");
  3734. }
  3735. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3736. {
  3737. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3738. }
  3739. else
  3740. {
  3741. sprintf((char*)txProfile.transactionId, " ");
  3742. }
  3743. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  3744. {
  3745. txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  3746. }
  3747. else
  3748. {
  3749. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  3750. }
  3751. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  3752. {
  3753. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule")));
  3754. }
  3755. else
  3756. {
  3757. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3758. }
  3759. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  3760. {
  3761. txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  3762. }
  3763. else
  3764. {
  3765. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3766. }
  3767. }
  3768. }
  3769. }
  3770. json_object_put(obj);
  3771. }
  3772. fclose(fp);
  3773. /*
  3774. if(txProfile.id != -1)
  3775. {
  3776. DEBUG_INFO("Profile ID: %d\n", txProfile.id);
  3777. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3778. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3779. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3780. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3781. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3782. DEBUG_INFO("Profile recurrencyKind: %s\n", txProfile.recurrencyKind);
  3783. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[idxSchedule].StartSchedule);
  3784. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  3785. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3786. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3787. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3788. {
  3789. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3790. {
  3791. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3792. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3793. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3794. }
  3795. }
  3796. }
  3797. else
  3798. DEBUG_INFO("TxProfile not found.\n");*/
  3799. }
  3800. // Search default tx profile
  3801. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  3802. if((access(profileFileName, F_OK))==-1)
  3803. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  3804. if((access(profileFileName, F_OK))!=-1)
  3805. {
  3806. fp = fopen(profileFileName, "r");
  3807. while(getline(&line, &len, fp) != -1)
  3808. {
  3809. json_object *obj = NULL;
  3810. obj = json_tokener_parse(line);
  3811. if(is_error(obj))
  3812. {
  3813. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  3814. }
  3815. else
  3816. {
  3817. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != defaultTxProfile.id) &&
  3818. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= defaultTxProfile.stackLevel)
  3819. )
  3820. {
  3821. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  3822. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3823. )
  3824. {
  3825. struct tm tmFrom, tmTo;
  3826. struct timeb tbFrom, tbTo;
  3827. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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) &&
  3828. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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))
  3829. {
  3830. tmFrom.tm_year -= 1900;
  3831. tmFrom.tm_mon -= 1;
  3832. tbFrom.time = mktime(&tmFrom);
  3833. tmTo.tm_year -= 1900;
  3834. tmTo.tm_mon -= 1;
  3835. tbTo.time = mktime(&tmTo);
  3836. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3837. {
  3838. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3839. {
  3840. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3841. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3842. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3843. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3844. }
  3845. defaultTxProfile.id = -1;
  3846. defaultTxProfile.stackLevel = -1;
  3847. if(defaultTxProfile.id == -1)
  3848. DEBUG_INFO("TxDefaultProfile found.\n");
  3849. else
  3850. DEBUG_INFO("TxDefaultProfile updated.\n");
  3851. // Required item
  3852. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3853. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3854. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3855. if(isUnitA)
  3856. {
  3857. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3858. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3859. {
  3860. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3861. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3862. 3:
  3863. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3864. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3865. }
  3866. }
  3867. else
  3868. {
  3869. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3870. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3871. {
  3872. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3873. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3874. 3:
  3875. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3876. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3877. }
  3878. }
  3879. // Optional item
  3880. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3881. {
  3882. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3883. }
  3884. else
  3885. {
  3886. sprintf((char*)defaultTxProfile.validFrom, " ");
  3887. }
  3888. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3889. {
  3890. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3891. }
  3892. else
  3893. {
  3894. sprintf((char*)defaultTxProfile.validTo, " ");
  3895. }
  3896. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3897. {
  3898. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3899. }
  3900. else
  3901. {
  3902. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3903. }
  3904. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3905. {
  3906. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3907. }
  3908. else
  3909. {
  3910. sprintf((char*)defaultTxProfile.transactionId, " ");
  3911. }
  3912. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  3913. {
  3914. defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  3915. }
  3916. else
  3917. {
  3918. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3919. }
  3920. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  3921. {
  3922. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule")));
  3923. }
  3924. else
  3925. {
  3926. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3927. }
  3928. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  3929. {
  3930. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  3931. }
  3932. else
  3933. {
  3934. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3935. }
  3936. }
  3937. }
  3938. }
  3939. else
  3940. {
  3941. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3942. {
  3943. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3944. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3945. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3946. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3947. }
  3948. defaultTxProfile.id = -1;
  3949. defaultTxProfile.stackLevel = -1;
  3950. if(defaultTxProfile.id == -1)
  3951. DEBUG_INFO("TxDefaultProfile found.\n");
  3952. else
  3953. DEBUG_INFO("TxDefaultProfile updated.\n");
  3954. // Required item
  3955. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3956. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3957. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3958. if(isUnitA)
  3959. {
  3960. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3961. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3962. {
  3963. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3964. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3965. 3:
  3966. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3967. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3968. }
  3969. }
  3970. else
  3971. {
  3972. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3973. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3974. {
  3975. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3976. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3977. 3:
  3978. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3979. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3980. }
  3981. }
  3982. // Optional item
  3983. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3984. {
  3985. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3986. }
  3987. else
  3988. {
  3989. sprintf((char*)defaultTxProfile.validFrom, " ");
  3990. }
  3991. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3992. {
  3993. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3994. }
  3995. else
  3996. {
  3997. sprintf((char*)defaultTxProfile.validTo, " ");
  3998. }
  3999. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4000. {
  4001. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4002. }
  4003. else
  4004. {
  4005. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  4006. }
  4007. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4008. {
  4009. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4010. }
  4011. else
  4012. {
  4013. sprintf((char*)defaultTxProfile.transactionId, " ");
  4014. }
  4015. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  4016. {
  4017. defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  4018. }
  4019. else
  4020. {
  4021. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4022. }
  4023. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  4024. {
  4025. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule")));
  4026. }
  4027. else
  4028. {
  4029. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  4030. }
  4031. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  4032. {
  4033. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  4034. }
  4035. else
  4036. {
  4037. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4038. }
  4039. }
  4040. }
  4041. }
  4042. json_object_put(obj);
  4043. }
  4044. fclose(fp);
  4045. /*
  4046. if(defaultTxProfile.id != -1)
  4047. {
  4048. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.id);
  4049. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  4050. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  4051. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  4052. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  4053. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  4054. DEBUG_INFO("Profile recurrencyKind: %s\n", defaultTxProfile.recurrencyKind);
  4055. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].StartSchedule);
  4056. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  4057. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4058. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4059. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4060. {
  4061. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4062. {
  4063. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4064. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4065. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4066. }
  4067. }
  4068. }
  4069. else
  4070. DEBUG_INFO("TxDefaultProfile not found.\n");
  4071. DEBUG_INFO("------------------------------------\n");*/
  4072. }
  4073. // Search max profile
  4074. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  4075. if((access(profileFileName, F_OK))!=-1)
  4076. {
  4077. fp = fopen(profileFileName, "r");
  4078. while(getline(&line, &len, fp) != -1)
  4079. {
  4080. json_object *obj = NULL;
  4081. obj = json_tokener_parse(line);
  4082. if(is_error(obj))
  4083. {
  4084. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  4085. }
  4086. else
  4087. {
  4088. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != maxProfile.id) &&
  4089. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= maxProfile.stackLevel)
  4090. )
  4091. {
  4092. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  4093. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4094. )
  4095. {
  4096. struct tm tmFrom, tmTo;
  4097. struct timeb tbFrom, tbTo;
  4098. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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) &&
  4099. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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))
  4100. {
  4101. tmFrom.tm_year -= 1900;
  4102. tmFrom.tm_mon -= 1;
  4103. tbFrom.time = mktime(&tmFrom);
  4104. tmTo.tm_year -= 1900;
  4105. tmTo.tm_mon -= 1;
  4106. tbTo.time = mktime(&tmTo);
  4107. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  4108. {
  4109. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4110. {
  4111. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4112. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4113. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4114. }
  4115. maxProfile.id = -1;
  4116. maxProfile.stackLevel = -1;
  4117. if(maxProfile.id == -1)
  4118. DEBUG_INFO("MaxProfile found.\n");
  4119. else
  4120. DEBUG_INFO("MaxProfile updated.\n");
  4121. // Required item
  4122. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4123. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4124. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4125. if(isUnitA)
  4126. {
  4127. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4128. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  4129. {
  4130. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4131. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4132. 3:
  4133. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4134. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  4135. }
  4136. }
  4137. else
  4138. {
  4139. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4140. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  4141. {
  4142. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4143. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4144. 3:
  4145. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4146. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  4147. }
  4148. }
  4149. // Optional item
  4150. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4151. {
  4152. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4153. }
  4154. else
  4155. {
  4156. sprintf((char*)maxProfile.validFrom, " ");
  4157. }
  4158. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4159. {
  4160. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4161. }
  4162. else
  4163. {
  4164. sprintf((char*)maxProfile.validTo, " ");
  4165. }
  4166. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4167. {
  4168. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4169. }
  4170. else
  4171. {
  4172. sprintf((char*)maxProfile.recurrencyKind, " ");
  4173. }
  4174. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4175. {
  4176. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4177. }
  4178. else
  4179. {
  4180. sprintf((char*)maxProfile.transactionId, " ");
  4181. }
  4182. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  4183. {
  4184. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  4185. }
  4186. else
  4187. {
  4188. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4189. }
  4190. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  4191. {
  4192. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule")));
  4193. }
  4194. else
  4195. {
  4196. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  4197. }
  4198. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  4199. {
  4200. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  4201. }
  4202. else
  4203. {
  4204. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4205. }
  4206. }
  4207. }
  4208. }
  4209. else
  4210. {
  4211. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4212. {
  4213. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4214. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4215. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4216. }
  4217. maxProfile.id = -1;
  4218. maxProfile.stackLevel = -1;
  4219. if(maxProfile.id == -1)
  4220. DEBUG_INFO("MaxProfile found.\n");
  4221. else
  4222. DEBUG_INFO("MaxProfile updated.\n");
  4223. // Required item
  4224. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4225. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4226. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4227. if(isUnitA)
  4228. {
  4229. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4230. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  4231. {
  4232. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4233. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4234. 3:
  4235. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4236. 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, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  4237. }
  4238. }
  4239. else
  4240. {
  4241. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4242. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  4243. {
  4244. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4245. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4246. 3:
  4247. 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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4248. 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, "chargingProfile"), "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, "chargingProfile"), "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, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  4249. }
  4250. }
  4251. // Optional item
  4252. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4253. {
  4254. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4255. }
  4256. else
  4257. {
  4258. sprintf((char*)maxProfile.validFrom, " ");
  4259. }
  4260. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4261. {
  4262. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4263. }
  4264. else
  4265. {
  4266. sprintf((char*)maxProfile.validTo, " ");
  4267. }
  4268. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4269. {
  4270. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4271. }
  4272. else
  4273. {
  4274. sprintf((char*)maxProfile.recurrencyKind, " ");
  4275. }
  4276. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4277. {
  4278. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4279. }
  4280. else
  4281. {
  4282. sprintf((char*)maxProfile.transactionId, " ");
  4283. }
  4284. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  4285. {
  4286. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  4287. }
  4288. else
  4289. {
  4290. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4291. }
  4292. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  4293. {
  4294. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule")));
  4295. }
  4296. else
  4297. {
  4298. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  4299. }
  4300. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  4301. {
  4302. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  4303. }
  4304. else
  4305. {
  4306. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4307. }
  4308. }
  4309. }
  4310. }
  4311. json_object_put(obj);
  4312. }
  4313. fclose(fp);
  4314. /*
  4315. if(maxProfile.id !=-1)
  4316. {
  4317. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  4318. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  4319. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  4320. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  4321. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  4322. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  4323. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  4324. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  4325. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  4326. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4327. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4328. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4329. {
  4330. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4331. {
  4332. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4333. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4334. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4335. }
  4336. }
  4337. }
  4338. else
  4339. DEBUG_INFO("MaxProfile not found.\n");
  4340. DEBUG_INFO("------------------------------------\n");*/
  4341. }
  4342. /*
  4343. * Align found profile start schedule & periods
  4344. */
  4345. //DEBUG_INFO("====================================\n");
  4346. /*
  4347. // For local test usage, force modify found profile start schedule info
  4348. 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);
  4349. 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);
  4350. 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);
  4351. */
  4352. if(txProfile.id != -1)
  4353. {
  4354. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4355. {
  4356. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4357. {
  4358. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4359. 0:
  4360. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4361. }
  4362. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4363. {
  4364. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4365. {
  4366. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4367. 0:
  4368. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4369. if(idxPeriod > 0)
  4370. {
  4371. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4372. {
  4373. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4374. }
  4375. }
  4376. }
  4377. }
  4378. }
  4379. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4380. {
  4381. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4382. {
  4383. txProfile.chargingSchedule[idxSchedule].duration = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?txProfile.chargingSchedule[idxSchedule].duration:((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4384. 0:
  4385. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4386. }
  4387. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4388. {
  4389. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4390. {
  4391. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?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?
  4392. 0:
  4393. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4394. if(idxPeriod > 0)
  4395. {
  4396. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4397. {
  4398. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4399. }
  4400. }
  4401. }
  4402. }
  4403. }
  4404. else
  4405. {
  4406. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4407. {
  4408. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4409. {
  4410. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4411. 0:
  4412. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4413. }
  4414. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4415. {
  4416. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4417. {
  4418. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4419. 0:
  4420. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4421. if(idxPeriod > 0)
  4422. {
  4423. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4424. {
  4425. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4426. }
  4427. }
  4428. }
  4429. }
  4430. }
  4431. else
  4432. {
  4433. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4434. {
  4435. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4436. 0:
  4437. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4438. }
  4439. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4440. {
  4441. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4442. {
  4443. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4444. 0:
  4445. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4446. if(idxPeriod > 0)
  4447. {
  4448. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4449. {
  4450. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4451. }
  4452. }
  4453. }
  4454. }
  4455. }
  4456. }
  4457. /*
  4458. DEBUG_INFO("txProfile after align.\n");
  4459. DEBUG_INFO("Profile ID: %d\n", txProfile.id);
  4460. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  4461. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  4462. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  4463. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  4464. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  4465. DEBUG_INFO("Profile recurrencyKind: %s\n", txProfile.recurrencyKind);
  4466. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  4467. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  4468. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4469. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4470. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4471. {
  4472. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4473. {
  4474. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4475. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4476. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4477. }
  4478. }*/
  4479. }
  4480. if(defaultTxProfile.id != -1)
  4481. {
  4482. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4483. {
  4484. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4485. {
  4486. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4487. 0:
  4488. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4489. }
  4490. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4491. {
  4492. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4493. {
  4494. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4495. 0:
  4496. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4497. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4498. {
  4499. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4500. }
  4501. if(idxPeriod > 0)
  4502. {
  4503. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4504. {
  4505. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4506. }
  4507. }
  4508. }
  4509. }
  4510. }
  4511. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4512. {
  4513. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4514. {
  4515. defaultTxProfile.chargingSchedule[idxSchedule].duration = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?defaultTxProfile.chargingSchedule[idxSchedule].duration:((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4516. 0:
  4517. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4518. }
  4519. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4520. {
  4521. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4522. {
  4523. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?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?
  4524. 0:
  4525. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4526. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4527. {
  4528. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4529. }
  4530. if(idxPeriod > 0)
  4531. {
  4532. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4533. {
  4534. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4535. }
  4536. }
  4537. }
  4538. }
  4539. }
  4540. else
  4541. {
  4542. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4543. {
  4544. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4545. {
  4546. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4547. 0:
  4548. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4549. }
  4550. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4551. {
  4552. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4553. {
  4554. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4555. 0:
  4556. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4557. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4558. {
  4559. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4560. }
  4561. if(idxPeriod > 0)
  4562. {
  4563. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4564. {
  4565. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4566. }
  4567. }
  4568. }
  4569. }
  4570. }
  4571. else
  4572. {
  4573. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4574. {
  4575. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4576. 0:
  4577. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4578. }
  4579. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4580. {
  4581. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4582. {
  4583. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4584. 0:
  4585. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4586. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4587. {
  4588. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4589. }
  4590. if(idxPeriod > 0)
  4591. {
  4592. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4593. {
  4594. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4595. }
  4596. }
  4597. }
  4598. }
  4599. }
  4600. }
  4601. /*
  4602. DEBUG_INFO("defaultTxProfile after align.\n");
  4603. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.id);
  4604. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  4605. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  4606. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  4607. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  4608. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  4609. DEBUG_INFO("Profile recurrencyKind: %s\n", defaultTxProfile.recurrencyKind);
  4610. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  4611. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  4612. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4613. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4614. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4615. {
  4616. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4617. {
  4618. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4619. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4620. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4621. }
  4622. }
  4623. DEBUG_INFO("------------------------------------\n");*/
  4624. }
  4625. if(maxProfile.id != -1)
  4626. {
  4627. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4628. {
  4629. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4630. {
  4631. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4632. 0:
  4633. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4634. }
  4635. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4636. {
  4637. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4638. {
  4639. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4640. 0:
  4641. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4642. if(idxPeriod > 0)
  4643. {
  4644. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4645. {
  4646. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4647. }
  4648. }
  4649. }
  4650. }
  4651. }
  4652. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4653. {
  4654. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4655. {
  4656. maxProfile.chargingSchedule[idxSchedule].duration = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?maxProfile.chargingSchedule[idxSchedule].duration:((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4657. 0:
  4658. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  4659. }
  4660. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4661. {
  4662. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4663. {
  4664. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?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?
  4665. 0:
  4666. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4667. if(idxPeriod > 0)
  4668. {
  4669. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4670. {
  4671. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4672. }
  4673. }
  4674. }
  4675. }
  4676. }
  4677. else
  4678. {
  4679. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4680. {
  4681. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4682. {
  4683. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4684. 0:
  4685. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4686. }
  4687. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4688. {
  4689. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4690. {
  4691. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4692. 0:
  4693. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4694. if(idxPeriod > 0)
  4695. {
  4696. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4697. {
  4698. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4699. }
  4700. }
  4701. }
  4702. }
  4703. }
  4704. else
  4705. {
  4706. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4707. {
  4708. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4709. 0:
  4710. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4711. }
  4712. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4713. {
  4714. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4715. {
  4716. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4717. 0:
  4718. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4719. if(idxPeriod > 0)
  4720. {
  4721. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4722. {
  4723. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4724. }
  4725. }
  4726. }
  4727. }
  4728. }
  4729. }
  4730. /*
  4731. DEBUG_INFO("MaxProfile after align.\n");
  4732. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  4733. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  4734. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  4735. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  4736. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  4737. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  4738. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  4739. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  4740. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  4741. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4742. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4743. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4744. {
  4745. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4746. {
  4747. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4748. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4749. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4750. }
  4751. }
  4752. DEBUG_INFO("------------------------------------\n");*/
  4753. }
  4754. /*
  4755. * Merge to conposite schedule
  4756. */
  4757. //DEBUG_INFO("====================================\n");
  4758. // Find each profile period quantity
  4759. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4760. {
  4761. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4762. limitMax = idx+1;
  4763. }
  4764. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4765. {
  4766. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4767. limitDef = idx+1;
  4768. }
  4769. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4770. {
  4771. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4772. limitTx = idx+1;
  4773. }
  4774. // TxProfile found, composite schedule based on it
  4775. if(txProfile.id != -1)
  4776. {
  4777. compositeProfile->chargingSchedule[idxSchedule].duration = txProfile.chargingSchedule[idxSchedule].duration;
  4778. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  4779. {
  4780. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  4781. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  4782. (txProfile.chargingSchedule[idxSchedule].duration > 0))
  4783. {
  4784. if(maxProfile.id != -1)
  4785. {
  4786. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4787. {
  4788. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  4789. {
  4790. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4791. {
  4792. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  4793. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  4794. 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);
  4795. }
  4796. else
  4797. {
  4798. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  4799. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  4800. tmpPeriod.limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit;
  4801. }
  4802. }
  4803. if(idxMaxPeriod == (limitMax-1))
  4804. {
  4805. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4806. {
  4807. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4808. {
  4809. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4810. compositePeriodIdx++;
  4811. }
  4812. else
  4813. {
  4814. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4815. }
  4816. }
  4817. }
  4818. }
  4819. }
  4820. else
  4821. {
  4822. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4823. {
  4824. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  4825. compositePeriodIdx++;
  4826. }
  4827. else
  4828. {
  4829. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  4830. }
  4831. }
  4832. }
  4833. if(idxTxPeriod == (limitTx-1))
  4834. {
  4835. if(defaultTxProfile.id != -1)
  4836. {
  4837. compositeProfile->chargingSchedule[idxSchedule].duration = (defaultTxProfile.chargingSchedule[idxSchedule].duration>compositeProfile->chargingSchedule[idxSchedule].duration)?defaultTxProfile.chargingSchedule[idxSchedule].duration:compositeProfile->chargingSchedule[idxSchedule].duration;
  4838. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  4839. {
  4840. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  4841. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  4842. (defaultTxProfile.chargingSchedule[idxSchedule].duration>0))
  4843. {
  4844. if(maxProfile.id != -1)
  4845. {
  4846. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4847. {
  4848. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  4849. {
  4850. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4851. {
  4852. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4853. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4854. 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);
  4855. }
  4856. else
  4857. {
  4858. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4859. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4860. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  4861. }
  4862. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4863. {
  4864. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4865. {
  4866. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4867. compositePeriodIdx++;
  4868. }
  4869. else
  4870. {
  4871. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4872. }
  4873. }
  4874. // Delete duplicate period
  4875. if(compositePeriodIdx > 1)
  4876. {
  4877. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  4878. {
  4879. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  4880. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  4881. compositePeriodIdx -= 1;
  4882. }
  4883. }
  4884. }
  4885. else
  4886. {
  4887. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4888. {
  4889. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4890. compositePeriodIdx++;
  4891. }
  4892. else
  4893. {
  4894. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4895. }
  4896. break;
  4897. }
  4898. }
  4899. }
  4900. else
  4901. {
  4902. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4903. {
  4904. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4905. compositePeriodIdx++;
  4906. }
  4907. else
  4908. {
  4909. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4910. }
  4911. }
  4912. }
  4913. }
  4914. }
  4915. }
  4916. }
  4917. }
  4918. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  4919. else if(defaultTxProfile.id != -1)
  4920. {
  4921. compositeProfile->chargingSchedule[idxSchedule].duration = defaultTxProfile.chargingSchedule[idxSchedule].duration;
  4922. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  4923. {
  4924. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  4925. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  4926. (defaultTxProfile.chargingSchedule[idxSchedule].duration > 0))
  4927. {
  4928. if(maxProfile.id != -1)
  4929. {
  4930. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4931. {
  4932. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  4933. {
  4934. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4935. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4936. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4937. {
  4938. 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);
  4939. }
  4940. else
  4941. {
  4942. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  4943. }
  4944. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4945. {
  4946. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4947. {
  4948. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4949. compositePeriodIdx++;
  4950. }
  4951. else
  4952. {
  4953. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4954. }
  4955. }
  4956. // Delete duplicate period
  4957. if(compositePeriodIdx > 1)
  4958. {
  4959. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  4960. {
  4961. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  4962. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  4963. compositePeriodIdx -= 1;
  4964. }
  4965. }
  4966. }
  4967. else
  4968. {
  4969. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4970. {
  4971. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4972. compositePeriodIdx++;
  4973. }
  4974. else
  4975. {
  4976. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4977. }
  4978. break;
  4979. }
  4980. }
  4981. }
  4982. else
  4983. {
  4984. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4985. {
  4986. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4987. compositePeriodIdx++;
  4988. }
  4989. else
  4990. {
  4991. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4992. }
  4993. }
  4994. }
  4995. }
  4996. }
  4997. // Fill other period by MaxProfile
  4998. if(maxProfile.id != -1)
  4999. {
  5000. if(compositePeriodIdx==0)
  5001. {
  5002. compositeProfile->chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
  5003. for(int idxMaxPeriod=0;idxMaxPeriod<limitDef;idxMaxPeriod++)
  5004. {
  5005. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  5006. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  5007. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5008. {
  5009. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5010. {
  5011. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
  5012. compositePeriodIdx++;
  5013. }
  5014. else
  5015. {
  5016. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
  5017. }
  5018. }
  5019. }
  5020. }
  5021. else
  5022. {
  5023. int lastCompositePeriodIdx = compositePeriodIdx;
  5024. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  5025. {
  5026. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  5027. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  5028. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5029. {
  5030. if((maxProfile.chargingSchedule[idxSchedule].duration >= compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod))
  5031. {
  5032. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit > compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit)
  5033. {
  5034. tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
  5035. tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  5036. tmpPeriod.limit = compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit;
  5037. }
  5038. else
  5039. {
  5040. tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
  5041. tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  5042. tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
  5043. }
  5044. }
  5045. if(tmpPeriod.limit != -1)
  5046. {
  5047. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].limit)
  5048. {
  5049. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].startPeriod)
  5050. {
  5051. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5052. compositePeriodIdx++;
  5053. }
  5054. else
  5055. {
  5056. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5057. }
  5058. }
  5059. // Delete duplicate period
  5060. if(compositePeriodIdx > 1)
  5061. {
  5062. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  5063. {
  5064. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  5065. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  5066. compositePeriodIdx -= 1;
  5067. }
  5068. }
  5069. }
  5070. }
  5071. }
  5072. }
  5073. }
  5074. compositeProfile->chargingSchedule[idxSchedule].duration = durationReq;
  5075. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  5076. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[idxSchedule].startSchedule);
  5077. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[idxSchedule].duration);
  5078. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit);
  5079. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5080. {
  5081. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  5082. {
  5083. compositeProfile->id = 1;
  5084. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  5085. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  5086. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  5087. }
  5088. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  5089. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  5090. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  5091. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  5092. }
  5093. if(line)
  5094. free(line);
  5095. checkChargePointMaxProfile(durationReq, &ShmOCPP20Data->MaxChargingProfile, idxSchedule, isUnitA);
  5096. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  5097. }
  5098. //==========================================
  5099. // Init all share memory
  5100. //==========================================
  5101. int InitShareMemory()
  5102. {
  5103. int result = PASS;
  5104. int MeterSMId;
  5105. //creat ShmSysConfigAndInfo
  5106. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  5107. {
  5108. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  5109. result = FAIL;
  5110. }
  5111. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5112. {
  5113. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  5114. result = FAIL;
  5115. }
  5116. else
  5117. {}
  5118. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  5119. {
  5120. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  5121. result = FAIL;
  5122. }
  5123. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5124. {
  5125. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  5126. result = FAIL;
  5127. }
  5128. else
  5129. {}
  5130. //creat ShmPsuData
  5131. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  5132. {
  5133. DEBUG_ERROR("shmget ShmPsuData NG\n");
  5134. result = FAIL;
  5135. }
  5136. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5137. {
  5138. DEBUG_ERROR("shmat ShmPsuData NG\n");
  5139. result = FAIL;
  5140. }
  5141. else
  5142. {}
  5143. //creat ShmOCPP20Data
  5144. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  5145. {
  5146. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  5147. result = FAIL;
  5148. }
  5149. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5150. {
  5151. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  5152. result = FAIL;
  5153. }
  5154. else
  5155. {}
  5156. /****************************** For Initial Settings************************************************/
  5157. /*
  5158. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  5159. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  5160. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  5161. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  5162. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  5163. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  5164. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  5165. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  5166. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  5167. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  5168. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  5169. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  5170. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  5171. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  5172. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  5173. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  5174. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  5175. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  5176. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  5177. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  5178. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  5179. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  5180. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  5181. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  5182. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  5183. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  5184. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  5185. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  5186. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  5187. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  5188. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  5189. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  5190. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  5191. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  5192. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  5193. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  5194. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  5195. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  5196. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  5197. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  5198. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  5199. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  5200. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  5201. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  5202. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  5203. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  5204. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  5205. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  5206. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  5207. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  5208. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  5209. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  5210. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  5211. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  5212. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  5213. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  5214. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  5215. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  5216. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  5217. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  5218. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  5219. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  5220. */
  5221. return result;
  5222. }
  5223. int ProcessShareMemory()
  5224. {
  5225. if(InitShareMemory() == FAIL)
  5226. {
  5227. DEBUG_ERROR("InitShareMemory NG\n");
  5228. if(ShmStatusCodeData!=NULL)
  5229. {
  5230. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  5231. }
  5232. sleep(5);
  5233. return FAIL;
  5234. }
  5235. return PASS;
  5236. }
  5237. //---------------------common routine---------------------------//
  5238. void checkNetworkProfile(void)
  5239. {
  5240. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  5241. json_object *priority;
  5242. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  5243. if(!is_error(priority))
  5244. {
  5245. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  5246. {
  5247. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  5248. {
  5249. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  5250. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  5251. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  5252. {
  5253. memcpy(ShmOCPP20Data->OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  5254. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  5255. break;
  5256. }
  5257. }
  5258. }
  5259. }
  5260. json_object_put(priority);
  5261. DEBUG_INFO("Get network profile URL: %s\n", ShmOCPP20Data->OcppServerURL);
  5262. }
  5263. void CheckSystemValue(void)
  5264. {
  5265. char filenmae[100]={0};
  5266. char str[100]={0};
  5267. int tempIndex = 0;
  5268. //===============================
  5269. // EVSE operation check
  5270. //===============================
  5271. //===============================
  5272. // Heartbeat check
  5273. //===============================
  5274. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  5275. {
  5276. clientTime.Heartbeat = time((time_t*)NULL);
  5277. if(server_sign == TRUE)
  5278. {
  5279. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  5280. }
  5281. else
  5282. {
  5283. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  5284. }
  5285. }
  5286. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  5287. {
  5288. //parameter for test
  5289. sendHeartbeatRequest(0);
  5290. //==============================================
  5291. // Reset Waiting Time
  5292. //==============================================
  5293. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  5294. }
  5295. //===============================
  5296. // CSU Trigger Authorize Request
  5297. //===============================
  5298. if(isWebsocketSendable &&
  5299. (server_sign == TRUE) &&
  5300. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  5301. (authorizeRetryTimes < 3))
  5302. {
  5303. sendAuthorizeRequest(0);
  5304. authorizeRetryTimes = authorizeRetryTimes + 1;
  5305. if(authorizeRetryTimes < 3)
  5306. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5307. }
  5308. else if((server_sign == TRUE) &&
  5309. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  5310. (authorizeRetryTimes >= 3))
  5311. {
  5312. authorizeRetryTimes = 0;
  5313. SetOcppConnStatus(FALSE);
  5314. server_sign = FALSE;
  5315. }
  5316. else if((server_sign == FALSE) &&
  5317. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  5318. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  5319. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  5320. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  5321. {
  5322. sendAuthorizeRequest(0);
  5323. }
  5324. if(isWebsocketSendable &&
  5325. (server_sign == TRUE) &&
  5326. (ShmOCPP20Data->GetMonitoringReport.requestId > 0))
  5327. {
  5328. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.monitoringCriteria);idxCriterion++)
  5329. {
  5330. if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_ThresholdMonitoring]) == 0)
  5331. {
  5332. /*
  5333. * TODO:
  5334. * 1. Report component that are ThresholdMonitoring
  5335. */
  5336. }
  5337. else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_DeltaMonitoring]) == 0)
  5338. {
  5339. /*
  5340. * TODO:
  5341. * 1. Report component that are DeltaMonitoring
  5342. */
  5343. }
  5344. else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_PeriodicMonitoring]) == 0)
  5345. {
  5346. /*
  5347. * TODO:
  5348. * 1. Report component that are PeriodicMonitoring
  5349. */
  5350. }
  5351. else
  5352. {
  5353. /*
  5354. * TODO:
  5355. * 1. Process unknown criteria condition
  5356. */
  5357. }
  5358. }
  5359. ShmOCPP20Data->GetMonitoringReport.requestId = 0;
  5360. }
  5361. if(isWebsocketSendable &&
  5362. (server_sign == TRUE) &&
  5363. (ShmOCPP20Data->GetReport.requestId > 0))
  5364. {
  5365. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetReport.componentCriteria);idxCriterion++)
  5366. {
  5367. if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Active]) == 0)
  5368. {
  5369. /*
  5370. * TODO:
  5371. * 1. Report component that are active
  5372. */
  5373. }
  5374. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Available]) == 0)
  5375. {
  5376. /*
  5377. * TODO:
  5378. * 1. Report component that are available
  5379. */
  5380. }
  5381. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Enabled]) == 0)
  5382. {
  5383. /*
  5384. * TODO:
  5385. * 1. Report component that are enable
  5386. */
  5387. }
  5388. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Problem]) == 0)
  5389. {
  5390. /*
  5391. * TODO:
  5392. * 1. Report component that are problem
  5393. */
  5394. }
  5395. else
  5396. {
  5397. /*
  5398. * TODO:
  5399. * 1. Process unknown criteria condition
  5400. */
  5401. }
  5402. }
  5403. ShmOCPP20Data->GetReport.requestId = 0;
  5404. }
  5405. if(isWebsocketSendable &&
  5406. (server_sign == TRUE) &&
  5407. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  5408. {
  5409. uint8_t reportIdx = 0;
  5410. ShmOCPP20Data->NotifyReport.requestId = ShmOCPP20Data->GetBaseReport.requestId;
  5411. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  5412. {
  5413. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  5414. {
  5415. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  5416. {
  5417. 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))
  5418. {
  5419. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  5420. reportIdx++;
  5421. }
  5422. }
  5423. else
  5424. {
  5425. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  5426. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  5427. ShmOCPP20Data->NotifyReport.seqNo += 1;
  5428. else
  5429. ShmOCPP20Data->NotifyReport.seqNo = 0;
  5430. sendNotifyReportRequest();
  5431. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  5432. reportIdx = 0;
  5433. }
  5434. }
  5435. }
  5436. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  5437. {
  5438. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  5439. {
  5440. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  5441. {
  5442. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  5443. reportIdx++;
  5444. }
  5445. else
  5446. {
  5447. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  5448. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  5449. ShmOCPP20Data->NotifyReport.seqNo += 1;
  5450. else
  5451. ShmOCPP20Data->NotifyReport.seqNo = 0;
  5452. sendNotifyReportRequest();
  5453. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  5454. reportIdx = 0;
  5455. }
  5456. }
  5457. }
  5458. else
  5459. {
  5460. /*
  5461. * TODO:
  5462. * 1. Fill out summary inventory to response message, currently not support
  5463. */
  5464. }
  5465. if(reportIdx > 0)
  5466. {
  5467. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  5468. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  5469. ShmOCPP20Data->NotifyReport.seqNo += 1;
  5470. else
  5471. ShmOCPP20Data->NotifyReport.seqNo = 0;
  5472. sendNotifyReportRequest();
  5473. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  5474. reportIdx = 0;
  5475. }
  5476. ShmOCPP20Data->GetBaseReport.requestId = 0;
  5477. }
  5478. if(isWebsocketSendable &&
  5479. (server_sign == TRUE) &&
  5480. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  5481. {
  5482. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  5483. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  5484. if(ShmOCPP20Data->NotifyEvent.seqNo < INT_MAX)
  5485. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  5486. else
  5487. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  5488. sendNotifyEventRequest();
  5489. memset(&ShmOCPP20Data->NotifyEvent.eventData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)* sizeof(struct EventDataType ));
  5490. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  5491. }
  5492. if(isWebsocketSendable &&
  5493. (server_sign == TRUE) &&
  5494. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq)
  5495. {
  5496. if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Install]) == 0)
  5497. {
  5498. /*
  5499. * TODO:
  5500. * 1.
  5501. */
  5502. }
  5503. else if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Update]) == 0)
  5504. {
  5505. /*
  5506. * TODO:
  5507. * 1.
  5508. */
  5509. }
  5510. else
  5511. {
  5512. /*
  5513. * TODO:
  5514. * 1.
  5515. */
  5516. }
  5517. sendGet15118EVCertificateRequest();
  5518. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  5519. }
  5520. //===============================
  5521. // Each connector operation check
  5522. //===============================
  5523. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  5524. {
  5525. //==========================================
  5526. // csu trigger DataTransferReq
  5527. //==========================================
  5528. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  5529. {
  5530. sendDataTransferRequest(gun_index);
  5531. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  5532. }
  5533. //==============================================
  5534. // Charger status notification & Transaction event report
  5535. //==============================================
  5536. //--- Check Mode Change ---//
  5537. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  5538. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5539. {
  5540. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5541. {
  5542. tempIndex = ((gun_index==2) ? 1: 0);
  5543. }
  5544. else
  5545. {
  5546. tempIndex = gun_index;
  5547. }
  5548. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5549. {
  5550. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5551. {
  5552. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  5553. {
  5554. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  5555. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  5556. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  5557. if((SystemInitial == 0) &&
  5558. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  5559. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  5560. {
  5561. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  5562. }
  5563. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  5564. {
  5565. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  5566. if((access(filenmae,F_OK))!=-1)
  5567. {
  5568. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  5569. sprintf(str,"rm -f %s",filenmae);
  5570. system(str);
  5571. }
  5572. }
  5573. }
  5574. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  5575. #if 1 // for TempStopTransaction
  5576. if(((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  5577. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  5578. {
  5579. checkTempStopTransaction(gun_index);
  5580. }
  5581. #endif
  5582. }
  5583. }
  5584. }
  5585. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5586. {
  5587. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5588. {
  5589. tempIndex = ((gun_index==2) ? 1: 0);
  5590. }
  5591. else
  5592. {
  5593. tempIndex = gun_index;
  5594. }
  5595. for (int index = 0; index < CCS_QUANTITY; index++)
  5596. {
  5597. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5598. {
  5599. 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]*/ )
  5600. {
  5601. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  5602. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  5603. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  5604. if((SystemInitial == 0) &&
  5605. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  5606. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  5607. {
  5608. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  5609. }
  5610. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  5611. {
  5612. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  5613. if((access(filenmae,F_OK))!=-1)
  5614. {
  5615. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  5616. sprintf(str,"rm -f %s",filenmae);
  5617. system(str);
  5618. }
  5619. }
  5620. }
  5621. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  5622. #if 1 // for TempStopTransaction
  5623. if(((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  5624. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  5625. {
  5626. checkTempStopTransaction(gun_index);
  5627. }
  5628. #endif
  5629. }
  5630. }
  5631. }
  5632. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5633. {
  5634. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5635. {
  5636. tempIndex = ((gun_index==2) ? 1: 0);
  5637. }
  5638. else
  5639. {
  5640. tempIndex = gun_index;
  5641. }
  5642. for (int index = 0; index < GB_QUANTITY; index++)
  5643. {
  5644. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5645. {
  5646. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  5647. {
  5648. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  5649. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  5650. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  5651. if((SystemInitial == 0) &&
  5652. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  5653. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  5654. {
  5655. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  5656. }
  5657. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  5658. {
  5659. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  5660. if((access(filenmae,F_OK))!=-1)
  5661. {
  5662. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  5663. sprintf(str,"rm -f %s",filenmae);
  5664. system(str);
  5665. }
  5666. }
  5667. }
  5668. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  5669. #if 1 // for TempStopTransaction
  5670. if(((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  5671. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  5672. {
  5673. checkTempStopTransaction(gun_index);
  5674. }
  5675. #endif
  5676. }
  5677. }
  5678. }
  5679. else if(gunType[gun_index] == GUN_TYPE_DO)
  5680. {
  5681. tempIndex = gun_index;
  5682. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5683. {
  5684. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5685. {
  5686. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  5687. {
  5688. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  5689. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  5690. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  5691. if((SystemInitial == 0) &&
  5692. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING) &&
  5693. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE))
  5694. {
  5695. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  5696. }
  5697. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_IDLE))) // complete
  5698. {
  5699. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  5700. if((access(filenmae,F_OK))!=-1)
  5701. {
  5702. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  5703. sprintf(str,"rm -f %s",filenmae);
  5704. system(str);
  5705. }
  5706. }
  5707. }
  5708. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING)?1:0);
  5709. #if 1 // for TempStopTransaction
  5710. if(((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)) &&
  5711. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  5712. {
  5713. checkTempStopTransaction(gun_index);
  5714. }
  5715. #endif
  5716. }
  5717. }
  5718. }
  5719. else
  5720. {
  5721. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5722. {
  5723. tempIndex = 2;
  5724. }
  5725. else
  5726. {
  5727. tempIndex = gun_index;
  5728. }
  5729. for (int index = 0; index < AC_QUANTITY; index++)
  5730. {
  5731. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5732. {
  5733. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  5734. {
  5735. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  5736. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  5737. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  5738. if((SystemInitial == 0) &&
  5739. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  5740. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  5741. {
  5742. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  5743. }
  5744. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  5745. {
  5746. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  5747. if((access(filenmae,F_OK))!=-1)
  5748. {
  5749. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  5750. sprintf(str,"rm -f %s",filenmae);
  5751. system(str);
  5752. }
  5753. }
  5754. }
  5755. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  5756. #if 1 // for TempStopTransaction
  5757. if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  5758. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  5759. {
  5760. checkTempStopTransaction(gun_index);
  5761. }
  5762. #endif
  5763. }
  5764. }// END
  5765. }
  5766. if(isWebsocketSendable && (server_sign == TRUE) && ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 5) &&
  5767. ((cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) || (cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq == ON)) )
  5768. {
  5769. if(SystemInitial > 0)
  5770. SystemInitial -= 1;
  5771. sendStatusNotificationRequest(gun_index);
  5772. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  5773. }
  5774. //==============================================
  5775. // CSU Trigger Smart Charging Profile
  5776. //==============================================
  5777. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  5778. {
  5779. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index], 0, TRUE);
  5780. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  5781. }
  5782. //==============================================
  5783. // CSU transaction event
  5784. //==============================================
  5785. if(ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == ON)
  5786. {
  5787. sendTransactionEventRequest(gun_index);
  5788. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  5789. //storeTempStopTransaction(gun_index);
  5790. //memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  5791. }
  5792. //==============================================
  5793. // Meter report
  5794. //==============================================
  5795. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  5796. {
  5797. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  5798. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  5799. }
  5800. // ClockAlign MeterValue
  5801. if(isWebsocketSendable && (server_sign == TRUE) && ((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value) > 0)?((getTimePassSinceToday(gun_index)%(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value)))==0):FALSE))
  5802. {
  5803. //check Transaction active
  5804. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5805. {
  5806. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5807. {
  5808. tempIndex = ((gun_index==2) ? 1: 0);
  5809. }
  5810. else
  5811. {
  5812. tempIndex = gun_index;
  5813. }
  5814. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5815. {
  5816. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5817. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5818. {
  5819. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5820. }
  5821. }// End for CHAdeMO
  5822. }
  5823. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5824. {
  5825. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5826. {
  5827. tempIndex = ((gun_index==2) ? 1: 0);
  5828. }
  5829. else
  5830. {
  5831. tempIndex = gun_index;
  5832. }
  5833. for (int index = 0; index < CCS_QUANTITY; index++)
  5834. {
  5835. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5836. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5837. {
  5838. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5839. }
  5840. } // End for CCS
  5841. }
  5842. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5843. {
  5844. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5845. {
  5846. tempIndex = ((gun_index==2) ? 1: 0);
  5847. }
  5848. else
  5849. {
  5850. tempIndex = gun_index;
  5851. }
  5852. for (int index = 0; index < GB_QUANTITY; index++)
  5853. {
  5854. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5855. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5856. {
  5857. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5858. }
  5859. }// End for GB
  5860. }
  5861. else if(gunType[gun_index] == GUN_TYPE_DO)
  5862. {
  5863. tempIndex = gun_index;
  5864. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5865. {
  5866. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5867. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5868. {
  5869. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5870. }
  5871. }
  5872. }
  5873. else
  5874. {
  5875. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5876. {
  5877. tempIndex = 2;
  5878. }
  5879. else
  5880. {
  5881. tempIndex = gun_index;
  5882. }
  5883. for (int index = 0; index < AC_QUANTITY; index++)
  5884. {
  5885. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5886. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5887. {
  5888. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5889. }
  5890. }//End for AC
  5891. }
  5892. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  5893. {
  5894. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  5895. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  5896. }
  5897. }
  5898. // Sample period MeterValue
  5899. if((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > ((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)>10)?(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1):10))
  5900. {
  5901. //check Transaction active
  5902. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5903. {
  5904. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5905. {
  5906. tempIndex = ((gun_index==2) ? 1: 0);
  5907. }
  5908. else
  5909. {
  5910. tempIndex = gun_index;
  5911. }
  5912. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5913. {
  5914. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5915. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5916. {
  5917. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5918. {
  5919. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5920. }
  5921. }
  5922. }// End for CHAdeMO
  5923. }
  5924. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5925. {
  5926. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5927. {
  5928. tempIndex = ((gun_index==2) ? 1: 0);
  5929. }
  5930. else
  5931. {
  5932. tempIndex = gun_index;
  5933. }
  5934. for (int index = 0; index < CCS_QUANTITY; index++)
  5935. {
  5936. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5937. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5938. {
  5939. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5940. {
  5941. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5942. }
  5943. }
  5944. } // End for CCS
  5945. }
  5946. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5947. {
  5948. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5949. {
  5950. tempIndex = ((gun_index==2) ? 1: 0);
  5951. }
  5952. else
  5953. {
  5954. tempIndex = gun_index;
  5955. }
  5956. for (int index = 0; index < GB_QUANTITY; index++)
  5957. {
  5958. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5959. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5960. {
  5961. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5962. {
  5963. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5964. }
  5965. }
  5966. }// End for GB
  5967. }
  5968. else if(gunType[gun_index] == GUN_TYPE_DO)
  5969. {
  5970. tempIndex = gun_index;
  5971. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5972. {
  5973. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5974. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5975. {
  5976. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  5977. {
  5978. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5979. }
  5980. }
  5981. }
  5982. }
  5983. else
  5984. {
  5985. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5986. {
  5987. tempIndex = 2;
  5988. }
  5989. else
  5990. {
  5991. tempIndex = gun_index;
  5992. }
  5993. for (int index = 0; index < AC_QUANTITY; index++)
  5994. {
  5995. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5996. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5997. {
  5998. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5999. {
  6000. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6001. }
  6002. }
  6003. }//End for AC
  6004. }
  6005. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  6006. {
  6007. if(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0)
  6008. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  6009. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  6010. }
  6011. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  6012. }
  6013. //==============================================
  6014. // Check Connector reserved
  6015. //==============================================
  6016. //===============================
  6017. // Check if Reserve is expired
  6018. //===============================
  6019. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0))
  6020. {
  6021. if(isOvertNow(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime))
  6022. {
  6023. DEBUG_INFO("reserve expired.\n");
  6024. ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId = ShmOCPP20Data->ReserveNow[gun_index].id;
  6025. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Expired]);
  6026. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = ON;
  6027. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  6028. }
  6029. }//END OF Check if Reserve is expired
  6030. //==========================================
  6031. // csu trigger FirmwareStatusNotificationReq
  6032. //==========================================
  6033. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  6034. {
  6035. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  6036. }
  6037. //==========================================
  6038. // csu cleared charging limit request
  6039. //==========================================
  6040. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq == ON))
  6041. {
  6042. sendClearedChargingLimitRequest(gun_index);
  6043. }
  6044. //==========================================
  6045. // csu trigger CancelReservationConf
  6046. //==========================================
  6047. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  6048. {
  6049. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  6050. }
  6051. //==========================================
  6052. // csu notify EV charging need request
  6053. //==========================================
  6054. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq == ON))
  6055. {
  6056. sendNotifyEVChargingNeedsRequest(gun_index);
  6057. }
  6058. //==========================================
  6059. // csu trigger ChangeAvailabilityConf
  6060. //==========================================
  6061. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  6062. {
  6063. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  6064. }
  6065. //==========================================
  6066. // csu trigger UnlockConnectorConf
  6067. //==========================================
  6068. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  6069. {
  6070. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  6071. }
  6072. //==========================================
  6073. // csu trigger ReserveNowConf
  6074. //==========================================
  6075. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  6076. {
  6077. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  6078. }
  6079. //==========================================
  6080. // csu trigger ReserveNowConf
  6081. //==========================================
  6082. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq == ON))
  6083. {
  6084. sendReservationStatusUpdateRequest(gun_index);
  6085. }
  6086. //==========================================
  6087. // csu trigger LogStatusNotificationReq
  6088. //==========================================
  6089. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq == ON))
  6090. {
  6091. sendLogStatusNotificationRequest((char *)ShmOCPP20Data->LogStatusNotification.status);
  6092. }
  6093. //==========================================
  6094. // csu trigger SignCertificateReq
  6095. //==========================================
  6096. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.SignCertificateReq == ON))
  6097. {
  6098. if((access("/Storage/OCPP/certCP.csr",F_OK) != -1) &&
  6099. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0) )
  6100. {
  6101. sendSignCertificateRequest(CertificateSignedStatusEnumType_ChargingStationCertificate);
  6102. }
  6103. else if((access("/Storage/OCPP/certV2G.csr",F_OK) != -1) &&
  6104. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0))
  6105. {
  6106. sendSignCertificateRequest(CertificateSignedStatusEnumType_V2GCertificate);
  6107. }
  6108. }
  6109. }
  6110. }
  6111. //==========================================
  6112. // send request routine
  6113. //==========================================
  6114. int sendAuthorizeRequest(int gun_index)
  6115. {
  6116. mtrace();
  6117. int result = FAIL;
  6118. char message[4096]={0};
  6119. char guid[37];
  6120. char tempdata[128]={0};
  6121. json_object *Authorize = json_object_new_object();
  6122. json_object *idToken = json_object_new_object();
  6123. DEBUG_INFO("sendAuthorizeRequest...\n");
  6124. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  6125. //Local Authorize
  6126. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  6127. {
  6128. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  6129. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  6130. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  6131. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  6132. result = PASS;
  6133. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6134. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6135. authorizeRetryTimes = 0;
  6136. return result;
  6137. }
  6138. 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)) ||
  6139. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  6140. {
  6141. // Query idtag from cache
  6142. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  6143. // Query idtag from list
  6144. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  6145. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  6146. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  6147. {
  6148. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  6149. {
  6150. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  6151. }
  6152. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  6153. {
  6154. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  6155. }
  6156. // Return authorize result if does not connect to server
  6157. if(!ShmOCPP20Data->OcppConnStatus)
  6158. {
  6159. DEBUG_INFO("Local Authorization Fail.\n");
  6160. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  6161. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6162. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  6163. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  6164. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6165. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6166. authorizeRetryTimes = 0;
  6167. return result;
  6168. }
  6169. }
  6170. else
  6171. {
  6172. DEBUG_INFO("Local Authorization get result.\n");
  6173. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  6174. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6175. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  6176. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  6177. else
  6178. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  6179. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  6180. result = PASS;
  6181. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6182. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6183. authorizeRetryTimes = 0;
  6184. return result;
  6185. }
  6186. }
  6187. //get data from shared memory
  6188. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6189. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  6190. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  6191. json_object_object_add(Authorize, "idToken", idToken);
  6192. random_uuid(guid);
  6193. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  6194. json_object_put(Authorize);
  6195. LWS_Send(message);
  6196. sprintf(tempdata, "Authorize,%d", gun_index);
  6197. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6198. {
  6199. result = PASS;
  6200. }
  6201. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6202. return result;
  6203. }
  6204. int sendBootNotificationRequest()
  6205. {
  6206. mtrace();
  6207. int result = FAIL;
  6208. char message[4096]={0};
  6209. char guid[37]={0};
  6210. char tempdata[128]={0};
  6211. json_object *BootNotification = json_object_new_object();
  6212. json_object *chargingStation = json_object_new_object();
  6213. json_object *modem = json_object_new_object();
  6214. DEBUG_INFO("sendBootNotificationRequest...\n");
  6215. // Fill BootNotification fields
  6216. DB_getBooType();
  6217. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  6218. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  6219. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  6220. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  6221. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  6222. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  6223. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  6224. {
  6225. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  6226. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  6227. json_object_object_add(chargingStation, "modem", modem);
  6228. }
  6229. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  6230. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  6231. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  6232. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  6233. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  6234. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  6235. random_uuid(guid);
  6236. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  6237. json_object_put(BootNotification);
  6238. LWS_Send(message);
  6239. sprintf(tempdata, "BootNotification,0");
  6240. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6241. {
  6242. result = PASS;
  6243. }
  6244. return result;
  6245. }
  6246. int sendClearedChargingLimitRequest(int gun_index)
  6247. {
  6248. mtrace();
  6249. int result = FAIL;
  6250. char message[4096]={0};
  6251. char guid[37]={0};
  6252. char tempdata[128]={0};
  6253. json_object *ClearedChargingLimit = json_object_new_object();
  6254. DEBUG_INFO("sendClearedChargingLimitRequest...\n");
  6255. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  6256. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  6257. random_uuid(guid);
  6258. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  6259. json_object_put(ClearedChargingLimit);
  6260. LWS_Send(message);
  6261. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  6262. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6263. {
  6264. result = PASS;
  6265. }
  6266. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  6267. return result;
  6268. }
  6269. int sendDataTransferRequest(int gun_index)
  6270. {
  6271. mtrace();
  6272. char message[1000]={0};
  6273. char guid[37]={0};
  6274. char tempdata[65]={0};
  6275. int result = FAIL;
  6276. DEBUG_INFO("sendDataTransferRequest...\n");
  6277. random_uuid(guid);
  6278. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  6279. MESSAGE_TYPE_CALL,
  6280. guid,
  6281. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  6282. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  6283. ShmOCPP20Data->DataTransfer[gun_index].data);
  6284. LWS_Send(message);
  6285. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  6286. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6287. {
  6288. result = PASS;
  6289. }
  6290. return result;
  6291. }
  6292. int sendFirmwareStatusNotificationRequest(char *status)
  6293. {
  6294. mtrace();
  6295. int result = FAIL;
  6296. char message[110]={0};
  6297. char guid[37]={0};
  6298. char tempdata[65]={0};
  6299. json_object *FirmwareStatusNotification = json_object_new_object();
  6300. DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
  6301. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  6302. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  6303. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  6304. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  6305. random_uuid(guid);
  6306. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6307. json_object_put(FirmwareStatusNotification);
  6308. LWS_SendNow(message);
  6309. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  6310. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6311. {
  6312. result = PASS;
  6313. }
  6314. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  6315. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  6316. //record status
  6317. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  6318. {
  6319. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  6320. }
  6321. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  6322. {
  6323. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  6324. }
  6325. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  6326. {
  6327. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  6328. }
  6329. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  6330. {
  6331. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  6332. }
  6333. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  6334. {
  6335. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  6336. }
  6337. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  6338. {
  6339. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  6340. }
  6341. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  6342. {
  6343. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  6344. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  6345. }
  6346. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  6347. {
  6348. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  6349. }
  6350. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  6351. {
  6352. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  6353. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  6354. }
  6355. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  6356. {
  6357. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  6358. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  6359. }
  6360. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  6361. {
  6362. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  6363. }
  6364. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  6365. {
  6366. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  6367. }
  6368. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  6369. {
  6370. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  6371. }
  6372. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  6373. {
  6374. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  6375. }
  6376. return result;
  6377. }
  6378. int sendGet15118EVCertificateRequest()
  6379. {
  6380. mtrace();
  6381. int result = FAIL;
  6382. char message[4096]={0};
  6383. char guid[37]={0};
  6384. char tempdata[128]={0};
  6385. json_object *Get15118EVCertificate = json_object_new_object();
  6386. DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
  6387. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  6388. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  6389. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  6390. random_uuid(guid);
  6391. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  6392. json_object_put(Get15118EVCertificate);
  6393. LWS_Send(message);
  6394. sprintf(tempdata, "Get15118EVCertificate,0");
  6395. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6396. {
  6397. result = PASS;
  6398. }
  6399. return result;
  6400. }
  6401. int sendGetCertificateStatusRequest()
  6402. {
  6403. mtrace();
  6404. int result = FAIL;
  6405. char message[4096]={0};
  6406. char guid[37]={0};
  6407. char tempdata[128]={0};
  6408. json_object *GetCertificateStatus = json_object_new_object();
  6409. json_object *ocspRequestData = json_object_new_object();
  6410. DEBUG_INFO("sendGetCertificateStatusRequest...\n");
  6411. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  6412. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  6413. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  6414. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  6415. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  6416. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  6417. random_uuid(guid);
  6418. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  6419. json_object_put(GetCertificateStatus);
  6420. LWS_Send(message);
  6421. sprintf(tempdata, "GetCertificateStatus,0");
  6422. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6423. {
  6424. result = PASS;
  6425. }
  6426. return result;
  6427. }
  6428. int sendHeartbeatRequest()
  6429. {
  6430. mtrace();
  6431. int result = FAIL;
  6432. char message[40096]={0};
  6433. char guid[37]={0};
  6434. char tempdata[128]={0};
  6435. DEBUG_INFO("sendHeartbeatRequest...\n");
  6436. random_uuid(guid);
  6437. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  6438. , MESSAGE_TYPE_CALL
  6439. , guid );
  6440. LWS_Send(message);
  6441. sprintf(tempdata, "Heartbeat,%d", 0);
  6442. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6443. {
  6444. result = PASS;
  6445. }
  6446. return result;
  6447. }
  6448. int sendLogStatusNotificationRequest(char *status)
  6449. {
  6450. mtrace();
  6451. int result = FAIL;
  6452. char message[4096]={0};
  6453. char guid[37]={0};
  6454. char tempdata[128]={0};
  6455. json_object *LogStatusNotification = json_object_new_object();
  6456. DEBUG_INFO("sendLogStatusNotificationRequest...\n");
  6457. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  6458. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  6459. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  6460. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  6461. random_uuid(guid);
  6462. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  6463. json_object_put(LogStatusNotification);
  6464. LWS_SendNow(message);
  6465. sprintf(tempdata, "LogStatusNotification,%d", 0);
  6466. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6467. {
  6468. result = PASS;
  6469. }
  6470. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  6471. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  6472. //record status
  6473. if(strcmp(status,"BadMessage")==0)
  6474. {
  6475. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  6476. }
  6477. else if(strcmp(status,"Idle")==0)
  6478. {
  6479. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  6480. }
  6481. else if(strcmp(status,"NotSupportedOperation")==0)
  6482. {
  6483. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  6484. }
  6485. else if(strcmp(status,"PermissionDenied")==0)
  6486. {
  6487. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  6488. }
  6489. else if(strcmp(status,"Uploaded")==0)
  6490. {
  6491. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  6492. }
  6493. else if(strcmp(status,"UploadFailure")==0)
  6494. {
  6495. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  6496. }
  6497. else if(strcmp(status,"Uploading")==0)
  6498. {
  6499. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  6500. }
  6501. return result;
  6502. }
  6503. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  6504. {
  6505. mtrace();
  6506. int result = FAIL;
  6507. char guid[37]={0};
  6508. char tempdata[65]={0};
  6509. int tempIndex = 0;
  6510. json_object *MeterValueReq = json_object_new_object();
  6511. json_object *meterValues = json_object_new_array();
  6512. json_object *sampledValues = json_object_new_array();
  6513. DEBUG_INFO("sendMeterValuesRequest...\n");
  6514. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  6515. memset(&ShmOCPP20Data->MeterValues[gun_index], 0, sizeof(struct MeterValues_20));
  6516. //set value
  6517. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  6518. //UTC Date time
  6519. struct timeval tmnow;
  6520. struct tm *tm;
  6521. char buf[28];//, usec_buf[6];
  6522. gettimeofday(&tmnow, NULL);
  6523. time_t t;
  6524. t = time(NULL);
  6525. /*UTC time and date*/
  6526. tm = gmtime(&t);
  6527. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6528. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  6529. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  6530. //idx_sample=0;
  6531. //********************************(1)Current.Import L1************************************************/
  6532. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  6533. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  6534. (dataType == ReadingContextEnumType_Trigger))
  6535. {
  6536. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6537. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6538. {
  6539. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6540. {
  6541. tempIndex = ((gun_index==2) ? 1: 0);
  6542. }
  6543. else
  6544. {
  6545. tempIndex = gun_index;
  6546. }
  6547. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6548. {
  6549. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6550. {
  6551. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent*100))/100.0;
  6552. }
  6553. }
  6554. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6555. }
  6556. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6557. {
  6558. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6559. {
  6560. tempIndex = ((gun_index==2) ? 1: 0);
  6561. }
  6562. else
  6563. {
  6564. tempIndex = gun_index;
  6565. }
  6566. for (int index = 0; index < CCS_QUANTITY; index++)
  6567. {
  6568. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6569. {
  6570. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent*100))/100.0;
  6571. }
  6572. }
  6573. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6574. }
  6575. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6576. {
  6577. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6578. {
  6579. tempIndex = ((gun_index==2) ? 1: 0);
  6580. }
  6581. else
  6582. {
  6583. tempIndex = gun_index;
  6584. }
  6585. for (int index = 0; index < GB_QUANTITY; index++)
  6586. {
  6587. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6588. {
  6589. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent*100))/100.0;
  6590. }
  6591. }
  6592. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6593. }
  6594. else if(gunType[gun_index] == GUN_TYPE_DO)
  6595. {
  6596. tempIndex = gun_index;
  6597. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6598. {
  6599. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6600. {
  6601. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*100))/100.0;
  6602. }
  6603. }
  6604. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6605. }
  6606. else
  6607. {
  6608. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6609. {
  6610. tempIndex = 2;
  6611. }
  6612. else
  6613. {
  6614. tempIndex = gun_index;
  6615. }
  6616. for (int index = 0; index < AC_QUANTITY; index++)
  6617. {
  6618. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6619. {
  6620. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent*100))/100.0;
  6621. }
  6622. }
  6623. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6624. }
  6625. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  6626. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  6627. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6628. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  6629. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  6630. }
  6631. //idx_sample=1;
  6632. //********************************(2)Energy.Active.Import.Register ************************************************/
  6633. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
  6634. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
  6635. (dataType == ReadingContextEnumType_Trigger))
  6636. {
  6637. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6638. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6639. {
  6640. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6641. {
  6642. tempIndex = ((gun_index==2) ? 1: 0);
  6643. }
  6644. else
  6645. {
  6646. tempIndex = gun_index;
  6647. }
  6648. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6649. {
  6650. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6651. {
  6652. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100))/100.0;
  6653. }
  6654. }
  6655. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6656. }
  6657. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6658. {
  6659. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6660. {
  6661. tempIndex = ((gun_index==2) ? 1: 0);
  6662. }
  6663. else
  6664. {
  6665. tempIndex = gun_index;
  6666. }
  6667. for (int index = 0; index < CCS_QUANTITY; index++)
  6668. {
  6669. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6670. {
  6671. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100))/100.0;
  6672. }
  6673. }
  6674. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6675. }
  6676. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6677. {
  6678. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6679. {
  6680. tempIndex = ((gun_index==2) ? 1: 0);
  6681. }
  6682. else
  6683. {
  6684. tempIndex = gun_index;
  6685. }
  6686. for (int index = 0; index < GB_QUANTITY; index++)
  6687. {
  6688. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6689. {
  6690. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100))/100.0;
  6691. }
  6692. }
  6693. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6694. }
  6695. else if(gunType[gun_index] == GUN_TYPE_DO)
  6696. {
  6697. tempIndex = gun_index;
  6698. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6699. {
  6700. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6701. {
  6702. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100))/100.0;
  6703. }
  6704. }
  6705. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6706. }
  6707. else
  6708. {
  6709. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6710. {
  6711. tempIndex = 2;
  6712. }
  6713. else
  6714. {
  6715. tempIndex = gun_index;
  6716. }
  6717. for (int index = 0; index < AC_QUANTITY; index++)
  6718. {
  6719. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6720. {
  6721. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100))/100.0;
  6722. }
  6723. }
  6724. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6725. }
  6726. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  6727. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  6728. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6729. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  6730. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  6731. }
  6732. //idx_sample=2;
  6733. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  6734. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
  6735. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
  6736. (dataType == ReadingContextEnumType_Trigger))
  6737. {
  6738. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6739. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6740. {
  6741. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6742. {
  6743. tempIndex = ((gun_index==2) ? 1: 0);
  6744. }
  6745. else
  6746. {
  6747. tempIndex = gun_index;
  6748. }
  6749. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6750. {
  6751. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6752. {
  6753. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy*100))/100.0;
  6754. }
  6755. } // END OF FOR CHAdeMO_QUANTITY
  6756. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6757. }
  6758. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6759. {
  6760. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6761. {
  6762. tempIndex = ((gun_index==2) ? 1: 0);
  6763. }
  6764. else
  6765. {
  6766. tempIndex = gun_index;
  6767. }
  6768. for (int index = 0; index < CCS_QUANTITY; index++)
  6769. {
  6770. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6771. {
  6772. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy*100))/100.0;
  6773. }
  6774. } // END OF CCS_QUANTITY
  6775. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6776. }
  6777. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6778. {
  6779. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6780. {
  6781. tempIndex = ((gun_index==2) ? 1: 0);
  6782. }
  6783. else
  6784. {
  6785. tempIndex = gun_index;
  6786. }
  6787. for (int index = 0; index < GB_QUANTITY; index++)
  6788. {
  6789. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6790. {
  6791. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy*100))/100.0;
  6792. }
  6793. } // END OF GB_QUANTITY
  6794. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6795. }
  6796. else if(gunType[gun_index] == GUN_TYPE_DO)
  6797. {
  6798. tempIndex = gun_index;
  6799. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6800. {
  6801. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6802. {
  6803. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100))/100.0;
  6804. }
  6805. }
  6806. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6807. }
  6808. else
  6809. {
  6810. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6811. {
  6812. tempIndex = 2;
  6813. }
  6814. else
  6815. {
  6816. tempIndex = gun_index;
  6817. }
  6818. for (int index = 0; index < AC_QUANTITY; index++)
  6819. {
  6820. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6821. {
  6822. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy*100))/100.0;
  6823. }
  6824. }
  6825. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6826. }
  6827. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  6828. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  6829. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6830. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  6831. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  6832. }
  6833. //idx_sample=3;
  6834. //********************************(4)Power.Active.Import************************************************/
  6835. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
  6836. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
  6837. (dataType == ReadingContextEnumType_Trigger))
  6838. {
  6839. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6840. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6841. {
  6842. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6843. {
  6844. tempIndex = ((gun_index==2) ? 1: 0);
  6845. }
  6846. else
  6847. {
  6848. tempIndex = gun_index;
  6849. }
  6850. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6851. {
  6852. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6853. {
  6854. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower*100))/100.0;
  6855. }
  6856. } // END OF FOR
  6857. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6858. }
  6859. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6860. {
  6861. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6862. {
  6863. tempIndex = ((gun_index==2) ? 1: 0);
  6864. }
  6865. else
  6866. {
  6867. tempIndex = gun_index;
  6868. }
  6869. for (int index = 0; index < CCS_QUANTITY; index++)
  6870. {
  6871. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6872. {
  6873. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower*100))/100.0;
  6874. }
  6875. }
  6876. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6877. }
  6878. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6879. {
  6880. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6881. {
  6882. tempIndex = ((gun_index==2) ? 1: 0);
  6883. }
  6884. else
  6885. {
  6886. tempIndex = gun_index;
  6887. }
  6888. for (int index = 0; index < GB_QUANTITY; index++)
  6889. {
  6890. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6891. {
  6892. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  6893. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower*100))/100.0;
  6894. }
  6895. }
  6896. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6897. }
  6898. else if(gunType[gun_index] == GUN_TYPE_DO)
  6899. {
  6900. tempIndex = gun_index;
  6901. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6902. {
  6903. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6904. {
  6905. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  6906. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower*100))/100.0;
  6907. }
  6908. }
  6909. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6910. }
  6911. else
  6912. {
  6913. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6914. {
  6915. tempIndex = 2;
  6916. }
  6917. else
  6918. {
  6919. tempIndex = gun_index;
  6920. }
  6921. for (int index = 0; index < AC_QUANTITY; index++)
  6922. {
  6923. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6924. {
  6925. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower*100))/100.0;
  6926. }
  6927. }
  6928. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6929. }
  6930. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  6931. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  6932. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6933. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  6934. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  6935. }
  6936. //idx_sample=4;
  6937. //***********************************************(5)VOLTAGE L1******************************************************/
  6938. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  6939. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  6940. (dataType == ReadingContextEnumType_Trigger))
  6941. {
  6942. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6943. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6944. {
  6945. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6946. {
  6947. tempIndex = ((gun_index==2) ? 1: 0);
  6948. }
  6949. else
  6950. {
  6951. tempIndex = gun_index;
  6952. }
  6953. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6954. {
  6955. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6956. {
  6957. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage*100))/100.0;
  6958. }
  6959. }
  6960. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6961. }
  6962. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6963. {
  6964. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6965. {
  6966. tempIndex = ((gun_index==2) ? 1: 0);
  6967. }
  6968. else
  6969. {
  6970. tempIndex = gun_index;
  6971. }
  6972. for (int index = 0; index < CCS_QUANTITY; index++)
  6973. {
  6974. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6975. {
  6976. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage*100))/100.0;
  6977. }
  6978. }
  6979. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6980. }
  6981. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6982. {
  6983. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6984. {
  6985. tempIndex = ((gun_index==2) ? 1: 0);
  6986. }
  6987. else
  6988. {
  6989. tempIndex = gun_index;
  6990. }
  6991. for (int index = 0; index < GB_QUANTITY; index++)
  6992. {
  6993. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6994. {
  6995. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage*100))/100.0;
  6996. }
  6997. }
  6998. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6999. }
  7000. else if(gunType[gun_index] == GUN_TYPE_DO)
  7001. {
  7002. tempIndex = gun_index;
  7003. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7004. {
  7005. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7006. {
  7007. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*100))/100.0;
  7008. }
  7009. }
  7010. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7011. }
  7012. else
  7013. {
  7014. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7015. {
  7016. tempIndex = 2;
  7017. }
  7018. else
  7019. {
  7020. tempIndex = gun_index;
  7021. }
  7022. for (int index = 0; index < AC_QUANTITY; index++)
  7023. {
  7024. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7025. {
  7026. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage*100))/100.0;
  7027. }
  7028. }
  7029. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7030. }
  7031. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  7032. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7033. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7034. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  7035. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  7036. }
  7037. //***********************************************(6)SOC******************************************************/
  7038. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
  7039. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
  7040. (dataType == ReadingContextEnumType_Trigger))
  7041. {
  7042. 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))
  7043. {
  7044. if((ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0') && (gunType[gun_index] != GUN_TYPE_DO))
  7045. {
  7046. tempIndex = ((gun_index==2) ? 1: 0);
  7047. }
  7048. else
  7049. {
  7050. tempIndex = gun_index;
  7051. }
  7052. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7053. {
  7054. //tempIndex = ((gun_index==2) ? 1: 0);
  7055. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7056. {
  7057. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7058. {
  7059. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  7060. }
  7061. }
  7062. }
  7063. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7064. {
  7065. //tempIndex = ((gun_index==2) ? 1: 0);
  7066. for (int index = 0; index < CCS_QUANTITY; index++)
  7067. {
  7068. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7069. {
  7070. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  7071. }
  7072. }
  7073. }
  7074. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7075. {
  7076. //tempIndex = ((gun_index==2) ? 1: 0);
  7077. for (int index = 0; index < GB_QUANTITY; index++)
  7078. {
  7079. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7080. {
  7081. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  7082. }
  7083. }
  7084. }
  7085. else if(gunType[gun_index] == GUN_TYPE_DO)
  7086. {
  7087. //tempIndex = ((gun_index==2) ? 1: 0);
  7088. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7089. {
  7090. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7091. {
  7092. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  7093. }
  7094. }
  7095. }
  7096. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  7097. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  7098. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7099. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  7100. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  7101. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  7102. }
  7103. }
  7104. //********************************(7)Current.Import L2************************************************/
  7105. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7106. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7107. (dataType == ReadingContextEnumType_Trigger))
  7108. {
  7109. // Only for AC 3 phase
  7110. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7111. {
  7112. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7113. {
  7114. tempIndex = 2;
  7115. }
  7116. else
  7117. {
  7118. tempIndex = gun_index;
  7119. }
  7120. for (int index = 0; index < AC_QUANTITY; index++)
  7121. {
  7122. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7123. {
  7124. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2*100))/100.0;
  7125. }
  7126. }
  7127. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  7128. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  7129. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7130. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7131. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  7132. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  7133. }
  7134. }
  7135. //********************************(8)Current.Import L3************************************************/
  7136. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7137. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7138. (dataType == ReadingContextEnumType_Trigger))
  7139. {
  7140. // Only for AC 3 phase
  7141. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7142. {
  7143. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7144. {
  7145. tempIndex = 2;
  7146. }
  7147. else
  7148. {
  7149. tempIndex = gun_index;
  7150. }
  7151. for (int index = 0; index < AC_QUANTITY; index++)
  7152. {
  7153. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7154. {
  7155. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3*100))/100.0;
  7156. }
  7157. }
  7158. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7159. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  7160. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7161. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7162. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  7163. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  7164. }
  7165. }
  7166. //***********************************************(9)VOLTAGE L2******************************************************/
  7167. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7168. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7169. (dataType == ReadingContextEnumType_Trigger))
  7170. {
  7171. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7172. {
  7173. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7174. {
  7175. tempIndex = 2;
  7176. }
  7177. else
  7178. {
  7179. tempIndex = gun_index;
  7180. }
  7181. for (int index = 0; index < AC_QUANTITY; index++)
  7182. {
  7183. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7184. {
  7185. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2*100))/100.0;
  7186. }
  7187. }
  7188. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  7189. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  7190. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7191. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7192. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  7193. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  7194. }
  7195. }
  7196. //***********************************************(10)VOLTAGE L3******************************************************/
  7197. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7198. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7199. (dataType == ReadingContextEnumType_Trigger))
  7200. {
  7201. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7202. {
  7203. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7204. {
  7205. tempIndex = 2;
  7206. }
  7207. else
  7208. {
  7209. tempIndex = gun_index;
  7210. }
  7211. for (int index = 0; index < AC_QUANTITY; index++)
  7212. {
  7213. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7214. {
  7215. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3*100))/100.0;
  7216. }
  7217. }
  7218. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7219. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  7220. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7221. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7222. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  7223. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  7224. }
  7225. }
  7226. //***********************************************(11)Current.Offered******************************************************/
  7227. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
  7228. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
  7229. (dataType == ReadingContextEnumType_Trigger))
  7230. {
  7231. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7232. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7233. {
  7234. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7235. {
  7236. tempIndex = ((gun_index==2) ? 1: 0);
  7237. }
  7238. else
  7239. {
  7240. tempIndex = gun_index;
  7241. }
  7242. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7243. {
  7244. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7245. {
  7246. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].AvailableChargingCurrent/10);
  7247. }
  7248. } // END OF FOR
  7249. }
  7250. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7251. {
  7252. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7253. {
  7254. tempIndex = ((gun_index==2) ? 1: 0);
  7255. }
  7256. else
  7257. {
  7258. tempIndex = gun_index;
  7259. }
  7260. for (int index = 0; index < CCS_QUANTITY; index++)
  7261. {
  7262. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7263. {
  7264. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].AvailableChargingCurrent/10);
  7265. }
  7266. }
  7267. }
  7268. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7269. {
  7270. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7271. {
  7272. tempIndex = ((gun_index==2) ? 1: 0);
  7273. }
  7274. else
  7275. {
  7276. tempIndex = gun_index;
  7277. }
  7278. for (int index = 0; index < GB_QUANTITY; index++)
  7279. {
  7280. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7281. {
  7282. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7283. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].AvailableChargingCurrent/10);;
  7284. }
  7285. }
  7286. }
  7287. else if(gunType[gun_index] == GUN_TYPE_DO)
  7288. {
  7289. tempIndex = gun_index;
  7290. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7291. {
  7292. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7293. {
  7294. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7295. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.AvailableChargingCurrent/10);;
  7296. }
  7297. }
  7298. }
  7299. else
  7300. {
  7301. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7302. {
  7303. tempIndex = 2;
  7304. }
  7305. else
  7306. {
  7307. tempIndex = gun_index;
  7308. }
  7309. for (int index = 0; index < AC_QUANTITY; index++)
  7310. {
  7311. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7312. {
  7313. uint16_t currentOffer;
  7314. if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
  7315. {
  7316. currentOffer = ShmSysConfigAndInfo->SysConfig.RatingCurrent;
  7317. }
  7318. else
  7319. {
  7320. currentOffer = ((ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent>ShmSysConfigAndInfo->SysConfig.RatingCurrent)?ShmSysConfigAndInfo->SysConfig.RatingCurrent:ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
  7321. }
  7322. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = currentOffer;
  7323. }
  7324. }
  7325. }
  7326. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].context, ReadingContextEnumTypeStr[dataType]);
  7327. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]);
  7328. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7329. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.uint , "A");
  7330. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.multiplier = 0;
  7331. }
  7332. //***********************************************(12)Power.Offered******************************************************/
  7333. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
  7334. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
  7335. (dataType == ReadingContextEnumType_Trigger))
  7336. {
  7337. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7338. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7339. {
  7340. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7341. {
  7342. tempIndex = ((gun_index==2) ? 1: 0);
  7343. }
  7344. else
  7345. {
  7346. tempIndex = gun_index;
  7347. }
  7348. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7349. {
  7350. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7351. {
  7352. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].AvailableChargingPower*100);
  7353. }
  7354. } // END OF FOR
  7355. }
  7356. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7357. {
  7358. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7359. {
  7360. tempIndex = ((gun_index==2) ? 1: 0);
  7361. }
  7362. else
  7363. {
  7364. tempIndex = gun_index;
  7365. }
  7366. for (int index = 0; index < CCS_QUANTITY; index++)
  7367. {
  7368. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7369. {
  7370. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].AvailableChargingPower*100);
  7371. }
  7372. }
  7373. }
  7374. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7375. {
  7376. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7377. {
  7378. tempIndex = ((gun_index==2) ? 1: 0);
  7379. }
  7380. else
  7381. {
  7382. tempIndex = gun_index;
  7383. }
  7384. for (int index = 0; index < GB_QUANTITY; index++)
  7385. {
  7386. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7387. {
  7388. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7389. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].AvailableChargingPower*100);
  7390. }
  7391. }
  7392. }
  7393. else if(gunType[gun_index] == GUN_TYPE_DO)
  7394. {
  7395. tempIndex = gun_index;
  7396. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7397. {
  7398. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7399. {
  7400. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7401. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.AvailableChargingPower*100);
  7402. }
  7403. }
  7404. }
  7405. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].context, ReadingContextEnumTypeStr[dataType]);
  7406. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]);
  7407. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7408. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.uint , "W");
  7409. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.multiplier = 0;
  7410. }
  7411. // Message create ====================================================================================================
  7412. random_uuid(guid);
  7413. for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
  7414. {
  7415. json_object *meterValue = json_object_new_object();
  7416. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7417. {
  7418. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7419. {
  7420. json_object *sampledValue = json_object_new_object();
  7421. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7422. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7423. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7424. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  7425. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7426. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  7427. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7428. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  7429. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7430. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  7431. {
  7432. json_object *unitOfMeasure = json_object_new_object();
  7433. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7434. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7435. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7436. }
  7437. json_object_array_add(sampledValues, sampledValue);
  7438. }
  7439. }
  7440. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  7441. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7442. json_object_array_add(meterValues, meterValue);
  7443. idxMeter++;
  7444. }
  7445. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  7446. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  7447. sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",%s]"
  7448. ,MESSAGE_TYPE_CALL
  7449. ,guid
  7450. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  7451. json_object_put(MeterValueReq);
  7452. if((dataType != ReadingContextEnumType_Trigger) &&
  7453. (dataType != ReadingContextEnumType_Sample_Clock))
  7454. {
  7455. // Transaction meter value send by TransactionEvent message
  7456. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  7457. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  7458. result = PASS;
  7459. }
  7460. else
  7461. {
  7462. // Put request guid to hash map
  7463. sprintf(tempdata, "MeterValues,%d", (gun_index));
  7464. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7465. {
  7466. result = PASS;
  7467. }
  7468. if((dataType != ReadingContextEnumType_Trigger) &&
  7469. (dataType != ReadingContextEnumType_Sample_Clock))
  7470. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  7471. else
  7472. {
  7473. if(FirstHeartBeat)
  7474. LWS_Send(queuedata +2);
  7475. }
  7476. }
  7477. return result;
  7478. }
  7479. int sendNotifyChargingLimitRequest(int gun_index)
  7480. {
  7481. mtrace();
  7482. int result = FAIL;
  7483. char message[4096]={0};
  7484. char guid[37]={0};
  7485. char tempdata[128]={0};
  7486. json_object *NotifyChargingLimit = json_object_new_object();
  7487. json_object *chargingLimit = json_object_new_object();
  7488. DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
  7489. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  7490. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  7491. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  7492. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  7493. random_uuid(guid);
  7494. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  7495. json_object_put(NotifyChargingLimit);
  7496. LWS_Send(message);
  7497. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  7498. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7499. {
  7500. result = PASS;
  7501. }
  7502. return result;
  7503. }
  7504. int sendNotifyCustomerInformationRequest()
  7505. {
  7506. mtrace();
  7507. int result = FAIL;
  7508. char message[4096]={0};
  7509. char guid[37]={0};
  7510. char tempdata[128]={0};
  7511. json_object *NotifyCustomerInformation = json_object_new_object();
  7512. DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
  7513. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  7514. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  7515. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  7516. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  7517. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  7518. random_uuid(guid);
  7519. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  7520. json_object_put(NotifyCustomerInformation);
  7521. LWS_Send(message);
  7522. sprintf(tempdata, "NotifyCustomerInformation,0");
  7523. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7524. {
  7525. result = PASS;
  7526. }
  7527. return result;
  7528. }
  7529. int sendNotifyDisplayMessagesRequest()
  7530. {
  7531. mtrace();
  7532. int result = FAIL;
  7533. char message[4096]={0};
  7534. char guid[37]={0};
  7535. char tempdata[128]={0};
  7536. json_object *NotifyDisplayMessages = json_object_new_object();
  7537. json_object *messageInfos = json_object_new_array();
  7538. DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
  7539. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  7540. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  7541. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  7542. {
  7543. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  7544. {
  7545. json_object *messageInfo = json_object_new_object();
  7546. json_object *message = json_object_new_object();
  7547. json_object *display = json_object_new_object();
  7548. json_object *evse = json_object_new_object();
  7549. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  7550. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  7551. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  7552. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  7553. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  7554. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  7555. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  7556. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  7557. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  7558. json_object_object_add(messageInfo, "message", message);
  7559. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  7560. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  7561. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  7562. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  7563. json_object_object_add(display, "evse",evse);
  7564. json_object_object_add(messageInfo, "evse", display);
  7565. json_object_array_add(messageInfos, messageInfo);
  7566. }
  7567. }
  7568. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  7569. random_uuid(guid);
  7570. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7571. json_object_put(NotifyDisplayMessages);
  7572. LWS_Send(message);
  7573. sprintf(tempdata, "NotifyDisplayMessages,0");
  7574. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7575. {
  7576. result = PASS;
  7577. }
  7578. return result;
  7579. }
  7580. int sendNotifyEVChargingNeedsRequest(int gun_index)
  7581. {
  7582. mtrace();
  7583. int result = FAIL;
  7584. char message[4096]={0};
  7585. char guid[37]={0};
  7586. char tempdata[128]={0};
  7587. json_object *NotifyEVChargingNeeds = json_object_new_object();
  7588. json_object *chargingNeeds = json_object_new_object();
  7589. json_object *acChargingParameters = json_object_new_object();
  7590. json_object *dcChargingParameters = json_object_new_object();
  7591. DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
  7592. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  7593. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  7594. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  7595. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  7596. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  7597. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  7598. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  7599. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  7600. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  7601. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  7602. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  7603. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  7604. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  7605. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  7606. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  7607. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  7608. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  7609. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  7610. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  7611. random_uuid(guid);
  7612. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  7613. json_object_put(NotifyEVChargingNeeds);
  7614. LWS_Send(message);
  7615. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  7616. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7617. {
  7618. result = PASS;
  7619. }
  7620. return result;
  7621. }
  7622. int sendNotifyEVChargingScheduleRequest(int gun_index)
  7623. {
  7624. mtrace();
  7625. int result = FAIL;
  7626. char message[4096]={0};
  7627. char guid[37]={0};
  7628. char tempdata[128]={0};
  7629. json_object *NotifyEVChargingSchedule = json_object_new_object();
  7630. json_object *chargingSchedule = json_object_new_object();
  7631. json_object *periods = json_object_new_array();
  7632. DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
  7633. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  7634. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  7635. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  7636. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  7637. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  7638. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  7639. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  7640. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7641. {
  7642. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7643. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7644. {
  7645. json_object *Period = json_object_new_object();
  7646. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7647. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7648. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7649. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7650. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7651. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7652. json_object_array_add(periods, Period);
  7653. }
  7654. }
  7655. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  7656. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  7657. random_uuid(guid);
  7658. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  7659. json_object_put(NotifyEVChargingSchedule);
  7660. LWS_Send(message);
  7661. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  7662. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7663. {
  7664. result = PASS;
  7665. }
  7666. return result;
  7667. }
  7668. int sendNotifyEventRequest()
  7669. {
  7670. mtrace();
  7671. int result = FAIL;
  7672. char message[4096]={0};
  7673. char guid[37]={0};
  7674. char tempdata[128]={0};
  7675. json_object *NotifyEvent = json_object_new_object();
  7676. json_object *eventDatas = json_object_new_array();
  7677. DEBUG_INFO("sendNotifyEventRequest...\n");
  7678. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  7679. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  7680. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  7681. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  7682. {
  7683. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  7684. {
  7685. json_object *eventData = json_object_new_object();
  7686. json_object *component = json_object_new_object();
  7687. json_object *evse = json_object_new_object();
  7688. json_object *variable = json_object_new_object();
  7689. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  7690. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  7691. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  7692. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  7693. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  7694. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  7695. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  7696. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  7697. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  7698. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  7699. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  7700. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  7701. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  7702. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  7703. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  7704. json_object_object_add(component, "evse",evse);
  7705. json_object_object_add(eventData, "component", component);
  7706. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  7707. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  7708. json_object_object_add(eventData, "variable", variable);
  7709. json_object_array_add(eventDatas, eventData);
  7710. }
  7711. }
  7712. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  7713. random_uuid(guid);
  7714. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  7715. json_object_put(NotifyEvent);
  7716. LWS_Send(message);
  7717. sprintf(tempdata, "NotifyEvent,0");
  7718. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7719. {
  7720. result = PASS;
  7721. }
  7722. return result;
  7723. }
  7724. int sendNotifyMonitoringReportRequest()
  7725. {
  7726. mtrace();
  7727. int result = FAIL;
  7728. char message[4096]={0};
  7729. char guid[37]={0};
  7730. char tempdata[128]={0};
  7731. json_object *NotifyMonitoringReport = json_object_new_object();
  7732. json_object *monitors = json_object_new_array();
  7733. DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
  7734. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  7735. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  7736. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  7737. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  7738. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  7739. {
  7740. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  7741. {
  7742. json_object *monitor = json_object_new_object();
  7743. json_object *component = json_object_new_object();
  7744. json_object *evse = json_object_new_object();
  7745. json_object *variable = json_object_new_object();
  7746. json_object *variableMonitorings = json_object_new_array();
  7747. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  7748. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  7749. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  7750. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  7751. json_object_object_add(component, "evse",evse);
  7752. json_object_object_add(monitor, "component", component);
  7753. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  7754. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  7755. json_object_object_add(monitor, "variable", variable);
  7756. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  7757. {
  7758. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  7759. {
  7760. json_object *variableMonitoring = json_object_new_object();
  7761. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  7762. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  7763. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  7764. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  7765. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  7766. json_object_array_add(variableMonitorings, variableMonitoring);
  7767. }
  7768. }
  7769. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  7770. json_object_array_add(monitors, monitor);
  7771. }
  7772. }
  7773. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  7774. random_uuid(guid);
  7775. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  7776. json_object_put(NotifyMonitoringReport);
  7777. LWS_Send(message);
  7778. sprintf(tempdata, "NotifyMonitoringReport,0");
  7779. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7780. {
  7781. result = PASS;
  7782. }
  7783. return result;
  7784. }
  7785. int sendNotifyReportRequest()
  7786. {
  7787. mtrace();
  7788. int result = FAIL;
  7789. char message[4096]={0};
  7790. char guid[37]={0};
  7791. char tempdata[128]={0};
  7792. json_object *NotifyReport = json_object_new_object();
  7793. json_object *reportDatas = json_object_new_array();
  7794. DEBUG_INFO("sendNotifyReportRequest...\n");
  7795. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  7796. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  7797. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  7798. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  7799. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  7800. {
  7801. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  7802. {
  7803. json_object *reportData = json_object_new_object();
  7804. json_object *component = json_object_new_object();
  7805. json_object *evse = json_object_new_object();
  7806. json_object *variable = json_object_new_object();
  7807. json_object *variableAttributes = json_object_new_array();
  7808. json_object *variableCharacteristics = json_object_new_object();
  7809. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  7810. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  7811. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  7812. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  7813. json_object_object_add(component, "evse",evse);
  7814. json_object_object_add(reportData, "component", component);
  7815. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  7816. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  7817. json_object_object_add(reportData, "variable",variable);
  7818. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  7819. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  7820. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  7821. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  7822. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  7823. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  7824. {
  7825. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  7826. {
  7827. json_object *variableAttribute = json_object_new_object();
  7828. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  7829. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  7830. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  7831. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  7832. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  7833. json_object_array_add(variableAttributes, variableAttribute);
  7834. }
  7835. }
  7836. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  7837. json_object_array_add(reportDatas, reportData);
  7838. }
  7839. }
  7840. json_object_object_add(NotifyReport, "reportData", reportDatas);
  7841. random_uuid(guid);
  7842. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  7843. json_object_put(NotifyReport);
  7844. LWS_SendNow(message);
  7845. sprintf(tempdata, "NotifyReport,0");
  7846. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7847. {
  7848. result = PASS;
  7849. }
  7850. return result;
  7851. }
  7852. int sendPublishFirmwareStatusNotificationRequest()
  7853. {
  7854. mtrace();
  7855. int result = FAIL;
  7856. char message[4096]={0};
  7857. char guid[37]={0};
  7858. char tempdata[128]={0};
  7859. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  7860. json_object *locations = json_object_new_array();
  7861. DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
  7862. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  7863. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  7864. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  7865. {
  7866. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  7867. }
  7868. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  7869. random_uuid(guid);
  7870. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  7871. json_object_put(PublishFirmwareStatusNotification);
  7872. LWS_Send(message);
  7873. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  7874. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7875. {
  7876. result = PASS;
  7877. }
  7878. return result;
  7879. }
  7880. int sendReportChargingProfilesRequest(int gun_index)
  7881. {
  7882. mtrace();
  7883. int result = FAIL;
  7884. char message[4096]={0};
  7885. char guid[37]={0};
  7886. char tempdata[128]={0};
  7887. json_object *ReportChargingProfiles = json_object_new_object();
  7888. json_object *chargingProfiles = json_object_new_array();
  7889. DEBUG_INFO("sendReportChargingProfilesRequest...\n");
  7890. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  7891. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  7892. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  7893. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  7894. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  7895. {
  7896. json_object *chargingProfile = json_object_new_object();
  7897. json_object *chargingSchedules = json_object_new_array();
  7898. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  7899. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  7900. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  7901. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  7902. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  7903. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  7904. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  7905. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  7906. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  7907. {
  7908. json_object *chargingSchedule = json_object_new_object();
  7909. json_object *chargingSchedulePeriods = json_object_new_array();
  7910. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  7911. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  7912. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  7913. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  7914. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  7915. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  7916. {
  7917. json_object *chargingSchedulePeriod = json_object_new_object();
  7918. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  7919. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  7920. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  7921. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  7922. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  7923. }
  7924. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  7925. json_object_array_add(chargingSchedules, chargingSchedule);
  7926. }
  7927. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  7928. json_object_array_add(chargingProfiles, chargingProfile);
  7929. }
  7930. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  7931. random_uuid(guid);
  7932. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  7933. json_object_put(ReportChargingProfiles);
  7934. LWS_Send(message);
  7935. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  7936. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7937. {
  7938. result = PASS;
  7939. }
  7940. return result;
  7941. }
  7942. int sendReservationStatusUpdateRequest(int gun_index)
  7943. {
  7944. mtrace();
  7945. int result = FAIL;
  7946. char message[4096]={0};
  7947. char guid[37]={0};
  7948. char tempdata[128]={0};
  7949. json_object *ReservationStatusUpdate = json_object_new_object();
  7950. DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
  7951. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  7952. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  7953. random_uuid(guid);
  7954. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  7955. json_object_put(ReservationStatusUpdate);
  7956. LWS_Send(message);
  7957. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  7958. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7959. {
  7960. result = PASS;
  7961. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  7962. }
  7963. return result;
  7964. }
  7965. int sendSecurityEventNotificationRequest()
  7966. {
  7967. mtrace();
  7968. int result = FAIL;
  7969. char message[4096]={0};
  7970. char guid[37]={0};
  7971. char tempdata[128]={0};
  7972. json_object *SecurityEventNotification = json_object_new_object();
  7973. DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
  7974. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  7975. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  7976. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techInfo));
  7977. random_uuid(guid);
  7978. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  7979. json_object_put(SecurityEventNotification);
  7980. LWS_Send(message);
  7981. sprintf(tempdata, "SecurityEventNotification,0");
  7982. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7983. {
  7984. result = PASS;
  7985. }
  7986. return result;
  7987. }
  7988. int sendSignCertificateRequest(CertificateSigningUseEnumType certType)
  7989. {
  7990. mtrace();
  7991. int result = FAIL;
  7992. char message[4096]={0};
  7993. char guid[37]={0};
  7994. char tempdata[128]={0};
  7995. json_object *SignCertificate = json_object_new_object();
  7996. DEBUG_INFO("sendSignCertificateRequest...\n");
  7997. // Read csr file content
  7998. memset(ShmOCPP20Data->SignCertificate.csr, 0x00, ARRAY_SIZE(ShmOCPP20Data->SignCertificate.csr));
  7999. FILE *fp=fopen(((certType == CertificateSignedStatusEnumType_V2GCertificate)?"/Storage/OCPP/certV2G.csr":"/Storage/OCPP/certCP.csr"),"r");
  8000. char *line = NULL;
  8001. size_t len = 0;
  8002. while(getline(&line, &len, fp) != -1)
  8003. {
  8004. if((strstr(line, "BEGIN CERTIFICATE REQUEST") == NULL) && (strstr(line, "END CERTIFICATE REQUEST") == NULL))
  8005. {
  8006. memcpy(&ShmOCPP20Data->SignCertificate.csr[strlen((char*)ShmOCPP20Data->SignCertificate.csr)], line, (strlen(line)-1));
  8007. }
  8008. }
  8009. fclose(fp);
  8010. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  8011. sprintf((char*)ShmOCPP20Data->SignCertificate.certificateType, CertificateSigningUseEnumTypeStr[certType]);
  8012. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  8013. random_uuid(guid);
  8014. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  8015. json_object_put(SignCertificate);
  8016. LWS_Send(message);
  8017. sprintf(tempdata, "SignCertificate,0");
  8018. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8019. {
  8020. result = PASS;
  8021. }
  8022. return result;
  8023. }
  8024. int sendStatusNotificationRequest(int gun_index)
  8025. {
  8026. mtrace();
  8027. int result = FAIL;
  8028. char message[600]={0};
  8029. char guid[37];
  8030. int currentStatus = 0;
  8031. struct timeval tmnow;
  8032. struct tm *tm;
  8033. char buf[28];//, usec_buf[6];
  8034. char tempdata[65]={0};
  8035. int tempIndex = 0;
  8036. uint8_t isStateChanged = TRUE;
  8037. DEBUG_INFO("sendStatusNotificationRequest...\n");
  8038. gettimeofday(&tmnow, NULL);
  8039. time_t t;
  8040. t = time(NULL);
  8041. /*UTC time and date*/
  8042. tm = gmtime(&t);
  8043. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  8044. #if 0 // remove temporally
  8045. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  8046. strcat(buf,".");
  8047. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  8048. strcat(buf,usec_buf);
  8049. #endif
  8050. printf("%s",buf);
  8051. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  8052. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  8053. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  8054. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  8055. /*
  8056. enum _SYSTEM_STATUS
  8057. {
  8058. S_BOOTING = 0,
  8059. S_IDLE, = 1
  8060. S_AUTHORIZING, =2
  8061. S_REASSIGN_CHECK, =3
  8062. S_REASSIGN, =4
  8063. S_PRECHARGE, =5
  8064. S_PREPARING_FOR_EV, =6
  8065. S_PREPARING_FOR_EVSE, =7
  8066. S_CHARGING, =8
  8067. S_TERMINATING, =9
  8068. S_COMPLETE, =10
  8069. S_ALARM, =11
  8070. S_FAULT =12
  8071. }
  8072. */
  8073. //check Transaction active
  8074. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  8075. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  8076. {
  8077. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8078. {
  8079. tempIndex = ((gun_index==2) ? 1: 0);
  8080. }
  8081. else
  8082. {
  8083. tempIndex = gun_index;
  8084. }
  8085. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8086. {
  8087. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  8088. {
  8089. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  8090. {
  8091. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8092. {
  8093. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8094. }
  8095. else
  8096. {
  8097. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8098. }
  8099. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8100. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8101. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8102. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8103. }
  8104. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8105. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8106. ) //S_PRECHARGE
  8107. {
  8108. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8109. }
  8110. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8111. {
  8112. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8113. }
  8114. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8115. {
  8116. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8117. }
  8118. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8119. {
  8120. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8121. }
  8122. 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
  8123. {
  8124. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8125. }
  8126. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8127. {
  8128. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8129. }
  8130. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8131. {
  8132. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8133. }
  8134. } //end of the same index
  8135. }//end of for CHAdeMO_QUANTITY
  8136. }
  8137. else if(gunType[gun_index] == GUN_TYPE_CCS)
  8138. {
  8139. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8140. {
  8141. tempIndex = ((gun_index==2) ? 1: 0);
  8142. }
  8143. else
  8144. {
  8145. tempIndex = gun_index;
  8146. }
  8147. for (int index = 0; index < CCS_QUANTITY; index++)
  8148. {
  8149. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  8150. {
  8151. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8152. {
  8153. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  8154. {
  8155. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8156. }
  8157. else
  8158. {
  8159. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8160. }
  8161. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8162. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8163. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8164. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8165. }
  8166. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8167. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8168. ) //S_PRECHARGE
  8169. {
  8170. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8171. }
  8172. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8173. {
  8174. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8175. }
  8176. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8177. {
  8178. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8179. }
  8180. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  8181. {
  8182. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8183. }
  8184. 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
  8185. {
  8186. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  8187. }
  8188. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  8189. {
  8190. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8191. }
  8192. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8193. {
  8194. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8195. }
  8196. } //end of the same index
  8197. } // end of for CCS_QUANTITY
  8198. }
  8199. else if(gunType[gun_index] == GUN_TYPE_GBT)
  8200. {
  8201. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8202. {
  8203. tempIndex = ((gun_index==2) ? 1: 0);
  8204. }
  8205. else
  8206. {
  8207. tempIndex = gun_index;
  8208. }
  8209. for (int index = 0; index < GB_QUANTITY; index++)
  8210. {
  8211. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  8212. {
  8213. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8214. {
  8215. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8216. {
  8217. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8218. }
  8219. else
  8220. {
  8221. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8222. }
  8223. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8224. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8225. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8226. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8227. }
  8228. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8229. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8230. ) //S_PRECHARGE
  8231. {
  8232. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8233. }
  8234. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8235. {
  8236. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8237. }
  8238. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8239. {
  8240. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8241. }
  8242. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8243. {
  8244. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8245. }
  8246. 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
  8247. {
  8248. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8249. }
  8250. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  8251. {
  8252. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8253. }
  8254. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8255. {
  8256. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8257. }
  8258. } //end of the same index
  8259. } // end of for GB_QUANTITY
  8260. }
  8261. else if(gunType[gun_index] == GUN_TYPE_DO)
  8262. {
  8263. tempIndex = gun_index;
  8264. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8265. {
  8266. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  8267. {
  8268. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8269. {
  8270. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8271. {
  8272. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8273. }
  8274. else
  8275. {
  8276. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8277. }
  8278. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8279. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8280. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8281. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8282. }
  8283. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8284. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8285. ) //S_PRECHARGE
  8286. {
  8287. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8288. }
  8289. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8290. {
  8291. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8292. }
  8293. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8294. {
  8295. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8296. }
  8297. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8298. {
  8299. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8300. }
  8301. 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
  8302. {
  8303. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8304. }
  8305. 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
  8306. {
  8307. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8308. }
  8309. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8310. {
  8311. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8312. }
  8313. } //end of the same index
  8314. }
  8315. }
  8316. else
  8317. {
  8318. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8319. {
  8320. tempIndex = 2;
  8321. }
  8322. else
  8323. {
  8324. tempIndex = gun_index;
  8325. }
  8326. for (int index = 0; index < AC_QUANTITY; index++)
  8327. {
  8328. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  8329. {
  8330. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  8331. {
  8332. 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))
  8333. {
  8334. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8335. }
  8336. else
  8337. {
  8338. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8339. }
  8340. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8341. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8342. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8343. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8344. }
  8345. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  8346. {
  8347. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8348. }
  8349. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  8350. {
  8351. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8352. }
  8353. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  8354. {
  8355. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8356. }
  8357. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8358. {
  8359. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8360. }
  8361. 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
  8362. {
  8363. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8364. }
  8365. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8366. {
  8367. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8368. }
  8369. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8370. {
  8371. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8372. }
  8373. }//end of the same index
  8374. }//end of for AC_QUANTITY
  8375. }
  8376. //it's option
  8377. if((strstr((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]) != NULL) &&
  8378. !cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq)
  8379. {
  8380. isStateChanged = FALSE;
  8381. }
  8382. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  8383. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  8384. random_uuid(guid);
  8385. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  8386. , MESSAGE_TYPE_CALL
  8387. , guid
  8388. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  8389. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  8390. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  8391. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  8392. if((server_sign == TRUE) && isStateChanged)
  8393. {
  8394. LWS_Send(message);
  8395. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  8396. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8397. {
  8398. result = PASS;
  8399. }
  8400. }
  8401. else
  8402. {
  8403. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  8404. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  8405. result = PASS;
  8406. }
  8407. return result;
  8408. }
  8409. int sendTransactionEventRequest(int gun_index)
  8410. {
  8411. mtrace();
  8412. int result = FAIL;
  8413. char message[1024*20]={0};
  8414. char guid[37]={0};
  8415. char tempdata[128]={0};
  8416. uint8_t tempIndex;
  8417. json_object *TransactionEvent = json_object_new_object();
  8418. json_object *transactionInfo = json_object_new_object();
  8419. json_object *idToken = json_object_new_object();
  8420. json_object *evse = json_object_new_object();
  8421. json_object *meterValues = json_object_new_array();
  8422. char TempStopTransaction[256];
  8423. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  8424. DEBUG_INFO("sendTransactionEventRequest...\n");
  8425. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  8426. {
  8427. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8428. {
  8429. tempIndex = ((gun_index==2) ? 1: 0);
  8430. }
  8431. else
  8432. {
  8433. tempIndex = gun_index;
  8434. }
  8435. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8436. {
  8437. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  8438. {
  8439. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8440. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8441. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8442. else
  8443. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8444. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8445. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8446. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8447. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  8448. {
  8449. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8450. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8451. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8452. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8453. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8454. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8455. {
  8456. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8457. }
  8458. else
  8459. {
  8460. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8461. }
  8462. }
  8463. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8464. {
  8465. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8466. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8467. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8468. }
  8469. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8470. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8471. ) //S_PRECHARGE
  8472. {
  8473. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8474. {
  8475. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8476. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  8477. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartIdType]);
  8478. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8479. }
  8480. else
  8481. {
  8482. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8483. }
  8484. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8485. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8486. }
  8487. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8488. {
  8489. storeTempStopTransaction(gun_index);
  8490. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8491. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8492. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8493. }
  8494. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8495. {
  8496. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8497. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8498. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8499. if((access(TempStopTransaction,F_OK))!=-1)
  8500. {
  8501. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8502. }
  8503. }
  8504. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8505. {
  8506. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8507. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8508. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8509. }
  8510. 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
  8511. {
  8512. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8513. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8514. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8515. }
  8516. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8517. {
  8518. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8519. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8520. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8521. }
  8522. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8523. {
  8524. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8525. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8526. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8527. }
  8528. } //end of the same index
  8529. }//end of for CHAdeMO_QUANTITY
  8530. }
  8531. else if(gunType[gun_index] == GUN_TYPE_CCS)
  8532. {
  8533. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8534. {
  8535. tempIndex = ((gun_index==2) ? 1: 0);
  8536. }
  8537. else
  8538. {
  8539. tempIndex = gun_index;
  8540. }
  8541. for (int index = 0; index < CCS_QUANTITY; index++)
  8542. {
  8543. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  8544. {
  8545. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8546. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8547. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8548. else
  8549. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8550. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8551. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8552. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8553. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8554. {
  8555. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8556. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8557. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8558. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8559. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8560. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  8561. {
  8562. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8563. }
  8564. else
  8565. {
  8566. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8567. }
  8568. }
  8569. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8570. {
  8571. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8572. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8573. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8574. }
  8575. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8576. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8577. ) //S_PRECHARGE
  8578. {
  8579. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8580. {
  8581. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8582. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  8583. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartIdType]);
  8584. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8585. }
  8586. else
  8587. {
  8588. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8589. }
  8590. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8591. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8592. }
  8593. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8594. {
  8595. storeTempStopTransaction(gun_index);
  8596. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8597. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8598. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8599. }
  8600. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8601. {
  8602. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8603. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8604. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8605. if((access(TempStopTransaction,F_OK))!=-1)
  8606. {
  8607. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8608. }
  8609. }
  8610. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8611. {
  8612. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8613. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8614. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8615. }
  8616. 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
  8617. {
  8618. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8619. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8620. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8621. }
  8622. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8623. {
  8624. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8625. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8626. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8627. }
  8628. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8629. {
  8630. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8631. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8632. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8633. }
  8634. } //end of the same index
  8635. } // end of for CCS_QUANTITY
  8636. }
  8637. else if(gunType[gun_index] == GUN_TYPE_GBT)
  8638. {
  8639. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8640. {
  8641. tempIndex = ((gun_index==2) ? 1: 0);
  8642. }
  8643. else
  8644. {
  8645. tempIndex = gun_index;
  8646. }
  8647. for (int index = 0; index < GB_QUANTITY; index++)
  8648. {
  8649. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  8650. {
  8651. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8652. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8653. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8654. else
  8655. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8656. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8657. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8658. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8659. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8660. {
  8661. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8662. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8663. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8664. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8665. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8666. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  8667. {
  8668. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8669. }
  8670. else
  8671. {
  8672. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8673. }
  8674. }
  8675. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8676. {
  8677. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8678. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8679. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8680. }
  8681. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8682. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8683. ) //S_PRECHARGE
  8684. {
  8685. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8686. {
  8687. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8688. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  8689. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartIdType]);
  8690. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8691. }
  8692. else
  8693. {
  8694. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8695. }
  8696. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8697. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8698. }
  8699. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8700. {
  8701. storeTempStopTransaction(gun_index);
  8702. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8703. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8704. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8705. }
  8706. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8707. {
  8708. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8709. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8710. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8711. if((access(TempStopTransaction,F_OK))!=-1)
  8712. {
  8713. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8714. }
  8715. }
  8716. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8717. {
  8718. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8719. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8720. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8721. }
  8722. 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
  8723. {
  8724. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8725. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8726. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8727. }
  8728. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8729. {
  8730. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8731. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8732. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8733. }
  8734. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8735. {
  8736. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8737. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8738. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8739. }
  8740. } //end of the same index
  8741. } // end of for GB_QUANTITY
  8742. }
  8743. else if(gunType[gun_index] == GUN_TYPE_DO)
  8744. {
  8745. tempIndex = gun_index;
  8746. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8747. {
  8748. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  8749. {
  8750. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8751. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8752. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8753. else
  8754. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8755. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8756. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8757. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8758. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8759. {
  8760. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8761. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8762. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8763. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8764. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8765. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8766. {
  8767. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8768. }
  8769. else
  8770. {
  8771. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8772. }
  8773. }
  8774. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8775. {
  8776. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8777. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8778. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8779. }
  8780. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8781. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8782. ) //S_PRECHARGE
  8783. {
  8784. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8785. {
  8786. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8787. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  8788. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartIdType]);
  8789. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8790. }
  8791. else
  8792. {
  8793. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8794. }
  8795. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8796. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8797. }
  8798. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8799. {
  8800. storeTempStopTransaction(gun_index);
  8801. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8802. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8803. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8804. }
  8805. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8806. {
  8807. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8808. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8809. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8810. if((access(TempStopTransaction,F_OK))!=-1)
  8811. {
  8812. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8813. }
  8814. }
  8815. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8816. {
  8817. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8818. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8819. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8820. }
  8821. 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
  8822. {
  8823. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8824. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8825. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8826. }
  8827. 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
  8828. {
  8829. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8830. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8831. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8832. }
  8833. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8834. {
  8835. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8836. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8837. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8838. }
  8839. } //end of the same index
  8840. }
  8841. }
  8842. else
  8843. {
  8844. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8845. {
  8846. tempIndex = 2;
  8847. }
  8848. else
  8849. {
  8850. tempIndex = gun_index;
  8851. }
  8852. for (int index = 0; index < AC_QUANTITY; index++)
  8853. {
  8854. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  8855. {
  8856. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8857. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8858. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8859. else
  8860. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8861. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8862. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8863. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8864. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  8865. {
  8866. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8867. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8868. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8869. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8870. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8871. 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))
  8872. {
  8873. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8874. }
  8875. else
  8876. {
  8877. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8878. }
  8879. }
  8880. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8881. {
  8882. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8883. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8884. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8885. }
  8886. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8887. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8888. ) //S_PRECHARGE
  8889. {
  8890. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8891. {
  8892. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8893. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  8894. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartIdType]);
  8895. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8896. }
  8897. else
  8898. {
  8899. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8900. }
  8901. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8902. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8903. }
  8904. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8905. {
  8906. storeTempStopTransaction(gun_index);
  8907. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8908. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8909. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8910. }
  8911. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8912. {
  8913. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8914. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8915. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8916. if((access(TempStopTransaction,F_OK))!=-1)
  8917. {
  8918. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8919. }
  8920. }
  8921. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8922. {
  8923. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8924. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8925. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8926. }
  8927. 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
  8928. {
  8929. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8930. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8931. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8932. }
  8933. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8934. {
  8935. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8936. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8937. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8938. }
  8939. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8940. {
  8941. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8942. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8943. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8944. }
  8945. }//end of the same index
  8946. }//end of for AC_QUANTITY
  8947. }
  8948. // Message
  8949. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8950. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  8951. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  8952. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  8953. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  8954. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  8955. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  8956. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  8957. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  8958. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  8959. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  8960. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  8961. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  8962. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  8963. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  8964. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  8965. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  8966. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  8967. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  8968. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  8969. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  8970. {
  8971. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  8972. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  8973. json_object_object_add(TransactionEvent, "idToken", idToken);
  8974. }
  8975. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  8976. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  8977. json_object_object_add(TransactionEvent, "evse", evse);
  8978. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  8979. {
  8980. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  8981. {
  8982. json_object *meterValue = json_object_new_object();
  8983. json_object *sampledValues = json_object_new_array();
  8984. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  8985. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  8986. {
  8987. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  8988. ((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) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) == 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) == 0)))
  8989. {
  8990. if(((strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, (char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) != NULL)) ||
  8991. (strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) == NULL))
  8992. {
  8993. json_object *sampledValue = json_object_new_object();
  8994. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  8995. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  8996. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  8997. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  8998. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  8999. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  9000. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  9001. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  9002. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  9003. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  9004. {
  9005. json_object *unitOfMeasure = json_object_new_object();
  9006. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  9007. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  9008. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  9009. }
  9010. json_object_array_add(sampledValues, sampledValue);
  9011. }
  9012. }
  9013. }
  9014. json_object_object_add(meterValue, "sampledValue", sampledValues);
  9015. json_object_array_add(meterValues, meterValue);
  9016. }
  9017. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  9018. }
  9019. random_uuid(guid);
  9020. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  9021. json_object_put(TransactionEvent);
  9022. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  9023. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  9024. {
  9025. result = PASS;
  9026. }
  9027. queue_operation(QUEUE_OPERATION_ADD, guid, message);
  9028. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Started]) != NULL)
  9029. OCPP_insert_transaction_msg(YES, message);
  9030. else if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL)
  9031. OCPP_insert_transaction_msg(NO, message);
  9032. return result;
  9033. }
  9034. //==========================================
  9035. // send confirm routine
  9036. //==========================================
  9037. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  9038. {
  9039. mtrace();
  9040. int result = FAIL;
  9041. char message[4096]={0};
  9042. json_object *CancelReservation = json_object_new_object();
  9043. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  9044. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  9045. sprintf(message,"[%d,\"%s\",%s]"
  9046. ,MESSAGE_TYPE_CALLRESULT
  9047. ,uuid
  9048. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  9049. json_object_put(CancelReservation);
  9050. ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf = OFF;
  9051. LWS_Send(message);
  9052. result = TRUE;
  9053. return result;
  9054. }
  9055. int sendCertificateSignedConfirmation(char *uuid)
  9056. {
  9057. mtrace();
  9058. int result = FAIL;
  9059. char message[4096]={0};
  9060. json_object *CertificateSigned = json_object_new_object();
  9061. json_object *statusInfo = json_object_new_object();
  9062. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  9063. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  9064. if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode) > 0)
  9065. {
  9066. json_object_object_add(statusInfo, "reasonCode", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode));
  9067. if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo) > 0)
  9068. json_object_object_add(statusInfo, "statadditionalInfous", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo));
  9069. }
  9070. json_object_object_add(CertificateSigned, "statusInfo", statusInfo);
  9071. sprintf(message,"[%d,\"%s\",%s]"
  9072. ,MESSAGE_TYPE_CALLRESULT
  9073. ,uuid
  9074. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  9075. json_object_put(CertificateSigned);
  9076. LWS_Send(message);
  9077. result = TRUE;
  9078. return result;
  9079. }
  9080. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  9081. {
  9082. mtrace();
  9083. int result = FAIL;
  9084. char message[4096]={0};
  9085. json_object *ChangeAvailability = json_object_new_object();
  9086. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  9087. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  9088. sprintf(message,"[%d,\"%s\",%s]"
  9089. ,MESSAGE_TYPE_CALLRESULT
  9090. ,uuid
  9091. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  9092. json_object_put(ChangeAvailability);
  9093. LWS_Send(message);
  9094. result = TRUE;
  9095. return result;
  9096. }
  9097. int sendClearCacheConfirmation(char *uuid)
  9098. {
  9099. mtrace();
  9100. int result = FAIL;
  9101. char message[4096]={0};
  9102. json_object *ClearCache = json_object_new_object();
  9103. DEBUG_INFO("sendClearCacheConfirmation...\n");
  9104. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  9105. sprintf(message,"[%d,\"%s\",%s]"
  9106. ,MESSAGE_TYPE_CALLRESULT
  9107. ,uuid
  9108. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  9109. json_object_put(ClearCache);
  9110. LWS_Send(message);
  9111. result = TRUE;
  9112. return result;
  9113. }
  9114. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  9115. {
  9116. mtrace();
  9117. int result = FAIL;
  9118. char message[500]={0};
  9119. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  9120. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  9121. LWS_Send(message);
  9122. return result;
  9123. }
  9124. int sendClearDisplayMessageConfirmation(char *uuid)
  9125. {
  9126. mtrace();
  9127. int result = FAIL;
  9128. char message[4096]={0};
  9129. json_object *ClearDisplayMessage = json_object_new_object();
  9130. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  9131. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  9132. sprintf(message,"[%d,\"%s\",%s]"
  9133. ,MESSAGE_TYPE_CALLRESULT
  9134. ,uuid
  9135. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  9136. json_object_put(ClearDisplayMessage);
  9137. LWS_Send(message);
  9138. result = TRUE;
  9139. return result;
  9140. }
  9141. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  9142. {
  9143. mtrace();
  9144. int result = FAIL;
  9145. char message[4096]={0};
  9146. json_object *ClearVariableMonitoring = json_object_new_object();
  9147. json_object *clearMonitoringResults = json_object_new_array();
  9148. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  9149. for(int idx=0;idx<variableQuantity;idx++)
  9150. {
  9151. json_object *clearMonitoringResult = json_object_new_object();
  9152. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  9153. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  9154. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  9155. }
  9156. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  9157. sprintf(message,"[%d,\"%s\",%s]"
  9158. ,MESSAGE_TYPE_CALLRESULT
  9159. ,uuid
  9160. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  9161. json_object_put(ClearVariableMonitoring);
  9162. LWS_Send(message);
  9163. result = TRUE;
  9164. return result;
  9165. }
  9166. int sendCostUpdatedConfirmation(char *uuid)
  9167. {
  9168. mtrace();
  9169. int result = FAIL;
  9170. char message[4096]={0};
  9171. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  9172. sprintf(message,"[%d,\"%s\",{}]"
  9173. ,MESSAGE_TYPE_CALLRESULT
  9174. ,uuid);
  9175. LWS_Send(message);
  9176. result = TRUE;
  9177. return result;
  9178. }
  9179. int sendCustomerInformationConfirmation(char *uuid)
  9180. {
  9181. mtrace();
  9182. int result = FAIL;
  9183. char message[4096]={0};
  9184. json_object *CustomerInformation = json_object_new_object();
  9185. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  9186. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  9187. sprintf(message,"[%d,\"%s\",%s]"
  9188. ,MESSAGE_TYPE_CALLRESULT
  9189. ,uuid
  9190. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  9191. json_object_put(CustomerInformation);
  9192. LWS_Send(message);
  9193. result = TRUE;
  9194. return result;
  9195. }
  9196. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  9197. {
  9198. mtrace();
  9199. int result = FAIL;
  9200. char message[4096]={0};
  9201. json_object *DataTransfer = json_object_new_object();
  9202. DEBUG_INFO("sendDataTransferConfirmation...\n");
  9203. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  9204. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  9205. sprintf(message,"[%d,\"%s\",%s]"
  9206. ,MESSAGE_TYPE_CALLRESULT
  9207. ,uuid
  9208. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  9209. json_object_put(DataTransfer);
  9210. LWS_Send(message);
  9211. result = TRUE;
  9212. return result;
  9213. }
  9214. int sendDeleteCertificateConfirmation(char *uuid)
  9215. {
  9216. mtrace();
  9217. int result = FAIL;
  9218. char message[4096]={0};
  9219. json_object *DeleteCertificate = json_object_new_object();
  9220. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  9221. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  9222. sprintf(message,"[%d,\"%s\",%s]"
  9223. ,MESSAGE_TYPE_CALLRESULT
  9224. ,uuid
  9225. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  9226. json_object_put(DeleteCertificate);
  9227. LWS_Send(message);
  9228. result = TRUE;
  9229. return result;
  9230. }
  9231. int sendGetBaseReportConfirmation(char *uuid)
  9232. {
  9233. mtrace();
  9234. int result = FAIL;
  9235. char message[4096]={0};
  9236. json_object *GetBaseReport = json_object_new_object();
  9237. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  9238. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  9239. sprintf(message,"[%d,\"%s\",%s]"
  9240. ,MESSAGE_TYPE_CALLRESULT
  9241. ,uuid
  9242. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  9243. json_object_put(GetBaseReport);
  9244. LWS_Send(message);
  9245. result = TRUE;
  9246. return result;
  9247. }
  9248. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  9249. {
  9250. mtrace();
  9251. int result = FAIL;
  9252. char message[4096]={0};
  9253. json_object *GetChargingProfiles = json_object_new_object();
  9254. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  9255. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  9256. sprintf(message,"[%d,\"%s\",%s]"
  9257. ,MESSAGE_TYPE_CALLRESULT
  9258. ,uuid
  9259. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  9260. json_object_put(GetChargingProfiles);
  9261. LWS_Send(message);
  9262. result = TRUE;
  9263. return result;
  9264. }
  9265. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  9266. {
  9267. mtrace();
  9268. int result = FAIL;
  9269. char message[4096]={0};
  9270. int CompositeScheduleIndex = 0;
  9271. json_object *GetCompositeSchedule = json_object_new_object();
  9272. json_object *schedule = json_object_new_object();
  9273. json_object *chargingSchedule = json_object_new_object();
  9274. json_object *chargingSchedulePeriod = json_object_new_array();
  9275. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  9276. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  9277. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  9278. if(nPeriod == 0)
  9279. {
  9280. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  9281. {
  9282. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  9283. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  9284. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  9285. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  9286. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  9287. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  9288. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  9289. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  9290. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  9291. {
  9292. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  9293. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  9294. {
  9295. json_object *Period = json_object_new_object();
  9296. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  9297. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  9298. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  9299. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  9300. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  9301. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  9302. json_object_array_add(chargingSchedulePeriod, Period);
  9303. }
  9304. }
  9305. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  9306. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  9307. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  9308. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  9309. }
  9310. }
  9311. else
  9312. {
  9313. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  9314. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  9315. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  9316. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  9317. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  9318. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  9319. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  9320. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  9321. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  9322. {
  9323. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  9324. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  9325. {
  9326. json_object *Period = json_object_new_object();
  9327. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  9328. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  9329. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  9330. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  9331. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  9332. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  9333. json_object_array_add(chargingSchedulePeriod, Period);
  9334. }
  9335. }
  9336. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  9337. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  9338. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  9339. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  9340. }
  9341. sprintf(message,"[%d,\"%s\",%s]"
  9342. ,MESSAGE_TYPE_CALLRESULT
  9343. ,uuid
  9344. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  9345. json_object_put(GetCompositeSchedule);
  9346. LWS_Send(message);
  9347. result = TRUE;
  9348. return result;
  9349. }
  9350. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  9351. {
  9352. mtrace();
  9353. int result = FAIL;
  9354. char message[4096]={0};
  9355. json_object *GetGetDisplayMessages = json_object_new_object();
  9356. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  9357. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  9358. sprintf(message,"[%d,\"%s\",%s]"
  9359. ,MESSAGE_TYPE_CALLRESULT
  9360. ,uuid
  9361. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  9362. json_object_put(GetGetDisplayMessages);
  9363. LWS_Send(message);
  9364. result = TRUE;
  9365. return result;
  9366. }
  9367. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  9368. {
  9369. mtrace();
  9370. int result = FAIL;
  9371. char message[4096]={0};
  9372. json_object *GetInstalledCertificateIds = json_object_new_object();
  9373. json_object *certificateHashDataChains = json_object_new_array();
  9374. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  9375. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  9376. for(int idx=0;idx<certQuantity;idx++)
  9377. {
  9378. json_object *cert = json_object_new_object();
  9379. json_object *certificateHashData = json_object_new_object();
  9380. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  9381. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  9382. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  9383. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  9384. json_object_object_add(cert, "certificateHashData", certificateHashData);
  9385. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  9386. json_object_array_add(certificateHashDataChains, cert);
  9387. }
  9388. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  9389. sprintf(message,"[%d,\"%s\",%s]"
  9390. ,MESSAGE_TYPE_CALLRESULT
  9391. ,uuid
  9392. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  9393. json_object_put(GetInstalledCertificateIds);
  9394. LWS_Send(message);
  9395. result = TRUE;
  9396. return result;
  9397. }
  9398. int sendGetLocalListVersionConfirmation(char *uuid)
  9399. {
  9400. mtrace();
  9401. int result = FAIL;
  9402. char message[4096]={0};
  9403. json_object *GetLocalListVersion = json_object_new_object();
  9404. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  9405. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  9406. sprintf(message,"[%d,\"%s\",%s]"
  9407. ,MESSAGE_TYPE_CALLRESULT
  9408. ,uuid
  9409. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  9410. json_object_put(GetLocalListVersion);
  9411. LWS_Send(message);
  9412. result = TRUE;
  9413. return result;
  9414. }
  9415. int sendGetLogConfirmation(char *uuid)
  9416. {
  9417. mtrace();
  9418. int result = FAIL;
  9419. char message[4096]={0};
  9420. json_object *GetLog = json_object_new_object();
  9421. DEBUG_INFO("sendGetLogConfirmation...\n");
  9422. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  9423. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  9424. sprintf(message,"[%d,\"%s\",%s]"
  9425. ,MESSAGE_TYPE_CALLRESULT
  9426. ,uuid
  9427. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  9428. json_object_put(GetLog);
  9429. LWS_Send(message);
  9430. result = TRUE;
  9431. return result;
  9432. }
  9433. int sendGetMonitoringReportConfirmation(char *uuid)
  9434. {
  9435. mtrace();
  9436. int result = FAIL;
  9437. char message[4096]={0};
  9438. json_object *GetMonitoringReport = json_object_new_object();
  9439. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  9440. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  9441. sprintf(message,"[%d,\"%s\",%s]"
  9442. ,MESSAGE_TYPE_CALLRESULT
  9443. ,uuid
  9444. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  9445. json_object_put(GetMonitoringReport);
  9446. LWS_Send(message);
  9447. result = TRUE;
  9448. return result;
  9449. }
  9450. int sendGetReportConfirmation(char *uuid)
  9451. {
  9452. mtrace();
  9453. int result = FAIL;
  9454. char message[4096]={0};
  9455. json_object *GetReport = json_object_new_object();
  9456. DEBUG_INFO("sendGetReportConfirmation...\n");
  9457. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  9458. sprintf(message,"[%d,\"%s\",%s]"
  9459. ,MESSAGE_TYPE_CALLRESULT
  9460. ,uuid
  9461. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  9462. json_object_put(GetReport);
  9463. LWS_Send(message);
  9464. result = TRUE;
  9465. return result;
  9466. }
  9467. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  9468. {
  9469. mtrace();
  9470. int result = FAIL;
  9471. char message[4096]={0};
  9472. json_object *GetTransactionStatus = json_object_new_object();
  9473. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  9474. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  9475. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  9476. sprintf(message,"[%d,\"%s\",%s]"
  9477. ,MESSAGE_TYPE_CALLRESULT
  9478. ,uuid
  9479. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  9480. json_object_put(GetTransactionStatus);
  9481. LWS_Send(message);
  9482. result = TRUE;
  9483. return result;
  9484. }
  9485. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  9486. {
  9487. mtrace();
  9488. int result = FAIL;
  9489. char message[4096]={0};
  9490. json_object *GetVariables = json_object_new_object();
  9491. json_object *getVariableResults = json_object_new_array();
  9492. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  9493. for(int idx=0;idx<variableQuantity;idx++)
  9494. {
  9495. json_object *variableResult = json_object_new_object();
  9496. json_object *component = json_object_new_object();
  9497. json_object *variable = json_object_new_object();
  9498. json_object *evse = json_object_new_object();
  9499. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  9500. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  9501. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  9502. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  9503. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  9504. json_object_object_add(component, "evse", evse);
  9505. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  9506. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  9507. json_object_object_add(variableResult, "component", component);
  9508. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  9509. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  9510. json_object_object_add(variableResult, "variable", variable);
  9511. json_object_array_add(getVariableResults, variableResult);
  9512. }
  9513. json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
  9514. sprintf(message,"[%d,\"%s\",%s]"
  9515. ,MESSAGE_TYPE_CALLRESULT
  9516. ,uuid
  9517. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  9518. json_object_put(GetVariables);
  9519. LWS_Send(message);
  9520. result = TRUE;
  9521. return result;
  9522. }
  9523. int sendInstallCertificateConfirmation(char *uuid)
  9524. {
  9525. mtrace();
  9526. int result = FAIL;
  9527. char message[4096]={0};
  9528. json_object *InstallCertificate = json_object_new_object();
  9529. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  9530. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  9531. sprintf(message,"[%d,\"%s\",%s]"
  9532. ,MESSAGE_TYPE_CALLRESULT
  9533. ,uuid
  9534. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  9535. json_object_put(InstallCertificate);
  9536. LWS_Send(message);
  9537. result = TRUE;
  9538. return result;
  9539. }
  9540. int sendPublishFirmwareConfirmation(char *uuid)
  9541. {
  9542. mtrace();
  9543. int result = FAIL;
  9544. char message[4096]={0};
  9545. json_object *PublishFirmware = json_object_new_object();
  9546. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  9547. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  9548. sprintf(message,"[%d,\"%s\",%s]"
  9549. ,MESSAGE_TYPE_CALLRESULT
  9550. ,uuid
  9551. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  9552. json_object_put(PublishFirmware);
  9553. LWS_Send(message);
  9554. result = TRUE;
  9555. return result;
  9556. }
  9557. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  9558. {
  9559. mtrace();
  9560. int result = FAIL;
  9561. char message[4096]={0};
  9562. json_object *RemoteStartTransaction = json_object_new_object();
  9563. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  9564. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  9565. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  9566. sprintf(message,"[%d,\"%s\",%s]"
  9567. ,MESSAGE_TYPE_CALLRESULT
  9568. ,uuid
  9569. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  9570. json_object_put(RemoteStartTransaction);
  9571. LWS_Send(message);
  9572. result = TRUE;
  9573. return result;
  9574. }
  9575. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  9576. {
  9577. mtrace();
  9578. int result = FAIL;
  9579. char message[4096]={0};
  9580. json_object *RemoteStopTransaction = json_object_new_object();
  9581. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  9582. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  9583. sprintf(message,"[%d,\"%s\",%s]"
  9584. ,MESSAGE_TYPE_CALLRESULT
  9585. ,uuid
  9586. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  9587. json_object_put(RemoteStopTransaction);
  9588. LWS_Send(message);
  9589. result = TRUE;
  9590. return result;
  9591. }
  9592. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  9593. {
  9594. mtrace();
  9595. int result = FAIL;
  9596. char message[4096]={0};
  9597. json_object *ReserveNow = json_object_new_object();
  9598. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  9599. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  9600. sprintf(message,"[%d,\"%s\",%s]"
  9601. ,MESSAGE_TYPE_CALLRESULT
  9602. ,uuid
  9603. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  9604. json_object_put(ReserveNow);
  9605. LWS_Send(message);
  9606. result = TRUE;
  9607. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  9608. return result;
  9609. }
  9610. int sendResetConfirmation(char *uuid)
  9611. {
  9612. mtrace();
  9613. int result = FAIL;
  9614. char message[4096]={0};
  9615. json_object *Reset = json_object_new_object();
  9616. DEBUG_INFO("sendResetConfirmation...\n");
  9617. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  9618. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  9619. sprintf(message,"[%d,\"%s\",%s]"
  9620. ,MESSAGE_TYPE_CALLRESULT
  9621. ,uuid
  9622. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  9623. json_object_put(Reset);
  9624. LWS_Send(message);
  9625. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  9626. {
  9627. DB_updateBootType(BootReasonEnumType_RemoteReset);
  9628. }
  9629. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  9630. {
  9631. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  9632. }
  9633. result = TRUE;
  9634. return result;
  9635. }
  9636. int sendSendLocalListConfirmation(char *uuid)
  9637. {
  9638. mtrace();
  9639. int result = FAIL;
  9640. char message[4096]={0};
  9641. json_object *SendLocalList = json_object_new_object();
  9642. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  9643. sprintf(message,"[%d,\"%s\",%s]"
  9644. ,MESSAGE_TYPE_CALLRESULT
  9645. ,uuid
  9646. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  9647. json_object_put(SendLocalList);
  9648. LWS_Send(message);
  9649. result = TRUE;
  9650. return result;
  9651. }
  9652. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  9653. {
  9654. mtrace();
  9655. int result = FAIL;
  9656. char message[4096]={0};
  9657. json_object *SetChargingProfile = json_object_new_object();
  9658. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  9659. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  9660. sprintf(message,"[%d,\"%s\",%s]"
  9661. ,MESSAGE_TYPE_CALLRESULT
  9662. ,uuid
  9663. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  9664. json_object_put(SetChargingProfile);
  9665. LWS_Send(message);
  9666. result = TRUE;
  9667. return result;
  9668. }
  9669. int sendSetDisplayMessagesConfirmation(char *uuid)
  9670. {
  9671. mtrace();
  9672. int result = FAIL;
  9673. char message[4096]={0};
  9674. json_object *SetDisplayMessage = json_object_new_object();
  9675. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  9676. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  9677. sprintf(message,"[%d,\"%s\",%s]"
  9678. ,MESSAGE_TYPE_CALLRESULT
  9679. ,uuid
  9680. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  9681. json_object_put(SetDisplayMessage);
  9682. LWS_Send(message);
  9683. result = TRUE;
  9684. return result;
  9685. }
  9686. int sendSetMonitoringBaseConfirmation(char *uuid)
  9687. {
  9688. mtrace();
  9689. int result = FAIL;
  9690. char message[4096]={0};
  9691. json_object *SetMonitoringBase = json_object_new_object();
  9692. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  9693. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  9694. sprintf(message,"[%d,\"%s\",%s]"
  9695. ,MESSAGE_TYPE_CALLRESULT
  9696. ,uuid
  9697. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  9698. json_object_put(SetMonitoringBase);
  9699. LWS_Send(message);
  9700. result = TRUE;
  9701. return result;
  9702. }
  9703. int sendSetMonitoringLevelConfirmation(char *uuid)
  9704. {
  9705. mtrace();
  9706. int result = FAIL;
  9707. char message[4096]={0};
  9708. json_object *SetMonitoringLevel = json_object_new_object();
  9709. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  9710. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  9711. sprintf(message,"[%d,\"%s\",%s]"
  9712. ,MESSAGE_TYPE_CALLRESULT
  9713. ,uuid
  9714. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  9715. json_object_put(SetMonitoringLevel);
  9716. LWS_Send(message);
  9717. result = TRUE;
  9718. return result;
  9719. }
  9720. int sendSetNetworkProfileConfirmation(char *uuid)
  9721. {
  9722. mtrace();
  9723. int result = FAIL;
  9724. char message[4096]={0};
  9725. json_object *SetNetworkProfile = json_object_new_object();
  9726. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  9727. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  9728. sprintf(message,"[%d,\"%s\",%s]"
  9729. ,MESSAGE_TYPE_CALLRESULT
  9730. ,uuid
  9731. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  9732. json_object_put(SetNetworkProfile);
  9733. LWS_Send(message);
  9734. result = TRUE;
  9735. return result;
  9736. }
  9737. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  9738. {
  9739. mtrace();
  9740. int result = FAIL;
  9741. char message[4096]={0};
  9742. json_object *SetVariableMonitoring = json_object_new_object();
  9743. json_object *setMonitoringResults = json_object_new_array();
  9744. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  9745. for(int idx=0;idx<variableQuantity;idx++)
  9746. {
  9747. json_object *variableMonitorResult = json_object_new_object();
  9748. json_object *component = json_object_new_object();
  9749. json_object *variable = json_object_new_object();
  9750. json_object *evse = json_object_new_object();
  9751. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  9752. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  9753. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  9754. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  9755. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  9756. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  9757. json_object_object_add(component, "component", evse);
  9758. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  9759. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  9760. json_object_object_add(variableMonitorResult, "component", component);
  9761. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  9762. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  9763. json_object_object_add(variableMonitorResult, "variable", variable);
  9764. json_object_array_add(setMonitoringResults, variableMonitorResult);
  9765. }
  9766. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  9767. sprintf(message,"[%d,\"%s\",%s]"
  9768. ,MESSAGE_TYPE_CALLRESULT
  9769. ,uuid
  9770. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  9771. json_object_put(SetVariableMonitoring);
  9772. LWS_Send(message);
  9773. result = TRUE;
  9774. return result;
  9775. }
  9776. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  9777. {
  9778. mtrace();
  9779. int result = FAIL;
  9780. char message[4096]={0};
  9781. json_object *SetVariable = json_object_new_object();
  9782. json_object *setVariableResults = json_object_new_array();
  9783. DEBUG_INFO("sendSetVariableConfirmation...\n");
  9784. for(int idx=0;idx<variableQuantity;idx++)
  9785. {
  9786. json_object *variableResult = json_object_new_object();
  9787. json_object *component = json_object_new_object();
  9788. json_object *variable = json_object_new_object();
  9789. json_object *evse = json_object_new_object();
  9790. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  9791. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  9792. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  9793. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  9794. json_object_object_add(component, "component", evse);
  9795. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  9796. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  9797. json_object_object_add(variableResult, "component", component);
  9798. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  9799. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  9800. json_object_object_add(variableResult, "variable", variable);
  9801. json_object_array_add(setVariableResults, variableResult);
  9802. }
  9803. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  9804. sprintf(message,"[%d,\"%s\",%s]"
  9805. ,MESSAGE_TYPE_CALLRESULT
  9806. ,uuid
  9807. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  9808. json_object_put(SetVariable);
  9809. LWS_Send(message);
  9810. result = TRUE;
  9811. return result;
  9812. }
  9813. int sendTriggerMessageConfirmation(char *uuid)
  9814. {
  9815. mtrace();
  9816. int result = FAIL;
  9817. char message[4096]={0};
  9818. json_object *TriggerMessage = json_object_new_object();
  9819. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  9820. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  9821. sprintf(message,"[%d,\"%s\",%s]",
  9822. MESSAGE_TYPE_CALLRESULT,
  9823. uuid,
  9824. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  9825. json_object_put(TriggerMessage);
  9826. LWS_Send(message);
  9827. result = TRUE;
  9828. return result;
  9829. }
  9830. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  9831. {
  9832. mtrace();
  9833. int result = FAIL;
  9834. char message[4096]={0};
  9835. json_object *UnlockConnector = json_object_new_object();
  9836. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  9837. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  9838. sprintf(message,"[%d,\"%s\",%s]",
  9839. MESSAGE_TYPE_CALLRESULT,
  9840. uuid,
  9841. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  9842. json_object_put(UnlockConnector);
  9843. LWS_Send(message);
  9844. result = TRUE;
  9845. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  9846. return result;
  9847. }
  9848. int sendUnpublishFirmwareConfirmation(char *uuid)
  9849. {
  9850. mtrace();
  9851. int result = FAIL;
  9852. char message[4096]={0};
  9853. json_object *UnpublishFirmware = json_object_new_object();
  9854. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  9855. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  9856. sprintf(message,"[%d,\"%s\",%s]"
  9857. ,MESSAGE_TYPE_CALLRESULT
  9858. ,uuid
  9859. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  9860. json_object_put(UnpublishFirmware);
  9861. LWS_Send(message);
  9862. result = TRUE;
  9863. return result;
  9864. }
  9865. int sendUpdateFirmwareConfirmation(char *uuid)
  9866. {
  9867. mtrace();
  9868. int result = FAIL;
  9869. char message[4096]={0};
  9870. json_object *UpdateFirmware = json_object_new_object();
  9871. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  9872. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  9873. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  9874. sprintf(message,"[%d,\"%s\",%s]"
  9875. ,MESSAGE_TYPE_CALLRESULT
  9876. ,uuid
  9877. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  9878. json_object_put(UpdateFirmware);
  9879. LWS_Send(message);
  9880. result = TRUE;
  9881. return result;
  9882. }
  9883. int sendUnknownConfirmation(char *uuid)
  9884. {
  9885. mtrace();
  9886. int result = FAIL;
  9887. char message[256]={0};
  9888. //[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
  9889. DEBUG_INFO("sendUnknownConfirmation...\n");
  9890. sprintf(message,"[%d,\"%s\",\"NotImplemented\",\"Requested Action is not known by receiver\",{}]", MESSAGE_TYPE_CALLERROR, uuid);
  9891. LWS_Send(message);
  9892. result = TRUE;
  9893. return result;
  9894. }
  9895. //==========================================
  9896. // send CallError routine
  9897. //==========================================
  9898. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  9899. {
  9900. mtrace();
  9901. char message[220]={0};
  9902. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  9903. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  9904. LWS_Send(message);
  9905. }
  9906. //==========================================
  9907. // Handle server request routine Start
  9908. //==========================================
  9909. int handleCancelReservationRequest(char *uuid, char *payload)
  9910. {
  9911. mtrace();
  9912. int result = FAIL;
  9913. int gunNO = 0;
  9914. int reservationIdInt = -1;
  9915. DEBUG_INFO("handleCancelReservationRequest...\n");
  9916. json_object *CancelReservation;
  9917. CancelReservation = json_tokener_parse(payload);
  9918. if(!is_error(CancelReservation))
  9919. {
  9920. // Required data
  9921. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  9922. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  9923. }
  9924. json_object_put(CancelReservation);
  9925. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  9926. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  9927. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  9928. if(reservationIdInt != -1)
  9929. {
  9930. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  9931. //check Transaction active
  9932. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  9933. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  9934. {
  9935. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  9936. {
  9937. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  9938. if(gunType[2] == GUN_TYPE_CHAdeMO)
  9939. {
  9940. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  9941. }
  9942. else
  9943. {
  9944. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  9945. }
  9946. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  9947. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  9948. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  9949. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  9950. goto end;
  9951. }
  9952. }
  9953. for (int index = 0; index < CCS_QUANTITY; index++)
  9954. {
  9955. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  9956. {
  9957. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  9958. if(gunType[2] == GUN_TYPE_CCS)
  9959. {
  9960. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  9961. }
  9962. else
  9963. {
  9964. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  9965. }
  9966. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  9967. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  9968. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  9969. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  9970. goto end;
  9971. }
  9972. }
  9973. for (int index = 0; index < GB_QUANTITY; index++)
  9974. {
  9975. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  9976. {
  9977. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  9978. if(gunType[2] == GUN_TYPE_GBT)
  9979. {
  9980. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  9981. }
  9982. else
  9983. {
  9984. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  9985. }
  9986. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  9987. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  9988. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  9989. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  9990. goto end;
  9991. }
  9992. }
  9993. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9994. {
  9995. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId == reservationIdInt)
  9996. {
  9997. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  9998. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  9999. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10000. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10001. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10002. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10003. goto end;
  10004. }
  10005. }
  10006. for (int index = 0; index < AC_QUANTITY; index++)
  10007. {
  10008. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  10009. {
  10010. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10011. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  10012. {
  10013. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  10014. }
  10015. else
  10016. {
  10017. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  10018. }
  10019. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10020. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10021. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10022. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10023. goto end;
  10024. }
  10025. }
  10026. }
  10027. //The reservationId does NOT match the reservationId
  10028. sendCancelReservationConfirmation(uuid, gunNO);
  10029. end:
  10030. // Fill in ocpp packet uuid
  10031. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  10032. return result;
  10033. }
  10034. int handleCertificateSignedRequest(char *uuid, char *payload)
  10035. {
  10036. mtrace();
  10037. int result = FAIL;
  10038. json_object *CertificateSigned;
  10039. DEBUG_INFO("handleCertificateSignedRequest...\n");
  10040. CertificateSigned = json_tokener_parse(payload);
  10041. if(!is_error(CertificateSigned))
  10042. {
  10043. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  10044. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  10045. // Required data
  10046. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateChain, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateChain")));
  10047. // Optional data
  10048. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  10049. {
  10050. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  10051. if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]) == 0)
  10052. {
  10053. FILE *fp = fopen("/Storage/OCPP/certCP.crt", "w");
  10054. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10055. fclose(fp);
  10056. }
  10057. else if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0)
  10058. {
  10059. FILE *fp = fopen("/Storage/OCPP/certV2G.crt", "w");
  10060. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10061. fclose(fp);
  10062. }
  10063. }
  10064. else
  10065. {
  10066. FILE *fp = fopen("/Storage/OCPP/certCP.crt", "w");
  10067. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10068. fclose(fp);
  10069. fp = fopen("/Storage/OCPP/certV2G.crt", "w");
  10070. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10071. fclose(fp);
  10072. }
  10073. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10074. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  10075. }
  10076. else
  10077. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  10078. json_object_put(CertificateSigned);
  10079. sendCertificateSignedConfirmation(uuid);
  10080. return result;
  10081. }
  10082. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  10083. {
  10084. mtrace();
  10085. int result = FAIL;
  10086. int evseId = 0, gunIndex = 0;
  10087. char operationalStatus[16]={0};
  10088. char comfirmstr[20];
  10089. int specificId = FALSE;
  10090. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  10091. json_object *ChangeAvailability;
  10092. ChangeAvailability = json_tokener_parse(payload);
  10093. if(!is_error(ChangeAvailability))
  10094. {
  10095. // Required data
  10096. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  10097. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  10098. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  10099. {
  10100. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  10101. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  10102. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  10103. }
  10104. }
  10105. json_object_put(ChangeAvailability);
  10106. if((evseId != 0) && (evseId <= gunTotalNumber))
  10107. {
  10108. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  10109. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  10110. }
  10111. else if(evseId == 0)
  10112. {
  10113. for(int i=0; i < gunTotalNumber; i++)
  10114. {
  10115. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  10116. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  10117. }
  10118. }
  10119. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  10120. {
  10121. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  10122. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  10123. }
  10124. else if(gunIndex == 0)
  10125. {
  10126. for(int i=0; i < gunTotalNumber; i++)
  10127. {
  10128. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  10129. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  10130. }
  10131. }
  10132. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  10133. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10134. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  10135. {
  10136. specificId = TRUE;
  10137. }
  10138. if(specificId == FALSE)
  10139. goto end;
  10140. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  10141. {
  10142. //----------------------gunIndex is 0 ------------------------------------------------//
  10143. if(gunIndex == 0)
  10144. {
  10145. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10146. {
  10147. for(int i=0; i < gunTotalNumber; i++)
  10148. {
  10149. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10150. {
  10151. if ((gunType[i] == GUN_TYPE_CHAdeMO)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  10152. {
  10153. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10154. {
  10155. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10156. goto end;
  10157. }
  10158. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10159. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10160. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10161. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10162. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10163. {
  10164. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10165. goto end;
  10166. }
  10167. }
  10168. }//END FOR CHAdeMO_QUANTITY
  10169. for (int index = 0; index < CCS_QUANTITY; index++)
  10170. {
  10171. if ((gunType[i] == GUN_TYPE_CCS)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  10172. {
  10173. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  10174. {
  10175. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10176. goto end;
  10177. }
  10178. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10179. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10180. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10181. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10182. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10183. {
  10184. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10185. goto end;
  10186. }
  10187. }
  10188. }//END FOR CCS_QUANTITY
  10189. for (int index = 0; index < GB_QUANTITY; index++)
  10190. {
  10191. if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  10192. {
  10193. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10194. {
  10195. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10196. goto end;
  10197. }
  10198. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10199. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10200. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10201. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10202. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10203. {
  10204. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10205. goto end;
  10206. }
  10207. }
  10208. }// END FOR GB_QUANTITY
  10209. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10210. {
  10211. if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i))
  10212. {
  10213. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10214. {
  10215. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10216. goto end;
  10217. }
  10218. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  10219. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  10220. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  10221. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  10222. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10223. {
  10224. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10225. goto end;
  10226. }
  10227. }
  10228. }// END FOR DO_QUANTITY
  10229. for (int index = 0; index < AC_QUANTITY; index++)
  10230. {
  10231. if ((gunType[i] == GUN_TYPE_AC)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  10232. {
  10233. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10234. {
  10235. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10236. goto end;
  10237. }
  10238. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10239. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10240. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10241. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10242. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10243. {
  10244. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10245. goto end;
  10246. }
  10247. }
  10248. }//END FOR AC_QUANTITY
  10249. }// END FOR gunTotalNumber
  10250. }
  10251. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  10252. {
  10253. for(int i=0; i < gunTotalNumber; i++)
  10254. {
  10255. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10256. {
  10257. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10258. goto end;
  10259. }
  10260. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10261. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  10262. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  10263. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  10264. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10265. {
  10266. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10267. goto end;
  10268. }
  10269. }
  10270. }
  10271. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10272. goto end;
  10273. }
  10274. //----------------------gunIndex is not 0 ------------------------------------------------//
  10275. //check Transaction active
  10276. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10277. {
  10278. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO))
  10279. {
  10280. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  10281. {
  10282. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10283. goto end;
  10284. }
  10285. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10286. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10287. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10288. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10289. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10290. {
  10291. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10292. goto end;
  10293. }
  10294. else
  10295. {
  10296. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  10297. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10298. goto end;
  10299. }
  10300. }
  10301. }//END FOR CHAdeMO_QUANTITY
  10302. for (int index = 0; index < CCS_QUANTITY; index++)
  10303. {
  10304. if ((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS))
  10305. {
  10306. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  10307. {
  10308. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10309. goto end;
  10310. }
  10311. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10312. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10313. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10314. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10315. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10316. {
  10317. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10318. goto end;
  10319. }
  10320. else
  10321. {
  10322. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  10323. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10324. goto end;
  10325. }
  10326. }
  10327. }//END FOR CCS_QUANTITY
  10328. for (int index = 0; index < GB_QUANTITY; index++)
  10329. {
  10330. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))
  10331. {
  10332. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  10333. {
  10334. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10335. goto end;
  10336. }
  10337. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10338. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10339. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10340. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10341. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10342. {
  10343. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10344. goto end;
  10345. }
  10346. else
  10347. {
  10348. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  10349. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10350. goto end;
  10351. }
  10352. }
  10353. }// END FOR GB_QUANTITY
  10354. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10355. {
  10356. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))
  10357. {
  10358. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  10359. {
  10360. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10361. goto end;
  10362. }
  10363. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  10364. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  10365. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  10366. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  10367. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10368. {
  10369. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10370. goto end;
  10371. }
  10372. else
  10373. {
  10374. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  10375. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10376. goto end;
  10377. }
  10378. }
  10379. }// END FOR DO_QUANTITY
  10380. for (int index = 0; index < AC_QUANTITY; index++)
  10381. {
  10382. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC))
  10383. {
  10384. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  10385. {
  10386. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10387. goto end;
  10388. }
  10389. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10390. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10391. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10392. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10393. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10394. {
  10395. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10396. goto end;
  10397. }
  10398. else
  10399. {
  10400. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  10401. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10402. goto end;
  10403. }
  10404. }
  10405. }//END FOR AC_QUANTITY
  10406. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  10407. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  10408. {
  10409. //----------------------gunIndex is 0 ------------------------------------------------//
  10410. if(gunIndex == 0)
  10411. {
  10412. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10413. {
  10414. for(int i=0; i < gunTotalNumber; i++)
  10415. {
  10416. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10417. {
  10418. 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
  10419. {
  10420. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10421. goto end;
  10422. }
  10423. }//END FOR CHAdeMO_QUANTITY
  10424. for (int index = 0; index < CCS_QUANTITY; index++)
  10425. {
  10426. 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
  10427. {
  10428. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10429. goto end;
  10430. }
  10431. }//END FOR CCS_QUANTITY
  10432. for (int index = 0; index < GB_QUANTITY; index++)
  10433. {
  10434. 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
  10435. {
  10436. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  10437. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10438. goto end;
  10439. }
  10440. }// END FOR GB_QUANTITY
  10441. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10442. {
  10443. 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
  10444. {
  10445. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  10446. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10447. goto end;
  10448. }
  10449. }// END FOR DO_QUANTITY
  10450. for (int index = 0; index < AC_QUANTITY; index++)
  10451. {
  10452. 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
  10453. {
  10454. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10455. goto end;
  10456. }
  10457. }//END FOR CHAdeMO_QUANTITY
  10458. }// END FOR gunTotalNumber
  10459. }
  10460. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  10461. {
  10462. for(int i=0; i < gunTotalNumber; i++)
  10463. {
  10464. for (int index = 0; index < AC_QUANTITY; index++)
  10465. {
  10466. 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
  10467. {
  10468. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10469. goto end;
  10470. }
  10471. }//END FOR CHAdeMO_QUANTITY
  10472. } // END FOR gunTotalNumber
  10473. }
  10474. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10475. goto end;
  10476. }
  10477. //----------------------gunIndex is not 0 ------------------------------------------------//
  10478. //check Transaction active
  10479. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10480. {
  10481. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10482. {
  10483. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10484. goto end;
  10485. }
  10486. }//END FOR CHAdeMO_QUANTITY
  10487. for (int index = 0; index < CCS_QUANTITY; index++)
  10488. {
  10489. if ((((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS)) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10490. {
  10491. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10492. goto end;
  10493. }
  10494. }//END FOR CCS_QUANTITY
  10495. for (int index = 0; index < GB_QUANTITY; index++)
  10496. {
  10497. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10498. {
  10499. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10500. goto end;
  10501. }
  10502. }// END FOR GB_QUANTITY
  10503. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10504. {
  10505. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10506. {
  10507. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10508. goto end;
  10509. }
  10510. }// END FOR DO_QUANTITY
  10511. for (int index = 0; index < AC_QUANTITY; index++)
  10512. {
  10513. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC)) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10514. {
  10515. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10516. goto end;
  10517. }
  10518. }//END FOR AC_QUANTITY
  10519. }//END FOR AvailabilityEnumTypeStr[Operative]
  10520. end:
  10521. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  10522. {
  10523. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  10524. }
  10525. else
  10526. {
  10527. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  10528. }
  10529. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  10530. {
  10531. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  10532. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  10533. }
  10534. else if(gunIndex == 0)
  10535. {
  10536. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  10537. {
  10538. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  10539. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  10540. }
  10541. }
  10542. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  10543. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10544. return result;
  10545. }
  10546. int handleClearCacheRequest(char *uuid, char *payload)
  10547. {
  10548. mtrace();
  10549. int result = FAIL;
  10550. char rmFileCmd[100]={0};
  10551. struct stat stats;
  10552. DEBUG_INFO("handleClearCacheRequest...\n");
  10553. stat("/Storage/OCPP", &stats);
  10554. // Check for directory existence
  10555. if (S_ISDIR(stats.st_mode) == 1)
  10556. {}
  10557. else
  10558. {
  10559. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  10560. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  10561. system(rmFileCmd);
  10562. }
  10563. if(DB_cleanLocalCache() != PASS)
  10564. {
  10565. DEBUG_INFO("open AuthorizationCache file failed\n");
  10566. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  10567. }
  10568. else
  10569. {
  10570. DEBUG_INFO("open AuthorizationCache file successful\n");
  10571. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  10572. }
  10573. sendClearCacheConfirmation(uuid);
  10574. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10575. return result;
  10576. }
  10577. int handleClearChargingProfileRequest(char *uuid, char *payload)
  10578. {
  10579. mtrace();
  10580. int result = FAIL;
  10581. int resultRename;
  10582. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  10583. char chargingProfilePurposeStr[26]={0};
  10584. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  10585. char tempchargingProfilePurposeStr[26]={0};
  10586. char sstr[160]={0};
  10587. char str[100]={0};
  10588. int c = 0;
  10589. char *loc;
  10590. char fname[200]={0};
  10591. char comfirmstr[20]={0};
  10592. char word[1600]={0};
  10593. int clearflag = FALSE;
  10594. int chargingProfileIdIsNULL = FALSE;
  10595. int connectorIsNULL = FALSE;
  10596. int chargingProfilePurposeIsNULL = FALSE;
  10597. int stackLevelIsNULL = FALSE;
  10598. //int GotoEnd = FALSE;
  10599. FILE *fptr1, *fptr2;
  10600. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  10601. int n_chargingProfile=0;
  10602. int isEmptyFile = FALSE;
  10603. char sLineWord[1600]={0};
  10604. char chargingProfiles[10][100]={0};
  10605. int ChargeProfileCount = 0;
  10606. int ch;
  10607. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  10608. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  10609. json_object *ClearChargingProfile;
  10610. ClearChargingProfile = json_tokener_parse(payload);
  10611. if(!is_error(ClearChargingProfile))
  10612. {
  10613. // Optional data
  10614. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  10615. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  10616. else
  10617. chargingProfileIdIsNULL = TRUE;
  10618. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  10619. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  10620. else
  10621. connectorIsNULL = TRUE;
  10622. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  10623. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  10624. else
  10625. chargingProfilePurposeIsNULL = TRUE;
  10626. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  10627. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  10628. else
  10629. stackLevelIsNULL = TRUE;
  10630. }
  10631. json_object_put(ClearChargingProfile);
  10632. if(connectorIsNULL == FALSE)
  10633. {
  10634. switch(connectorIdInt)
  10635. {
  10636. case 0:
  10637. if(chargingProfilePurposeIsNULL == TRUE)
  10638. {
  10639. int l = 0;
  10640. strcpy(fname, ChargePointMaxProfile_JSON);
  10641. if((access(fname,F_OK))!=-1)
  10642. {
  10643. strcpy(chargingProfiles[l], fname);
  10644. l = l + 1;
  10645. }
  10646. strcpy(fname, TxDefaultProfile_0_JSON);
  10647. if((access(fname,F_OK))!=-1)
  10648. {
  10649. strcpy(chargingProfiles[l], fname);
  10650. l = l + 1;
  10651. }
  10652. ChargeProfileCount = l;
  10653. }
  10654. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  10655. {
  10656. strcpy(fname, ChargePointMaxProfile_JSON);
  10657. if((access(fname,F_OK))!=-1)
  10658. {
  10659. strcpy(chargingProfiles[0], fname);
  10660. ChargeProfileCount = 1;
  10661. }
  10662. }
  10663. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  10664. {
  10665. strcpy(fname, TxDefaultProfile_0_JSON);
  10666. if((access(fname,F_OK))!=-1)
  10667. {
  10668. strcpy(chargingProfiles[0], fname);
  10669. ChargeProfileCount = 1;
  10670. }
  10671. }
  10672. break;
  10673. default:
  10674. if(chargingProfilePurposeIsNULL == TRUE)
  10675. {
  10676. int m = 0;
  10677. memset(fname, 0, ARRAY_SIZE(fname));
  10678. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  10679. if((access(fname,F_OK))!=-1)
  10680. {
  10681. strcpy(chargingProfiles[m], fname);
  10682. m = m + 1;
  10683. }
  10684. memset(fname, 0, ARRAY_SIZE(fname));
  10685. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  10686. if((access(fname,F_OK))!=-1)
  10687. {
  10688. strcpy(chargingProfiles[m], fname);
  10689. m = m + 1;
  10690. }
  10691. ChargeProfileCount = m;
  10692. }
  10693. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  10694. {
  10695. //strcpy(fname, TxDefaultProfile_1_JSON);
  10696. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  10697. if((access(fname,F_OK))!=-1)
  10698. {
  10699. strcpy(chargingProfiles[0], fname);
  10700. ChargeProfileCount = 1;
  10701. }
  10702. }
  10703. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  10704. {
  10705. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  10706. if((access(fname,F_OK))!=-1)
  10707. {
  10708. strcpy(chargingProfiles[0], fname);
  10709. ChargeProfileCount = 1;
  10710. }
  10711. }
  10712. //strcpy(fname, ChargePointMaxProfile_JSON );
  10713. break;
  10714. }
  10715. }
  10716. else // Check all Charging Profiles
  10717. {
  10718. int i = 0;
  10719. char fnametemp[200]={0};
  10720. ChargeProfileCount = 0;
  10721. //Check ChargePointMaxProfile.json exit
  10722. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  10723. {
  10724. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  10725. i = i + 1;
  10726. }
  10727. //Check TxDefaultProfile_%d.json
  10728. for(int j=1; j <= gunTotalNumber; j++)
  10729. {
  10730. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  10731. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  10732. if((access(fnametemp,F_OK))!=-1)
  10733. {
  10734. strcpy(chargingProfiles[i], fnametemp);
  10735. i = i + 1;
  10736. }
  10737. }
  10738. //Check TxProfile_%d.json
  10739. for(int j=1; j <= gunTotalNumber; j++)
  10740. {
  10741. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  10742. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  10743. if((access(fnametemp,F_OK))!=-1)
  10744. {
  10745. strcpy(chargingProfiles[i], fnametemp);
  10746. i = i + 1;
  10747. }
  10748. }
  10749. ChargeProfileCount = i;
  10750. }// End connectorIsNULL is TRUE
  10751. if(ChargeProfileCount == 0)
  10752. {
  10753. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  10754. goto end;
  10755. }
  10756. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  10757. {
  10758. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  10759. goto end;
  10760. }
  10761. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  10762. {
  10763. memset(str, 0, ARRAY_SIZE(str));
  10764. // clear temp file
  10765. sprintf(str,"rm -f %s",temp);
  10766. system(str);
  10767. for(int k=0; k < ChargeProfileCount; k++)
  10768. {
  10769. memset(str, 0, ARRAY_SIZE(str));
  10770. //clear file in C
  10771. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10772. system(str);
  10773. }
  10774. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10775. goto end;
  10776. }
  10777. else if(connectorIsNULL == TRUE)
  10778. {
  10779. for(int k=0; k < ChargeProfileCount; k++)
  10780. {
  10781. fptr1 = fopen(chargingProfiles[k], "r");
  10782. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  10783. //Check Charging Profile Count
  10784. while(fscanf(fptr1, "%s", word) != EOF)
  10785. {
  10786. //DEBUG_INFO("word=%s\n",word);
  10787. if(strstr(word, "id")!= NULL)
  10788. {
  10789. //DEBUG_INFO("test id \n");
  10790. n_chargingProfile = n_chargingProfile + 1;
  10791. //DEBUG_INFO("id Found\n");
  10792. }
  10793. }
  10794. rewind(fptr1);
  10795. //search Charging Profile Element
  10796. //int i= 0;
  10797. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  10798. {
  10799. //------------------------tempconnectorIdInt------------------------//
  10800. loc = strstr(sLineWord, "connectorId");
  10801. c = 0;
  10802. memset(sstr ,0, sizeof(sstr) );
  10803. while (loc[strlen("connectorId")+2+c] != ',')
  10804. {
  10805. sstr[c] = loc[strlen("connectorId")+2+c];
  10806. c++;
  10807. }
  10808. sstr[c] = '\0';
  10809. tempconnectorIdInt = atoi(sstr);
  10810. printf("file's gun number is %d\n", tempconnectorIdInt);
  10811. //--------------------------id--------------------//
  10812. c = 0;
  10813. loc = strstr(sLineWord, "id");
  10814. memset(sstr ,0, ARRAY_SIZE(sstr));
  10815. while (loc[strlen("id")+2+c] != ',')
  10816. {
  10817. sstr[c] = loc[strlen("id")+2+c];
  10818. //printf("i=%d sstr=%c\n",c, sstr[c]);
  10819. c++;
  10820. }
  10821. sstr[c] = '\0';
  10822. tempchargingProfileIdInt = atoi(sstr);
  10823. //stackLevel
  10824. c = 0;
  10825. loc = strstr(sLineWord, "stackLevel");
  10826. memset(sstr ,0, ARRAY_SIZE(sstr));
  10827. while (loc[strlen("stackLevel")+2+c] != ',')
  10828. {
  10829. sstr[c] = loc[strlen("stackLevel")+2+c];
  10830. //printf("i=%d sstr=%c\n",c, sstr[c]);
  10831. c++;
  10832. }
  10833. sstr[c] = '\0';
  10834. tempstackLevelInt = atoi(sstr);
  10835. c = 0;
  10836. loc = strstr(sLineWord, "chargingProfilePurpose");
  10837. memset(sstr ,0, ARRAY_SIZE(sstr));
  10838. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  10839. {
  10840. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  10841. c++;
  10842. }
  10843. sstr[c] = '\0';
  10844. strcpy(tempchargingProfilePurposeStr, sstr);
  10845. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  10846. {
  10847. //------- not write to fptr2-------//
  10848. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10849. //clearflag = TRUE;
  10850. }
  10851. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  10852. {
  10853. //------- not write to fptr2-------//
  10854. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10855. }
  10856. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  10857. {
  10858. //------- not write to fptr2-------//
  10859. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10860. }
  10861. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  10862. {
  10863. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10864. }
  10865. else
  10866. {
  10867. fprintf(fptr2, sLineWord);//writing data into file
  10868. }
  10869. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  10870. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  10871. if(clearflag == TRUE)
  10872. {
  10873. fclose(fptr1);
  10874. fclose(fptr2);
  10875. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10876. system(str);
  10877. // clear temp file
  10878. sprintf(str,"rm -f %s",temp);
  10879. system(str);
  10880. }
  10881. else
  10882. {
  10883. fclose(fptr1);
  10884. fclose(fptr2);
  10885. memset(str, 0, ARRAY_SIZE(str));
  10886. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10887. system(str);
  10888. resultRename = rename(temp, chargingProfiles[k]);
  10889. if(resultRename == 0)
  10890. {
  10891. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  10892. }
  10893. else
  10894. {
  10895. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  10896. }
  10897. if(comfirmstr[0]== 0)
  10898. {
  10899. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  10900. }
  10901. //Check chargingProfile is empty file
  10902. /*------ Read the file ----------------*/
  10903. fptr1=fopen(chargingProfiles[k],"r");
  10904. ch=fgetc(fptr1);
  10905. rewind(fptr1);
  10906. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  10907. if(ch!=EOF)
  10908. {
  10909. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  10910. {
  10911. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  10912. if(sLineWord[0]=='\0')
  10913. {
  10914. isEmptyFile = TRUE;
  10915. break;
  10916. }
  10917. else
  10918. {
  10919. isEmptyFile = FALSE;
  10920. break;
  10921. }
  10922. }
  10923. }
  10924. else
  10925. isEmptyFile = TRUE;
  10926. fclose(fptr1);
  10927. if(isEmptyFile == TRUE)
  10928. {
  10929. memset(str, 0, ARRAY_SIZE(str));
  10930. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10931. system(str);
  10932. }
  10933. }
  10934. }// End of while(int k=0; k < ChargePointCount; k++)
  10935. }
  10936. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  10937. {
  10938. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  10939. for(int k=0; k < ChargeProfileCount; k++)
  10940. {
  10941. fptr1 = fopen(chargingProfiles[k], "r");
  10942. fptr2 = fopen(temp, "w+");
  10943. //Check Charging Profile Count
  10944. while(fscanf(fptr1, "%s", word) != EOF)
  10945. {
  10946. //DEBUG_INFO("word=%s\n",word);
  10947. if(strstr(word, "id")!= NULL)
  10948. {
  10949. n_chargingProfile = n_chargingProfile + 1;
  10950. }
  10951. }
  10952. rewind(fptr1);
  10953. //search Charging Profile Element
  10954. //int i= 0;
  10955. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  10956. {
  10957. //*************************tempconnectorIdInt*********************************/
  10958. loc = strstr(sLineWord, "connectorId");
  10959. c = 0;
  10960. memset(sstr ,0, ARRAY_SIZE(sstr));
  10961. while (loc[strlen("connectorId")+2+c] != ',')
  10962. {
  10963. sstr[c] = loc[strlen("connectorId")+2+c];
  10964. c++;
  10965. }
  10966. sstr[c] = '\0';
  10967. tempconnectorIdInt = atoi(sstr);
  10968. //id
  10969. c = 0;
  10970. loc = strstr(sLineWord, "id");
  10971. memset(sstr ,0, ARRAY_SIZE(sstr));
  10972. while (loc[strlen("id")+2+c] != ',')
  10973. {
  10974. sstr[c] = loc[strlen("id")+2+c];
  10975. //printf("i=%d sstr=%c\n",c, sstr[c]);
  10976. c++;
  10977. }
  10978. sstr[c] = '\0';
  10979. tempchargingProfileIdInt = atoi(sstr);
  10980. //stackLevel
  10981. c = 0;
  10982. loc = strstr(sLineWord, "stackLevel");
  10983. memset(sstr ,0, ARRAY_SIZE(sstr));
  10984. while (loc[strlen("stackLevel")+2+c] != ',')
  10985. {
  10986. sstr[c] = loc[strlen("stackLevel")+2+c];
  10987. //printf("i=%d sstr=%c\n",c, sstr[c]);
  10988. c++;
  10989. }
  10990. sstr[c] = '\0';
  10991. tempstackLevelInt = atoi(sstr);
  10992. c = 0;
  10993. loc = strstr(sLineWord, "chargingProfilePurpose");
  10994. memset(sstr ,0, ARRAY_SIZE(sstr));
  10995. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  10996. {
  10997. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  10998. c++;
  10999. }
  11000. sstr[c] = '\0';
  11001. strcpy(tempchargingProfilePurposeStr, sstr);
  11002. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  11003. {
  11004. //------- not write to fptr2-------//
  11005. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11006. //clearflag = TRUE;
  11007. }
  11008. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  11009. {
  11010. //------- not write to fptr2-------//
  11011. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11012. }
  11013. else if(stackLevelIsNULL == TRUE)
  11014. {
  11015. //Clear Whole File
  11016. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11017. clearflag = TRUE;
  11018. break;
  11019. }
  11020. else
  11021. {
  11022. fprintf(fptr2, sLineWord);//writing data into file
  11023. }
  11024. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11025. }
  11026. if(clearflag == TRUE)
  11027. {
  11028. fclose(fptr1);
  11029. fclose(fptr2);
  11030. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11031. system(str);
  11032. // clear temp file
  11033. sprintf(str,"rm -f %s",temp);
  11034. system(str);
  11035. }
  11036. else
  11037. {
  11038. fclose(fptr1);
  11039. fclose(fptr2);
  11040. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11041. system(str);
  11042. resultRename = rename(temp, chargingProfiles[k]);
  11043. if(resultRename == 0)
  11044. {
  11045. DEBUG_INFO("File ChargingProfile renamed successfully");
  11046. }
  11047. else
  11048. {
  11049. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  11050. }
  11051. if(comfirmstr[0]== 0)
  11052. {
  11053. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11054. }
  11055. //Check chargingProfile is empty file
  11056. /*------ Read the file ----------------*/
  11057. fptr1=fopen(chargingProfiles[k],"r");
  11058. ch=fgetc(fptr1);
  11059. rewind(fptr1);
  11060. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11061. if(ch!=EOF)
  11062. {
  11063. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  11064. {
  11065. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  11066. if(sLineWord[0]=='\0')
  11067. {
  11068. isEmptyFile = TRUE;
  11069. break;
  11070. }
  11071. else
  11072. {
  11073. isEmptyFile = FALSE;
  11074. break;
  11075. }
  11076. }
  11077. }
  11078. else
  11079. isEmptyFile = TRUE;
  11080. fclose(fptr1);
  11081. if(isEmptyFile == TRUE)
  11082. {
  11083. memset(str, 0, ARRAY_SIZE(str));
  11084. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11085. system(str);
  11086. }
  11087. /*------- End of reading ---------------*/
  11088. }
  11089. } // while(int k=0; k < ChargeProfileCount; k++)
  11090. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  11091. end:
  11092. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  11093. {
  11094. if(connectorIdInt == 0)
  11095. {
  11096. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  11097. {
  11098. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  11099. }
  11100. }
  11101. else
  11102. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1], 0, TRUE);
  11103. }
  11104. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  11105. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11106. return result;
  11107. }
  11108. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  11109. {
  11110. mtrace();
  11111. int result = FAIL;
  11112. json_object *ClearDisplayMessage;
  11113. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  11114. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  11115. ClearDisplayMessage = json_tokener_parse(payload);
  11116. if(!is_error(ClearDisplayMessage))
  11117. {
  11118. // Required data
  11119. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  11120. {
  11121. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  11122. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  11123. }
  11124. }
  11125. json_object_put(ClearDisplayMessage);
  11126. sendCostUpdatedConfirmation(uuid);
  11127. return result;
  11128. }
  11129. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  11130. {
  11131. mtrace();
  11132. int result = FAIL;
  11133. json_object *ClearVariableMonitorin;
  11134. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  11135. ClearVariableMonitorin = json_tokener_parse(payload);
  11136. if(!is_error(ClearVariableMonitorin))
  11137. {
  11138. // Required data
  11139. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  11140. {
  11141. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  11142. {
  11143. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  11144. /*
  11145. * TODO:
  11146. * 1. Check response
  11147. */
  11148. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  11149. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  11150. }
  11151. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  11152. }
  11153. }
  11154. json_object_put(ClearVariableMonitorin);
  11155. return result;
  11156. }
  11157. int handleCostUpdatedRequest(char *uuid, char *payload)
  11158. {
  11159. mtrace();
  11160. int result = FAIL;
  11161. json_object *CostUpdate;
  11162. DEBUG_INFO("handleCostUpdatedRequest...\n");
  11163. CostUpdate = json_tokener_parse(payload);
  11164. if(!is_error(CostUpdate))
  11165. {
  11166. // Required data
  11167. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  11168. {
  11169. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  11170. }
  11171. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  11172. {
  11173. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  11174. }
  11175. }
  11176. json_object_put(CostUpdate);
  11177. sendCostUpdatedConfirmation(uuid);
  11178. return result;
  11179. }
  11180. int handleCustomerInformationRequest(char *uuid, char *payload)
  11181. {
  11182. mtrace();
  11183. int result = FAIL;
  11184. json_object *CustomerInformation;
  11185. DEBUG_INFO("handleCustomerInformationRequest...\n");
  11186. CustomerInformation = json_tokener_parse(payload);
  11187. if(!is_error(CustomerInformation))
  11188. {
  11189. // Required data
  11190. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  11191. {
  11192. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  11193. }
  11194. if(json_object_object_get(CustomerInformation, "report") != NULL)
  11195. {
  11196. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  11197. }
  11198. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  11199. {
  11200. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  11201. }
  11202. // Optional data
  11203. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  11204. {
  11205. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  11206. {
  11207. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  11208. }
  11209. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  11210. {
  11211. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  11212. }
  11213. }
  11214. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  11215. {
  11216. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  11217. {
  11218. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  11219. }
  11220. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  11221. {
  11222. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  11223. }
  11224. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  11225. {
  11226. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  11227. }
  11228. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  11229. {
  11230. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  11231. }
  11232. }
  11233. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  11234. }
  11235. else
  11236. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  11237. json_object_put(CustomerInformation);
  11238. sendCustomerInformationConfirmation(uuid);
  11239. return result;
  11240. }
  11241. void createFirmwareVersionByDataTransfer(void)
  11242. {
  11243. json_object *FirmwareDataTransfer = json_object_new_object();
  11244. // AC & DC model
  11245. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  11246. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  11247. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  11248. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  11249. // DC model
  11250. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  11251. {
  11252. if((gunType[1] != GUN_TYPE_UNKNOWN) ||
  11253. (gunType[2] != GUN_TYPE_UNKNOWN) ||
  11254. (gunType[3] != GUN_TYPE_UNKNOWN))
  11255. {
  11256. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  11257. }
  11258. if((ShmSysConfigAndInfo->SysConfig.ModelName[1]!='B') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='K') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O'))
  11259. {
  11260. // DS DM DW
  11261. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  11262. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  11263. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  11264. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  11265. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  11266. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  11267. }
  11268. else
  11269. {
  11270. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  11271. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  11272. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  11273. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  11274. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  11275. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  11276. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  11277. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  11278. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  11279. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  11280. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  11281. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  11282. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  11283. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  11284. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  11285. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  11286. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  11287. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  11288. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  11289. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  11290. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  11291. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  11292. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  11293. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  11294. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  11295. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  11296. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  11297. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  11298. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  11299. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  11300. json_object_object_add(FirmwareDataTransfer, "D11_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  11301. }
  11302. }
  11303. // 4G model
  11304. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  11305. {
  11306. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  11307. }
  11308. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
  11309. json_object_put(FirmwareDataTransfer);
  11310. }
  11311. int handleDataTransferRequest(char *uuid, char *payload)
  11312. {
  11313. mtrace();
  11314. int result = PASS;
  11315. DEBUG_INFO("handleDataTransferRequest...\n");
  11316. if((uuid != NULL) && (payload != NULL))
  11317. {
  11318. json_object *DataTransfer;
  11319. DataTransfer = json_tokener_parse(payload);
  11320. if(!is_error(DataTransfer))
  11321. {
  11322. // Required data
  11323. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  11324. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  11325. // Optional data
  11326. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  11327. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  11328. if(json_object_object_get(DataTransfer, "data") != NULL)
  11329. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  11330. result = PASS;
  11331. }
  11332. json_object_put(DataTransfer);
  11333. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  11334. {
  11335. // Send all moudle firmware version on EVSE
  11336. createFirmwareVersionByDataTransfer();
  11337. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11338. }
  11339. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  11340. {
  11341. system("/usr/bin/run_tmate_restart.sh &");
  11342. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11343. }
  11344. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  11345. {
  11346. json_object *data;
  11347. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11348. if(!is_error(data))
  11349. {
  11350. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  11351. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  11352. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  11353. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  11354. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  11355. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  11356. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  11357. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  11358. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  11359. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  11360. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11361. }
  11362. else
  11363. {
  11364. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11365. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11366. }
  11367. json_object_put(data);
  11368. }
  11369. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_ConfigQR") != NULL)
  11370. {
  11371. json_object *data;
  11372. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11373. if(!is_error(data))
  11374. {
  11375. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11376. if(json_object_object_get(data, "Content_Type") != NULL)
  11377. {
  11378. if((0 <= json_object_get_int(json_object_object_get(data, "Content_Type"))) && (json_object_get_int(json_object_object_get(data, "Content_Type")) <= 1))
  11379. {
  11380. ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode = json_object_get_int(json_object_object_get(data, "Content_Type"));
  11381. if(json_object_object_get(data, "Customization_Conent") != NULL)
  11382. {
  11383. sprintf((char*)ShmSysConfigAndInfo->SysConfig.QRCodeContent, "%s", json_object_get_string(json_object_object_get(data, "Customization_Conent")));
  11384. }
  11385. }
  11386. else
  11387. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11388. }
  11389. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  11390. }
  11391. else
  11392. {
  11393. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11394. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11395. }
  11396. json_object_put(data);
  11397. }
  11398. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_DsiplayLcdPage") != NULL)
  11399. {
  11400. json_object *data;
  11401. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11402. if(!is_error(data))
  11403. {
  11404. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11405. if(json_object_object_get(data, "Page_Index") != NULL)
  11406. {
  11407. ShmSysConfigAndInfo->SysConfig.LcdOveride.page_index = json_object_get_int(json_object_object_get(data, "Page_Index"));
  11408. }
  11409. if(json_object_object_get(data, "Duration") != NULL)
  11410. {
  11411. ShmSysConfigAndInfo->SysConfig.LcdOveride.duration = json_object_get_int(json_object_object_get(data, "Duration"));
  11412. }
  11413. ShmSysConfigAndInfo->SysConfig.LcdOveride.isOverideReq = 1;
  11414. }
  11415. else
  11416. {
  11417. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11418. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11419. }
  11420. json_object_put(data);
  11421. }
  11422. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_CpConfiguration") != NULL)
  11423. {
  11424. json_object *data;
  11425. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11426. if(!is_error(data))
  11427. {
  11428. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11429. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, " ");
  11430. if(json_object_object_get(data, "MaxChargingCurrent") != NULL)
  11431. {
  11432. if(json_object_get_int(json_object_object_get(data, "MaxChargingCurrent")) >= 0)
  11433. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent = json_object_get_int(json_object_object_get(data, "MaxChargingCurrent"));
  11434. else
  11435. {
  11436. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11437. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11438. }
  11439. }
  11440. if(json_object_object_get(data, "MaxChargingDuration") != NULL)
  11441. {
  11442. if(json_object_get_int(json_object_object_get(data, "MaxChargingDuration")) >= 0)
  11443. ShmSysConfigAndInfo->SysConfig.MaxChargingDuration = json_object_get_int(json_object_object_get(data, "MaxChargingDuration"));
  11444. else
  11445. {
  11446. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11447. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11448. }
  11449. }
  11450. if(json_object_object_get(data, "MaxChargingEnergy") != NULL)
  11451. {
  11452. if(json_object_get_int(json_object_object_get(data, "MaxChargingEnergy")) >= 0)
  11453. ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy = json_object_get_int(json_object_object_get(data, "MaxChargingEnergy"));
  11454. else
  11455. {
  11456. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11457. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11458. }
  11459. }
  11460. if(json_object_object_get(data, "MaxChargingPower") != NULL)
  11461. {
  11462. if(json_object_get_int(json_object_object_get(data, "MaxChargingPower")) >= 0)
  11463. ShmSysConfigAndInfo->SysConfig.MaxChargingPower = json_object_get_int(json_object_object_get(data, "MaxChargingPower"));
  11464. else
  11465. {
  11466. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11467. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11468. }
  11469. }
  11470. if(json_object_object_get(data, "OfflineMaxChargeEnergy") != NULL)
  11471. {
  11472. if(json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy")) >= 0)
  11473. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy"));
  11474. else
  11475. {
  11476. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11477. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11478. }
  11479. }
  11480. if(json_object_object_get(data, "OfflinePolicy") != NULL)
  11481. {
  11482. if((json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 0) ||
  11483. (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 2) ||
  11484. (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 3))
  11485. ShmSysConfigAndInfo->SysConfig.OfflinePolicy = json_object_get_int(json_object_object_get(data, "OfflinePolicy"));
  11486. else
  11487. {
  11488. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11489. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11490. }
  11491. }
  11492. if(json_object_object_get(data, "isAuthentication") != NULL)
  11493. {
  11494. switch(json_object_get_int(json_object_object_get(data, "isAuthentication")))
  11495. {
  11496. case 0:
  11497. case 1:
  11498. ShmSysConfigAndInfo->SysConfig.AuthorisationMode = json_object_get_int(json_object_object_get(data, "isAuthentication"))^1;
  11499. break;
  11500. default:
  11501. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11502. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11503. break;
  11504. }
  11505. }
  11506. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]) != NULL)
  11507. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  11508. }
  11509. else
  11510. {
  11511. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11512. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11513. }
  11514. json_object_put(data);
  11515. }
  11516. else
  11517. {
  11518. // Can not find valid message id
  11519. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  11520. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  11521. ,ShmOCPP20Data->DataTransfer[0].vendorId
  11522. ,ShmOCPP20Data->DataTransfer[0].messageId
  11523. ,ShmOCPP20Data->DataTransfer[0].data);
  11524. }
  11525. }
  11526. else
  11527. {
  11528. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  11529. result = FAIL;
  11530. }
  11531. sendDataTransferConfirmation(uuid, 0);
  11532. return result;
  11533. }
  11534. int handleDeleteCertificateRequest(char *uuid, char *payload)
  11535. {
  11536. mtrace();
  11537. int result = FAIL;
  11538. json_object *DeleteCertificate;
  11539. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  11540. DeleteCertificate = json_tokener_parse(payload);
  11541. if(!is_error(DeleteCertificate))
  11542. {
  11543. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  11544. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  11545. // Required data
  11546. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  11547. {
  11548. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  11549. {
  11550. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  11551. }
  11552. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  11553. {
  11554. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  11555. }
  11556. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  11557. {
  11558. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  11559. }
  11560. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  11561. {
  11562. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  11563. }
  11564. /*
  11565. * TODO:
  11566. * 1. Delete certification and response
  11567. */
  11568. if(strstr((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, HashAlgorithmEnumTypeStr[HashAlgorithmEnumType_SHA256]) != NULL)
  11569. {
  11570. }
  11571. else if(strstr((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, HashAlgorithmEnumTypeStr[HashAlgorithmEnumType_SHA384]) != NULL)
  11572. {
  11573. }
  11574. else
  11575. {
  11576. }
  11577. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  11578. }
  11579. }
  11580. else
  11581. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  11582. json_object_put(DeleteCertificate);
  11583. sendDeleteCertificateConfirmation(uuid);
  11584. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11585. return result;
  11586. }
  11587. int handleGetBaseReportRequest(char *uuid, char *payload)
  11588. {
  11589. mtrace();
  11590. int result = FAIL;
  11591. json_object *GetBaseRepor;
  11592. DEBUG_INFO("handleGetBaseReportRequest...\n");
  11593. GetBaseRepor = json_tokener_parse(payload);
  11594. if(!is_error(GetBaseRepor))
  11595. {
  11596. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  11597. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  11598. // Required data
  11599. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  11600. {
  11601. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  11602. }
  11603. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  11604. {
  11605. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  11606. }
  11607. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_SummaryInventory]) == 0)
  11608. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  11609. else
  11610. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  11611. }
  11612. else
  11613. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  11614. json_object_put(GetBaseRepor);
  11615. sendGetBaseReportConfirmation(uuid);
  11616. return result;
  11617. }
  11618. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  11619. {
  11620. mtrace();
  11621. int result = FAIL;
  11622. int gun_index = -1;
  11623. json_object *GetChargingProfiles;
  11624. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  11625. GetChargingProfiles = json_tokener_parse(payload);
  11626. if(!is_error(GetChargingProfiles))
  11627. {
  11628. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  11629. {
  11630. 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;
  11631. }
  11632. if(gun_index >-1)
  11633. {
  11634. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  11635. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  11636. // Required data
  11637. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  11638. {
  11639. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  11640. }
  11641. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  11642. {
  11643. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  11644. {
  11645. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  11646. }
  11647. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  11648. {
  11649. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  11650. }
  11651. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  11652. {
  11653. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  11654. {
  11655. 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)));
  11656. }
  11657. }
  11658. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  11659. {
  11660. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  11661. {
  11662. 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));
  11663. }
  11664. }
  11665. }
  11666. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  11667. }
  11668. else
  11669. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  11670. }
  11671. json_object_put(GetChargingProfiles);
  11672. sendGetChargingProfilesConfirmation(uuid, gun_index);
  11673. return result;
  11674. }
  11675. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  11676. {
  11677. mtrace();
  11678. int result = FAIL;
  11679. int connectorIdInt, durationInt;
  11680. char chargingRateUnitStr[4]={0};
  11681. char comfirmstr[20];
  11682. int confirmPeriods = 0;
  11683. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  11684. json_object *GetCompositeSchedule;
  11685. GetCompositeSchedule = json_tokener_parse(payload);
  11686. if(!is_error(GetCompositeSchedule))
  11687. {
  11688. // Required data
  11689. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  11690. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  11691. else
  11692. connectorIdInt = -1;
  11693. if(json_object_object_get(GetCompositeSchedule, "duration"))
  11694. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  11695. else
  11696. durationInt = 86400;
  11697. // Optional data
  11698. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  11699. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  11700. }
  11701. json_object_put(GetCompositeSchedule);
  11702. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  11703. if((connectorIdInt == 0) ||
  11704. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  11705. {
  11706. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  11707. struct ChargingProfileType tmpProfile[1];
  11708. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  11709. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  11710. if(strstr(chargingRateUnitStr, "W") != NULL)
  11711. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, FALSE);
  11712. else
  11713. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, TRUE);
  11714. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  11715. {
  11716. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  11717. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  11718. }
  11719. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  11720. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  11721. {
  11722. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  11723. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  11724. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  11725. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0) &&
  11726. (idx<(ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod)-1)?(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx+1].startPeriod==0):TRUE))
  11727. {
  11728. confirmPeriods = idx;
  11729. break;
  11730. }
  11731. }
  11732. if((confirmPeriods == 0) && (tmpProfile[0].id > 0))
  11733. {
  11734. confirmPeriods += 1;
  11735. }
  11736. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  11737. }
  11738. else
  11739. {
  11740. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  11741. }
  11742. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  11743. return result;
  11744. }
  11745. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  11746. {
  11747. mtrace();
  11748. int result = FAIL;
  11749. json_object *GetDisplayMessages;
  11750. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  11751. GetDisplayMessages = json_tokener_parse(payload);
  11752. if(!is_error(GetDisplayMessages))
  11753. {
  11754. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  11755. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  11756. // Required data
  11757. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  11758. {
  11759. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  11760. }
  11761. // Optional data
  11762. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  11763. {
  11764. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  11765. }
  11766. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  11767. {
  11768. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  11769. }
  11770. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  11771. {
  11772. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  11773. {
  11774. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  11775. }
  11776. strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  11777. ShmOCPP20Data->MsMsg.bits.GetDisplayMessagesReq = ON;
  11778. }
  11779. else
  11780. strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  11781. }
  11782. json_object_put(GetDisplayMessages);
  11783. return result;
  11784. }
  11785. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  11786. {
  11787. mtrace();
  11788. int result = FAIL;
  11789. json_object *GetInstalledCertificateIds;
  11790. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  11791. GetInstalledCertificateIds = json_tokener_parse(payload);
  11792. if(!is_error(GetInstalledCertificateIds))
  11793. {
  11794. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  11795. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  11796. // Optional data
  11797. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  11798. {
  11799. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  11800. {
  11801. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  11802. /*
  11803. * TODO:
  11804. * 1. Get installed certificate info for response
  11805. */
  11806. if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_V2GRootCertificate]) != NULL)
  11807. {
  11808. }
  11809. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_MORootCertificate]) != NULL)
  11810. {
  11811. }
  11812. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_CSMSRootCertificate]) != NULL)
  11813. {
  11814. }
  11815. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_V2GCertificateChain]) != NULL)
  11816. {
  11817. }
  11818. else
  11819. {
  11820. }
  11821. }
  11822. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  11823. }
  11824. else
  11825. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  11826. }
  11827. json_object_put(GetInstalledCertificateIds);
  11828. sendInstallCertificateConfirmation(uuid);
  11829. return result;
  11830. }
  11831. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  11832. {
  11833. mtrace();
  11834. int result = FAIL;
  11835. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  11836. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  11837. {
  11838. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  11839. localversion = -1;
  11840. }
  11841. else
  11842. {
  11843. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  11844. DB_getListVerion();
  11845. }
  11846. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  11847. sendGetLocalListVersionConfirmation(uuid);
  11848. return result;
  11849. }
  11850. static char fnamePlusPath[100]={0};
  11851. static char fnamePWithNoPath[60]={0};
  11852. void checkUploadLog(void)
  11853. {
  11854. FILE *fp;
  11855. /* Open the command for reading. */
  11856. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  11857. if (fp == NULL) {
  11858. printf("Failed to run command\n" );
  11859. exit(1);
  11860. }
  11861. int ftppathlen = 0;
  11862. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  11863. int i = 0;
  11864. /* Read the output a line at a time - output it. */
  11865. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  11866. if(i==0)
  11867. {
  11868. ftppathlen = strlen(fnamePlusPath);
  11869. printf("%s\n", fnamePlusPath);
  11870. fnamePlusPath[ftppathlen]='\0';
  11871. break;
  11872. }
  11873. i= i+1;
  11874. }
  11875. /* close */
  11876. pclose(fp);
  11877. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  11878. {
  11879. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  11880. {
  11881. fnamePlusPath[k]='\0';
  11882. }
  11883. }
  11884. i=1;
  11885. //char fname[60]={0};
  11886. while(i < ftppathlen)
  11887. {
  11888. int len=ftppathlen-i;
  11889. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  11890. {
  11891. printf("compare '/' all right\n");
  11892. break;
  11893. }
  11894. i=i+1;
  11895. }
  11896. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  11897. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  11898. fnamePWithNoPath[i+1] = '\0';
  11899. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  11900. {
  11901. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  11902. {
  11903. fnamePWithNoPath[j]='\0';
  11904. }
  11905. }
  11906. FILE* fp1 = fopen(fnamePlusPath, "r");
  11907. if (fp1)
  11908. {
  11909. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  11910. // file exists
  11911. fclose(fp1);
  11912. }
  11913. else
  11914. {
  11915. // file doesn't exist
  11916. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  11917. }
  11918. }
  11919. void* GetLogProcess(void* data)
  11920. {
  11921. pthread_detach(pthread_self());
  11922. mtrace();
  11923. int requestId, retriesInt=0, retryIntervalInt=0;
  11924. char logType[32], remoteLocation[1024]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  11925. char protocol[10]={0}, user[64]={0},password[64]={0},host[128]={0}, path[512]={0}, ftppath[512]={0},host1[128]={0},path1[512]={0};
  11926. int port=0;
  11927. int isSuccess = FALSE;
  11928. char ftpbuf[1024]={0};
  11929. char cmdBuf[2048];
  11930. struct tm *tmNow;
  11931. time_t CurrentTime;
  11932. struct tm tmStart;
  11933. struct tm tmStop;
  11934. CurrentTime = time(NULL);
  11935. tmNow=localtime(&CurrentTime);
  11936. uint16_t targetYear, targetMonth;
  11937. json_object *GetLog;
  11938. DEBUG_INFO("GetGetProcess...\n");
  11939. GetLog = json_tokener_parse(data);
  11940. if(!is_error(GetLog))
  11941. {
  11942. // Required data
  11943. if(json_object_object_get(GetLog, "requestId") != NULL)
  11944. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  11945. if(json_object_object_get(GetLog, "logType") != NULL)
  11946. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  11947. if(json_object_object_get(GetLog, "log") != NULL)
  11948. {
  11949. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  11950. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  11951. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  11952. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  11953. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  11954. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  11955. }
  11956. // Optional data
  11957. if(json_object_object_get(GetLog, "retries") != NULL)
  11958. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  11959. else
  11960. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  11961. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  11962. retryIntervalInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  11963. else
  11964. retryIntervalInt = 30;
  11965. }
  11966. json_object_put(GetLog);
  11967. ShmOCPP20Data->GetLog.requestId = requestId;
  11968. if(strstr(logType, LogEnumTypeStr[LogEnumType_SecurityLog]))
  11969. {
  11970. /*
  11971. * TODO:
  11972. * 1. Pack security log
  11973. */
  11974. }
  11975. else
  11976. {
  11977. // Pack log to compress file
  11978. 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) &&
  11979. (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))
  11980. {
  11981. // Pack system log
  11982. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  11983. sprintf(cmdBuf, "exec zip -9 --password %04d%02d%s /mnt/system.zip", tmNow->tm_year+1900, tmNow->tm_mon+1, ShmSysConfigAndInfo->SysConfig.SerialNumber);
  11984. targetYear = tmStart.tm_year;
  11985. targetMonth = tmStart.tm_mon;
  11986. do
  11987. {
  11988. sprintf(cmdBuf, "%s /Storage/SystemLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  11989. sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  11990. if(targetMonth+1>=13)
  11991. {
  11992. targetYear += 1;
  11993. targetMonth = 1;
  11994. }
  11995. else
  11996. {
  11997. targetMonth += 1;
  11998. }
  11999. }while((targetYear < (tmNow->tm_year+1900)) ||
  12000. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  12001. sprintf(cmdBuf, "%s /Storage/CCS*.zip", cmdBuf);
  12002. system(cmdBuf);
  12003. // Pack charging & event log
  12004. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  12005. sprintf(cmdBuf, "exec zip -9 /mnt/charging_event.zip");
  12006. targetYear = tmStart.tm_year;
  12007. targetMonth = tmStart.tm_mon;
  12008. do
  12009. {
  12010. sprintf(cmdBuf, "%s /Storage/EventLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  12011. if(targetMonth+1>=13)
  12012. {
  12013. targetYear += 1;
  12014. targetMonth = 1;
  12015. }
  12016. else
  12017. {
  12018. targetMonth += 1;
  12019. }
  12020. }while((targetYear < (tmNow->tm_year+1900)) ||
  12021. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  12022. sprintf(cmdBuf, "%s /Storage/ChargeLog/*.db", cmdBuf);
  12023. sprintf(cmdBuf, "%s /Storage/EventLog/*.db", cmdBuf);
  12024. system(cmdBuf);
  12025. // Combine log file
  12026. system("exec zip -9 /mnt/log.zip /mnt/system.zip /mnt/charging_event.zip");
  12027. system("exec rm -f /mnt/system.zip /mnt/charging_event.zip");
  12028. }
  12029. else
  12030. {
  12031. system("exec /root/logPackTools 'log' 6");
  12032. }
  12033. }
  12034. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", ShmOCPP20Data->GetLog.Response_filename);
  12035. system(cmdBuf);
  12036. checkUploadLog();
  12037. //****************location*******************/
  12038. if(strcmp(remoteLocation,"")==0)
  12039. {
  12040. DEBUG_INFO("remoteLocation is <Empty>!\n");
  12041. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12042. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12043. goto end;
  12044. }
  12045. memset(protocol, 0, ARRAY_SIZE(protocol));
  12046. memset(user, 0, ARRAY_SIZE(user) );
  12047. memset(password, 0, ARRAY_SIZE(password));
  12048. memset(host, 0, ARRAY_SIZE(host));
  12049. memset(path, 0, ARRAY_SIZE(path));
  12050. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12051. memset(host1, 0, ARRAY_SIZE(host1));
  12052. memset(path1, 0, ARRAY_SIZE(path1));
  12053. /*location: ftp://user:password@host:port/path*/
  12054. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  12055. if((access(fnamePlusPath,F_OK))!=-1)
  12056. {
  12057. DEBUG_INFO("fnamePlusPath exist.\n");
  12058. }
  12059. else
  12060. {
  12061. DEBUG_INFO("fnamePlusPath not exist!\n");
  12062. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12063. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12064. goto end;
  12065. }
  12066. if(strchr(remoteLocation,'@')==NULL)
  12067. {
  12068. sscanf(remoteLocation,
  12069. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12070. protocol, host, &port, path);
  12071. strcpy(user,"anonymous");
  12072. strcpy(password,"");
  12073. }
  12074. else
  12075. {
  12076. //DEBUG_INFO("pch=%s\n", pch);
  12077. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12078. protocol, user, password, host, &port, path);
  12079. }
  12080. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0)&&(strcmp(protocol,"https")!=0))
  12081. {
  12082. DEBUG_INFO("protocol is not ftp/http ! \n");
  12083. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12084. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12085. goto end;
  12086. }
  12087. if(strncmp(remoteLocation,"http", 4) == 0)
  12088. {
  12089. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12090. sprintf(ftppath,"/%s", path);
  12091. do
  12092. {
  12093. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  12094. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12095. sleep(3);
  12096. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  12097. if(!isSuccess)
  12098. {
  12099. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  12100. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12101. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12102. sleep(retryIntervalInt);
  12103. }
  12104. else
  12105. {
  12106. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  12107. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  12108. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12109. }
  12110. retriesInt--;
  12111. }while((isSuccess == 0)&&(retriesInt >= 0));
  12112. }
  12113. else
  12114. {
  12115. sscanf(host,"%[^/]%s",host1, path1);
  12116. if(strlen(path) > 0)
  12117. sprintf(ftppath,"/%s", path);
  12118. else
  12119. sprintf(ftppath,"/%s", path1);
  12120. int ftppathlen=strlen(ftppath);
  12121. int i=1;
  12122. char filenametemp[50];
  12123. while(i < ftppathlen)
  12124. {
  12125. int len=ftppathlen-i;
  12126. if(ftppath[len]== 47) // '/' ascll code: 47
  12127. {
  12128. DEBUG_INFO("find '/' all right\n");
  12129. break;
  12130. }
  12131. i=i+1;
  12132. }
  12133. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12134. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  12135. filenametemp[i+1] = 0;
  12136. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12137. if(port == 0)
  12138. port = 21;
  12139. do
  12140. {
  12141. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  12142. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12143. sleep(3);
  12144. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  12145. if(!isSuccess)
  12146. {
  12147. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  12148. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12149. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12150. sleep(retryIntervalInt);
  12151. }
  12152. else
  12153. {
  12154. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  12155. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  12156. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12157. }
  12158. retriesInt--;
  12159. }while((!isSuccess)&&(retriesInt >= 0));
  12160. }
  12161. end:
  12162. system("rm -f /mnt/*");
  12163. sleep(5);
  12164. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  12165. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12166. interLock.isGetLogGoing = OFF;
  12167. pthread_exit(NULL);
  12168. }
  12169. int handleGetLogRequest(char *uuid, char *payload)
  12170. {
  12171. mtrace();
  12172. int result = FAIL;
  12173. char fName[258];
  12174. time_t CurrentTime;
  12175. struct tm *tm;
  12176. pthread_t th_Status;
  12177. CurrentTime = time(NULL);
  12178. tm = localtime(&CurrentTime);
  12179. 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);
  12180. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  12181. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  12182. sendGetLogConfirmation(uuid);
  12183. if(!interLock.isGetLogGoing)
  12184. {
  12185. interLock.isGetLogGoing = ON;
  12186. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  12187. sleep(1);
  12188. }
  12189. else
  12190. DEBUG_WARN("Other GetDiagnostic request on going.\n");
  12191. return result;
  12192. }
  12193. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  12194. {
  12195. mtrace();
  12196. int result = FAIL;
  12197. json_object *GetMonitoringReport;
  12198. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  12199. GetMonitoringReport = json_tokener_parse(payload);
  12200. if(!is_error(GetMonitoringReport))
  12201. {
  12202. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  12203. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  12204. // Required data
  12205. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  12206. {
  12207. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  12208. }
  12209. // Optional data
  12210. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  12211. {
  12212. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  12213. }
  12214. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  12215. {
  12216. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  12217. {
  12218. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  12219. {
  12220. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  12221. {
  12222. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  12223. {
  12224. 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")));
  12225. }
  12226. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  12227. {
  12228. 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")));
  12229. }
  12230. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  12231. {
  12232. 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)
  12233. {
  12234. 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"));
  12235. }
  12236. 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)
  12237. {
  12238. 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"));
  12239. }
  12240. }
  12241. }
  12242. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  12243. {
  12244. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  12245. {
  12246. 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")));
  12247. }
  12248. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  12249. {
  12250. 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")));
  12251. }
  12252. }
  12253. }
  12254. }
  12255. }
  12256. }
  12257. json_object_put(GetMonitoringReport);
  12258. /*
  12259. * TODO:
  12260. * 1. Response result
  12261. */
  12262. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12263. sendGetMonitoringReportConfirmation(uuid);
  12264. return result;
  12265. }
  12266. int handleGetReportRequest(char *uuid, char *payload)
  12267. {
  12268. mtrace();
  12269. int result = FAIL;
  12270. json_object *GetReport;
  12271. DEBUG_INFO("handleGetReportRequest...\n");
  12272. GetReport = json_tokener_parse(payload);
  12273. if(!is_error(GetReport))
  12274. {
  12275. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  12276. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  12277. // Required data
  12278. if(json_object_object_get(GetReport, "requestId") != NULL)
  12279. {
  12280. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  12281. }
  12282. // Optional data
  12283. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  12284. {
  12285. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  12286. }
  12287. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  12288. {
  12289. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  12290. {
  12291. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  12292. {
  12293. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  12294. {
  12295. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  12296. {
  12297. 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")));
  12298. }
  12299. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  12300. {
  12301. 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")));
  12302. }
  12303. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  12304. {
  12305. 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)
  12306. {
  12307. 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"));
  12308. }
  12309. 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)
  12310. {
  12311. 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"));
  12312. }
  12313. }
  12314. }
  12315. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  12316. {
  12317. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  12318. {
  12319. 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")));
  12320. }
  12321. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  12322. {
  12323. 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")));
  12324. }
  12325. }
  12326. }
  12327. }
  12328. }
  12329. }
  12330. json_object_put(GetReport);
  12331. /*
  12332. * TODO:
  12333. * 1. Response result
  12334. */
  12335. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12336. sendGetReportConfirmation(uuid);
  12337. return result;
  12338. }
  12339. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  12340. {
  12341. mtrace();
  12342. int result = FAIL;
  12343. int8_t gun_index = -1;
  12344. json_object *GetTransactionStatus;
  12345. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  12346. GetTransactionStatus = json_tokener_parse(payload);
  12347. if(!is_error(GetTransactionStatus))
  12348. {
  12349. /*
  12350. * TODO:
  12351. * 1. Check transaction locate which connector
  12352. */
  12353. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  12354. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  12355. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  12356. {
  12357. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  12358. }
  12359. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  12360. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  12361. }
  12362. json_object_put(GetTransactionStatus);
  12363. sendGetTransactionStatusConfirmation(uuid, gun_index);
  12364. return result;
  12365. }
  12366. int handleGetVariablesRequest(char *uuid, char *payload)
  12367. {
  12368. mtrace();
  12369. int result = FAIL;
  12370. json_object *GetVariables;
  12371. DEBUG_INFO("handleGetVariablesRequest...\n");
  12372. GetVariables = json_tokener_parse(payload);
  12373. if(!is_error(GetVariables))
  12374. {
  12375. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  12376. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  12377. // Required data
  12378. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  12379. {
  12380. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  12381. {
  12382. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  12383. {
  12384. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  12385. {
  12386. 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")));
  12387. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  12388. }
  12389. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  12390. {
  12391. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  12392. {
  12393. 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")));
  12394. }
  12395. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  12396. {
  12397. 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")));
  12398. }
  12399. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  12400. {
  12401. 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)
  12402. {
  12403. 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"));
  12404. }
  12405. 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)
  12406. {
  12407. 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"));
  12408. }
  12409. }
  12410. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  12411. }
  12412. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  12413. {
  12414. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  12415. {
  12416. 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")));
  12417. }
  12418. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  12419. {
  12420. 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")));
  12421. }
  12422. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  12423. }
  12424. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  12425. {
  12426. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
  12427. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance) == 0) &&
  12428. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
  12429. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance) == 0))
  12430. {
  12431. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  12432. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  12433. break;
  12434. }
  12435. else
  12436. {
  12437. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  12438. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  12439. }
  12440. }
  12441. }
  12442. }
  12443. }
  12444. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  12445. }
  12446. json_object_put(GetVariables);
  12447. return result;
  12448. }
  12449. int handleInstallCertificateRequest(char *uuid, char *payload)
  12450. {
  12451. mtrace();
  12452. int result = FAIL;
  12453. json_object *InstallCertificate;
  12454. DEBUG_INFO("handleInstallCertificateRequest...\n");
  12455. InstallCertificate = json_tokener_parse(payload);
  12456. if(!is_error(InstallCertificate))
  12457. {
  12458. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  12459. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  12460. // Required data
  12461. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  12462. {
  12463. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  12464. }
  12465. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  12466. {
  12467. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  12468. }
  12469. }
  12470. json_object_put(InstallCertificate);
  12471. /*
  12472. * TODO:
  12473. * 1. Install certification preocess and response
  12474. */
  12475. if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_V2GRootCertificate]))
  12476. {
  12477. }
  12478. else if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_MORootCertificate]))
  12479. {
  12480. }
  12481. else if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_CSMSRootCertificate]))
  12482. {
  12483. }
  12484. else
  12485. {
  12486. }
  12487. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12488. sendInstallCertificateConfirmation(uuid);
  12489. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  12490. return result;
  12491. }
  12492. int handlePublishFirmwareRequest(char *uuid, char *payload)
  12493. {
  12494. mtrace();
  12495. int result = FAIL;
  12496. json_object *PublishFirmware;
  12497. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  12498. PublishFirmware = json_tokener_parse(payload);
  12499. if(!is_error(PublishFirmware))
  12500. {
  12501. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  12502. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  12503. // Required data
  12504. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  12505. {
  12506. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  12507. }
  12508. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  12509. {
  12510. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  12511. }
  12512. // Optional data
  12513. if(json_object_object_get(PublishFirmware, "location") != NULL)
  12514. {
  12515. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  12516. }
  12517. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  12518. {
  12519. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  12520. }
  12521. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  12522. {
  12523. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  12524. }
  12525. }
  12526. json_object_put(PublishFirmware);
  12527. /*
  12528. * TODO:
  12529. * 1. Publish firmware preocess and response
  12530. */
  12531. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12532. sendPublishFirmwareConfirmation(uuid);
  12533. return result;
  12534. }
  12535. int handleRequestStartTransactionRequest(char *uuid, char *payload)
  12536. {
  12537. mtrace();
  12538. int result = FAIL;
  12539. int8_t gun_index = -1;
  12540. uint8_t tempIndex;
  12541. uint8_t isPeriodOverMax = FALSE;
  12542. uint8_t isProfileOverMax = FALSE;
  12543. uint8_t isTxProfile = TRUE;
  12544. uint8_t isAllowStart = TRUE;
  12545. uint8_t existProfileQuantity = 0;
  12546. uint8_t filename[128]={0};
  12547. uint8_t word[2048]={0};
  12548. char cmdBuf[128];
  12549. FILE *filePtr;
  12550. json_object *RemoteStartTransaction;
  12551. DEBUG_INFO("handleRequestStartTransactionRequest...\n");
  12552. RemoteStartTransaction = json_tokener_parse(payload);
  12553. if(!is_error(RemoteStartTransaction))
  12554. {
  12555. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  12556. {
  12557. gun_index = ((0 < json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))) && (json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))<=gunTotalNumber))?(json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))-1):-1;
  12558. }
  12559. else
  12560. {
  12561. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  12562. {
  12563. if(!cpinitateMsg.bits[idx].isOnCharging && (strstr((char*)ShmOCPP20Data->StatusNotification[idx].connectorStatus, ConnectorStatusEnumTypeStr[ConnectorStatusEnumType_Occupied]) != NULL))
  12564. {
  12565. gun_index = idx;
  12566. DEBUG_INFO("Remote start without connectorId but detect connector-%02d connected ready to start.\n", (gun_index+1));
  12567. break;
  12568. }
  12569. }
  12570. }
  12571. if(gun_index >= 0)
  12572. {
  12573. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  12574. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  12575. // Required data
  12576. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  12577. {
  12578. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  12579. }
  12580. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  12581. {
  12582. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  12583. {
  12584. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  12585. }
  12586. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  12587. {
  12588. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  12589. }
  12590. }
  12591. // Optional data
  12592. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  12593. {
  12594. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  12595. {
  12596. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  12597. }
  12598. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  12599. {
  12600. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  12601. }
  12602. }
  12603. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  12604. {
  12605. // Check periods is over max configuration
  12606. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
  12607. {
  12608. isPeriodOverMax = TRUE;
  12609. }
  12610. // Check profile purpose is TxProfile
  12611. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  12612. {
  12613. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", (gun_index+1));
  12614. filePtr = fopen((char*)filename, "r");
  12615. if (!filePtr)
  12616. {
  12617. DEBUG_INFO("%s not exist, create it.\n", filename);
  12618. filePtr = fopen((char*)filename, "w+");
  12619. }
  12620. else
  12621. {
  12622. //Check Charging Profile Count
  12623. while(fscanf(filePtr, "%s", word) != EOF)
  12624. {
  12625. //DEBUG_INFO("word=%s\n",word);
  12626. if(strstr((char*)word, "id")!= NULL)
  12627. {
  12628. existProfileQuantity += 1;
  12629. }
  12630. }
  12631. }
  12632. fclose(filePtr);
  12633. }
  12634. else
  12635. {
  12636. isTxProfile = FALSE;
  12637. }
  12638. if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
  12639. isProfileOverMax = TRUE;
  12640. }
  12641. //check Transaction active
  12642. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  12643. {
  12644. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12645. {
  12646. tempIndex = (gun_index == 2) ? 1: 0;
  12647. }
  12648. else
  12649. {
  12650. tempIndex = gun_index;
  12651. }
  12652. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12653. {
  12654. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
  12655. {
  12656. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) == 0))
  12657. {
  12658. //Reserved
  12659. DEBUG_INFO("Reserved now! The idTag matches the idTag of Reservation!\n");
  12660. }
  12661. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) != 0))
  12662. {
  12663. //Reserved
  12664. DEBUG_INFO("Reserved now! The idTag does NOT match the idTag of Reservation! Reject it!\n");
  12665. isAllowStart = FALSE;
  12666. }
  12667. else
  12668. {
  12669. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  12670. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) //S_PRECHARGE
  12671. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) //S_PREPARING_FOR_EV
  12672. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE )) // S_PREPARING_FOR_EVSE
  12673. {
  12674. DEBUG_WARN("CHAdeMO connector not allow start\n.");
  12675. isAllowStart = FALSE;
  12676. }
  12677. }//END FOR ELSE
  12678. }
  12679. }// END FOR CHAdeMO_QUANTITY
  12680. }
  12681. else if(gunType[gun_index] == GUN_TYPE_CCS)
  12682. {
  12683. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12684. {
  12685. tempIndex = (gun_index == 2) ? 1: 0;
  12686. }
  12687. else
  12688. {
  12689. tempIndex = gun_index;
  12690. }
  12691. for (int index = 0; index < CCS_QUANTITY; index++)
  12692. {
  12693. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  12694. {
  12695. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) == 0))
  12696. {
  12697. //Reserved
  12698. DEBUG_INFO("Reserved now! The idTag matches the idTag of Reservation!\n");
  12699. }
  12700. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) != 0))
  12701. {
  12702. //Reserved
  12703. DEBUG_INFO("Reserved now! The idTag does NOT match the idTag of Reservation! Reject it!\n");
  12704. isAllowStart = FALSE;
  12705. }
  12706. else
  12707. {
  12708. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  12709. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  12710. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  12711. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  12712. {
  12713. DEBUG_WARN("CCS connector not allow start\n.");
  12714. isAllowStart = FALSE;
  12715. }
  12716. }// END FOR ELSE
  12717. }
  12718. }// END FOR CCS_QUANTITY
  12719. }
  12720. else if(gunType[gun_index] == GUN_TYPE_GBT)
  12721. {
  12722. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12723. {
  12724. tempIndex = (gun_index == 2) ? 1: 0;
  12725. }
  12726. else
  12727. {
  12728. tempIndex = gun_index;
  12729. }
  12730. for (int index = 0; index < GB_QUANTITY; index++)
  12731. {
  12732. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
  12733. {
  12734. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) == 0))
  12735. {
  12736. //Reserved
  12737. DEBUG_INFO("Reserved now! The idTag matches the idTag of Reservation!\n");
  12738. }
  12739. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) != 0))
  12740. {
  12741. //Reserved
  12742. DEBUG_INFO("Reserved now! The idTag does NOT match the idTag of Reservation! Reject it!\n");
  12743. isAllowStart = FALSE;
  12744. }
  12745. else
  12746. {
  12747. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  12748. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  12749. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  12750. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  12751. {
  12752. DEBUG_WARN("GB connector not allow start\n.");
  12753. isAllowStart = FALSE;
  12754. }
  12755. }// END FOR ELSE
  12756. }
  12757. } // END FOR GB_QUANTITY
  12758. }
  12759. else if(gunType[gun_index] == GUN_TYPE_DO)
  12760. {
  12761. tempIndex = gun_index;
  12762. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  12763. {
  12764. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
  12765. {
  12766. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) == 0))
  12767. {
  12768. //Reserved
  12769. DEBUG_INFO("Reserved now! The idTag matches the idTag of Reservation!\n");
  12770. }
  12771. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) != 0))
  12772. {
  12773. //Reserved
  12774. DEBUG_INFO("Reserved now! The idTag does NOT match the idTag of Reservation! Reject it!\n");
  12775. isAllowStart = FALSE;
  12776. }
  12777. else
  12778. {
  12779. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) //S_IDLE
  12780. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  12781. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  12782. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  12783. {
  12784. DEBUG_WARN("GB connector not allow start\n.");
  12785. isAllowStart = FALSE;
  12786. }
  12787. }// END FOR ELSE
  12788. }
  12789. } // END FOR GB_QUANTITY
  12790. }
  12791. else
  12792. {
  12793. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  12794. {
  12795. tempIndex = 2;
  12796. }
  12797. else
  12798. {
  12799. tempIndex = gun_index;
  12800. }
  12801. for (int index = 0; index < AC_QUANTITY; index++)
  12802. {
  12803. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
  12804. {
  12805. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) == 0))
  12806. {
  12807. //Reserved
  12808. DEBUG_INFO("Reserved now! The idTag matches the idTag of Reservation!\n");
  12809. }
  12810. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken) != 0))
  12811. {
  12812. //Reserved
  12813. DEBUG_INFO("Reserved now! The idTag does NOT match the idTag of Reservation! Reject it!\n");
  12814. isAllowStart = FALSE;
  12815. }
  12816. else
  12817. {
  12818. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  12819. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  12820. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  12821. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  12822. {
  12823. DEBUG_WARN("AC connector not allow start\n.");
  12824. isAllowStart = FALSE;
  12825. }
  12826. }//END FOR ELSE
  12827. }
  12828. }// END FOR AC_QUANTITY
  12829. }
  12830. }
  12831. // Profile replace or add info
  12832. if((gun_index >= 0) && !isPeriodOverMax && !isProfileOverMax && isTxProfile && isAllowStart)
  12833. {
  12834. if(strlen((char*)filename) > 0)
  12835. {
  12836. // Save profile to file
  12837. sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_%d_OCPP20.json", (gun_index+1));
  12838. system(cmdBuf);
  12839. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json.json", (gun_index+1));
  12840. filePtr = fopen((char*)filename, "w");
  12841. fprintf(filePtr, "{\"evseId\":%d,\"chargingProfile\":%s}\n", (gun_index+1), json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
  12842. fclose(filePtr);
  12843. }
  12844. ShmOCPP20Data->CsMsg.bits[gun_index].RequestStartTransactionReq = ON;
  12845. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  12846. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId);
  12847. result = PASS;
  12848. }
  12849. else
  12850. {
  12851. if(gun_index < 0)
  12852. DEBUG_WARN("evseId id is wrong.\n");
  12853. if(isPeriodOverMax)
  12854. DEBUG_WARN("Profile periods quantity is over spec.\n");
  12855. if(isProfileOverMax)
  12856. DEBUG_WARN("Profile quantity is over spec.\n");
  12857. if(!isTxProfile)
  12858. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  12859. if(!isAllowStart)
  12860. DEBUG_WARN("Target connector does not allow start.\n");
  12861. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index<0?0:gun_index)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  12862. }
  12863. }
  12864. json_object_put(RemoteStartTransaction);
  12865. sendRemoteStartTransactionConfirmation(uuid, (gun_index<0?0:gun_index));
  12866. return result;
  12867. }
  12868. int handleRequestStopTransactionRequest(char *uuid, char *payload)
  12869. {
  12870. mtrace();
  12871. int result = FAIL;
  12872. int match = FALSE;
  12873. int GunNO = 0;
  12874. int tempIndex = 0;
  12875. char transactionIdStr[37];
  12876. int transactionIdIsNULL= TRUE;
  12877. json_object *RemoteStopTransaction;
  12878. DEBUG_INFO("handleRequestStopTransactionRequest...\n");
  12879. if(server_pending == TRUE)
  12880. {
  12881. return 0;
  12882. }
  12883. RemoteStopTransaction = json_tokener_parse(payload);
  12884. if(!is_error(RemoteStopTransaction))
  12885. {
  12886. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  12887. {
  12888. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  12889. transactionIdIsNULL = FALSE;
  12890. }
  12891. }
  12892. json_object_put(RemoteStopTransaction);
  12893. if(transactionIdIsNULL == FALSE)
  12894. {
  12895. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  12896. {
  12897. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  12898. {
  12899. //check Transaction active
  12900. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  12901. {
  12902. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12903. {
  12904. tempIndex = ((gun_index==2) ? 1: 0);
  12905. }
  12906. else
  12907. {
  12908. tempIndex = gun_index;
  12909. }
  12910. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12911. {
  12912. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  12913. {
  12914. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  12915. {
  12916. match = TRUE;
  12917. GunNO = gun_index;
  12918. }
  12919. }
  12920. }// END FOR CHAdeMO_QUANTITY
  12921. }
  12922. else if(gunType[gun_index] == GUN_TYPE_CCS)
  12923. {
  12924. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12925. {
  12926. tempIndex = ((gun_index==2) ? 1: 0);
  12927. }
  12928. else
  12929. {
  12930. tempIndex = gun_index;
  12931. }
  12932. for (int index = 0; index < CCS_QUANTITY; index++)
  12933. {
  12934. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  12935. {
  12936. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  12937. {
  12938. match = TRUE;
  12939. GunNO = gun_index;
  12940. }
  12941. }
  12942. }// END FOR CCS_QUANTITY
  12943. }
  12944. else if(gunType[gun_index] == GUN_TYPE_GBT)
  12945. {
  12946. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12947. {
  12948. tempIndex = ((gun_index==2) ? 1: 0);
  12949. }
  12950. else
  12951. {
  12952. tempIndex = gun_index;
  12953. }
  12954. for (int index = 0; index < GB_QUANTITY; index++)
  12955. {
  12956. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  12957. {
  12958. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  12959. {
  12960. match = TRUE;
  12961. GunNO = gun_index;
  12962. }
  12963. }
  12964. }// END FOR GB_QUANTITY
  12965. }
  12966. else if(gunType[gun_index] == GUN_TYPE_DO)
  12967. {
  12968. tempIndex = gun_index;
  12969. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  12970. {
  12971. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  12972. {
  12973. 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
  12974. {
  12975. match = TRUE;
  12976. GunNO = gun_index;
  12977. }
  12978. }
  12979. }// END FOR GB_QUANTITY
  12980. }
  12981. else
  12982. {
  12983. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  12984. {
  12985. tempIndex = 2;
  12986. }
  12987. else
  12988. {
  12989. tempIndex = gun_index;
  12990. }
  12991. for (int index = 0; index < AC_QUANTITY; index++)
  12992. {
  12993. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  12994. {
  12995. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  12996. {
  12997. match = TRUE;
  12998. GunNO = gun_index;
  12999. }
  13000. }
  13001. }// END FOR CHAdeMO_QUANTITY
  13002. } // END FOR AC ELSE
  13003. }// CHECK IF ResponseTransactionId == transactionIdInt
  13004. }//END FOR
  13005. if( match == TRUE)
  13006. {
  13007. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  13008. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  13009. }
  13010. else
  13011. {
  13012. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  13013. }
  13014. }
  13015. else
  13016. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  13017. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  13018. return result;
  13019. }
  13020. int handleReserveNowRequest(char *uuid, char *payload)
  13021. {
  13022. mtrace();
  13023. int result = FAIL;
  13024. int connectorIdInt=0, reservationIdInt=0;
  13025. int tempIndex = 0;
  13026. json_object *ReserveNow;
  13027. DEBUG_INFO("handleReserveNowRequest ...\n");
  13028. ReserveNow = json_tokener_parse(payload);
  13029. if(!is_error(ReserveNow))
  13030. {
  13031. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  13032. {
  13033. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  13034. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  13035. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  13036. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  13037. }
  13038. // Required data
  13039. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  13040. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  13041. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  13042. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  13043. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  13044. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  13045. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  13046. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  13047. // Optional data
  13048. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  13049. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  13050. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  13051. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  13052. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  13053. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  13054. result = PASS;
  13055. }
  13056. json_object_put(ReserveNow);
  13057. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13058. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  13059. {
  13060. //check Transaction active
  13061. if(gunType[connectorIdInt -1] == GUN_TYPE_CHAdeMO)
  13062. {
  13063. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13064. {
  13065. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  13066. }
  13067. else
  13068. {
  13069. tempIndex = connectorIdInt -1;
  13070. }
  13071. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13072. {
  13073. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  13074. {
  13075. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  13076. {
  13077. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  13078. {
  13079. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13080. {
  13081. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13082. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13083. }
  13084. 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'))
  13085. {
  13086. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13087. }
  13088. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  13089. {
  13090. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13091. }
  13092. else
  13093. {
  13094. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13095. }
  13096. }
  13097. 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
  13098. {
  13099. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13100. }
  13101. }
  13102. else
  13103. {
  13104. //replace reservation
  13105. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13106. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13107. }
  13108. }
  13109. } // END FOR CHAdeMO_QUANTITY
  13110. }
  13111. else if(gunType[connectorIdInt -1] == GUN_TYPE_CCS)
  13112. {
  13113. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13114. {
  13115. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  13116. }
  13117. else
  13118. {
  13119. tempIndex = connectorIdInt -1;
  13120. }
  13121. for (int index = 0; index < CCS_QUANTITY; index++)
  13122. {
  13123. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  13124. {
  13125. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  13126. {
  13127. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  13128. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  13129. {
  13130. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13131. {
  13132. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13133. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13134. }
  13135. 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'))
  13136. {
  13137. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13138. }
  13139. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  13140. {
  13141. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13142. }
  13143. else
  13144. {
  13145. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13146. }
  13147. }
  13148. 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
  13149. {
  13150. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13151. }
  13152. }
  13153. else
  13154. {
  13155. //replace reservation
  13156. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13157. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13158. }
  13159. }
  13160. } // END FOR CCS_QUANTITY
  13161. }
  13162. else if(gunType[connectorIdInt -1] == GUN_TYPE_GBT)
  13163. {
  13164. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13165. {
  13166. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  13167. }
  13168. else
  13169. {
  13170. tempIndex = connectorIdInt -1;
  13171. }
  13172. for (int index = 0; index < GB_QUANTITY; index++)
  13173. {
  13174. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  13175. {
  13176. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  13177. {
  13178. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  13179. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  13180. {
  13181. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13182. {
  13183. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13184. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13185. }
  13186. 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'))
  13187. {
  13188. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13189. }
  13190. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  13191. {
  13192. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13193. }
  13194. else
  13195. {
  13196. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13197. }
  13198. }
  13199. 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
  13200. {
  13201. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13202. }
  13203. }
  13204. else
  13205. {
  13206. //replace reservation
  13207. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13208. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13209. }
  13210. }
  13211. }// END FOR GB_QUANTITY
  13212. }
  13213. else if(gunType[connectorIdInt -1] == GUN_TYPE_DO)
  13214. {
  13215. tempIndex = connectorIdInt -1;
  13216. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13217. {
  13218. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  13219. {
  13220. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId)
  13221. {
  13222. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  13223. 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
  13224. {
  13225. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13226. {
  13227. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13228. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13229. }
  13230. 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'))
  13231. {
  13232. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13233. }
  13234. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  13235. {
  13236. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13237. }
  13238. else
  13239. {
  13240. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13241. }
  13242. }
  13243. 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
  13244. {
  13245. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13246. }
  13247. }
  13248. else
  13249. {
  13250. //replace reservation
  13251. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13252. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13253. }
  13254. }
  13255. }// END FOR DO_QUANTITY
  13256. }
  13257. else
  13258. {
  13259. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13260. {
  13261. tempIndex = 2;
  13262. }
  13263. else
  13264. {
  13265. tempIndex = (connectorIdInt -1);
  13266. }
  13267. for (int index = 0; index < AC_QUANTITY; index++)
  13268. {
  13269. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  13270. {
  13271. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  13272. {
  13273. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  13274. {
  13275. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13276. {
  13277. 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))
  13278. {
  13279. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13280. }
  13281. else
  13282. {
  13283. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13284. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13285. }
  13286. }
  13287. 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'))
  13288. {
  13289. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13290. }
  13291. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  13292. {
  13293. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13294. }
  13295. else
  13296. {
  13297. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13298. }
  13299. }
  13300. 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
  13301. {
  13302. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13303. }
  13304. }
  13305. else
  13306. {
  13307. //replace reservation
  13308. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13309. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13310. }
  13311. }
  13312. } // END FOR AC_QUANTITY
  13313. }
  13314. }
  13315. else if(connectorIdInt == 0)
  13316. {
  13317. //check Transaction active
  13318. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13319. {
  13320. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  13321. {
  13322. 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'))
  13323. {
  13324. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13325. goto end;
  13326. }
  13327. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  13328. {
  13329. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13330. goto end;
  13331. }
  13332. 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
  13333. {
  13334. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13335. goto end;
  13336. }
  13337. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13338. {
  13339. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13340. goto end;
  13341. }
  13342. }
  13343. }// END FOR CHAdeMO_QUANTITY
  13344. for (int index = 0; index < CCS_QUANTITY; index++)
  13345. {
  13346. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  13347. {
  13348. 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'))
  13349. {
  13350. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13351. goto end;
  13352. }
  13353. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  13354. {
  13355. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13356. goto end;
  13357. }
  13358. 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
  13359. {
  13360. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13361. goto end;
  13362. }
  13363. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13364. {
  13365. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13366. goto end;
  13367. }
  13368. }
  13369. } // END FOR CCS_QUANTITY
  13370. for (int index = 0; index < GB_QUANTITY; index++)
  13371. {
  13372. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  13373. {
  13374. 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'))
  13375. {
  13376. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13377. goto end;
  13378. }
  13379. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  13380. {
  13381. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13382. goto end;
  13383. }
  13384. 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
  13385. {
  13386. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13387. goto end;
  13388. }
  13389. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13390. {
  13391. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13392. goto end;
  13393. }
  13394. }
  13395. } // END FOR GB_QUANTITY
  13396. for (int index = 0; index < AC_QUANTITY; index++)
  13397. {
  13398. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  13399. {
  13400. 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'))
  13401. {
  13402. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13403. goto end;
  13404. }
  13405. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  13406. {
  13407. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13408. goto end;
  13409. }
  13410. 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
  13411. {
  13412. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13413. goto end;
  13414. }
  13415. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13416. {
  13417. 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))
  13418. {
  13419. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13420. goto end;
  13421. }
  13422. }
  13423. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13424. {
  13425. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13426. goto end;
  13427. }
  13428. }
  13429. }// END FOR AC_QUANTITY
  13430. //The connectorId is 0
  13431. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  13432. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13433. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  13434. result = TRUE;
  13435. return result;
  13436. }
  13437. else
  13438. {
  13439. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13440. }
  13441. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  13442. {
  13443. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  13444. result = TRUE;
  13445. return result;
  13446. }
  13447. end:
  13448. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  13449. return result;
  13450. }
  13451. int handleResetRequest(char *uuid, char *payload)
  13452. {
  13453. mtrace();
  13454. int result = FAIL;
  13455. json_object *Reset = json_object_new_object();
  13456. DEBUG_INFO("handleResetRequest...\n");
  13457. Reset = json_tokener_parse(payload);
  13458. if(!is_error(Reset))
  13459. {
  13460. // Required data
  13461. if(json_object_object_get(Reset, "type") != NULL)
  13462. {
  13463. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  13464. }
  13465. if(json_object_object_get(Reset, "evseId") != NULL)
  13466. {
  13467. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  13468. }
  13469. }
  13470. json_object_put(Reset);
  13471. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  13472. {
  13473. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  13474. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]);
  13475. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  13476. result = PASS;
  13477. }
  13478. else
  13479. {
  13480. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  13481. }
  13482. if(strlen((char*)ShmOCPP20Data->Reset.Response_status) > 0)
  13483. sendResetConfirmation(uuid);
  13484. return result;
  13485. }
  13486. int handleSendLocalListRequest(char *uuid, char *payload)
  13487. {
  13488. mtrace();
  13489. int result = FAIL;
  13490. char updateTypestr[15]={0};
  13491. int checkState_Faulted = FALSE;
  13492. json_object *SendLocalList;
  13493. DEBUG_INFO("handleSendLocalListRequest...\n");
  13494. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  13495. {
  13496. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  13497. goto end;
  13498. }
  13499. SendLocalList = json_tokener_parse(payload);
  13500. if(!is_error(SendLocalList))
  13501. {
  13502. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  13503. // Required data
  13504. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  13505. {
  13506. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  13507. }
  13508. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  13509. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  13510. // Optional data
  13511. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  13512. {
  13513. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  13514. {
  13515. // Required data
  13516. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  13517. {
  13518. 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")));
  13519. 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")));
  13520. }
  13521. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  13522. {
  13523. 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")));
  13524. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  13525. 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")));
  13526. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  13527. 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"));
  13528. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  13529. {
  13530. 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")));
  13531. 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")));
  13532. }
  13533. }
  13534. }
  13535. }
  13536. }
  13537. json_object_put(SendLocalList);
  13538. //check Charge Point state
  13539. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13540. {
  13541. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  13542. {
  13543. checkState_Faulted = TRUE; //OCPP Status: Faulted
  13544. }
  13545. }
  13546. for (int index = 0; index < CCS_QUANTITY; index++)
  13547. {
  13548. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  13549. {
  13550. checkState_Faulted = TRUE; //OCPP Status
  13551. }
  13552. }
  13553. for (int index = 0; index < GB_QUANTITY; index++)
  13554. {
  13555. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  13556. {
  13557. checkState_Faulted = TRUE; //OCPP Status: Faulted
  13558. }
  13559. }
  13560. for (int index = 0; index < AC_QUANTITY; index++)
  13561. {
  13562. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  13563. {
  13564. checkState_Faulted = TRUE; //OCPP Status: Faulted
  13565. }
  13566. }
  13567. if(checkState_Faulted == TRUE)
  13568. {
  13569. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  13570. goto end;
  13571. }
  13572. // Check update type
  13573. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  13574. {
  13575. //Local list full update
  13576. DEBUG_INFO("Local list full update.\n");
  13577. DB_getListVerion();
  13578. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  13579. {
  13580. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  13581. goto end;
  13582. }
  13583. DB_cleanLocalList();
  13584. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  13585. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  13586. }
  13587. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  13588. {
  13589. //Local list different update
  13590. DEBUG_INFO("Local list different update.\n");
  13591. DB_getListVerion();
  13592. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  13593. {
  13594. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  13595. goto end;
  13596. }
  13597. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  13598. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  13599. }
  13600. else
  13601. {
  13602. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  13603. goto end;
  13604. }
  13605. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  13606. end:
  13607. sendSendLocalListConfirmation(uuid);
  13608. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  13609. return result;
  13610. }
  13611. int handleSetChargingProfileRequest(char *uuid, char *payload)
  13612. {
  13613. mtrace();
  13614. int result = FAIL;
  13615. struct SetChargingProfile_20 SetProfileReq = {0};
  13616. uint8_t isLostConnectorId = FALSE;
  13617. uint8_t isPeriodOverMax = FALSE;
  13618. uint8_t isProfileOverMax = FALSE;
  13619. uint8_t isConnectorMismatch = FALSE;
  13620. uint8_t isTransactiodIdMismatch = FALSE;
  13621. uint8_t existProfileQuantity = 0;
  13622. uint8_t filename[128]={0};
  13623. uint8_t dataLine[4096]={0};
  13624. FILE *filePtr;
  13625. json_object *SetChargingProfile;
  13626. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  13627. SetChargingProfile = json_tokener_parse(payload);
  13628. if(!is_error(SetChargingProfile))
  13629. {
  13630. // Required data
  13631. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  13632. SetProfileReq.evseId = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  13633. else
  13634. isLostConnectorId = TRUE;
  13635. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id") != NULL)
  13636. SetProfileReq.chargingProfile.id = json_object_get_int((json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id")));
  13637. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  13638. {
  13639. sprintf((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")));
  13640. // Check periods is over max configuration
  13641. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
  13642. {
  13643. isPeriodOverMax = TRUE;
  13644. }
  13645. // Check periods is over max configuration
  13646. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  13647. {
  13648. if(SetProfileReq.evseId == 0)
  13649. {
  13650. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  13651. filePtr = fopen((char*)filename, "r");
  13652. if (!filePtr)
  13653. {
  13654. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  13655. filePtr = fopen((char*)filename, "w+");
  13656. }
  13657. else
  13658. {
  13659. //Check Charging Profile Count
  13660. while(fscanf(filePtr, "%s", dataLine) != EOF)
  13661. {
  13662. //DEBUG_INFO("word=%s\n",word);
  13663. if(strstr((char*)dataLine, "id")!= NULL)
  13664. {
  13665. existProfileQuantity += 1;
  13666. }
  13667. }
  13668. }
  13669. fclose(filePtr);
  13670. }
  13671. else
  13672. isConnectorMismatch = TRUE;
  13673. }
  13674. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  13675. {
  13676. if((0 < SetProfileReq.evseId) && (SetProfileReq.evseId > gunTotalNumber))
  13677. isConnectorMismatch = TRUE;
  13678. if(!isConnectorMismatch)
  13679. {
  13680. if(SetProfileReq.evseId == 0)
  13681. {
  13682. int tmpExistProfileQuantity;
  13683. for(int idxCon=1;idxCon<=gunTotalNumber;idxCon++)
  13684. {
  13685. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
  13686. filePtr = fopen((char*)filename, "r");
  13687. if (!filePtr)
  13688. {
  13689. DEBUG_INFO("%s not exist, create it.\n", filename);
  13690. filePtr = fopen((char*)filename, "w+");
  13691. }
  13692. else
  13693. {
  13694. //Check Charging Profile Count
  13695. while(fscanf(filePtr, "%s", dataLine) != EOF)
  13696. {
  13697. //DEBUG_INFO("word=%s\n",word);
  13698. if(strstr((char*)dataLine, "id")!= NULL)
  13699. {
  13700. tmpExistProfileQuantity += 1;
  13701. }
  13702. }
  13703. }
  13704. fclose(filePtr);
  13705. existProfileQuantity = (existProfileQuantity < tmpExistProfileQuantity) ? tmpExistProfileQuantity : existProfileQuantity;
  13706. }
  13707. }
  13708. else
  13709. {
  13710. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
  13711. filePtr = fopen((char*)filename, "r");
  13712. if (!filePtr)
  13713. {
  13714. DEBUG_INFO("%s not exist, create it.\n", filename);
  13715. filePtr = fopen((char*)filename, "w+");
  13716. }
  13717. else
  13718. {
  13719. //Check Charging Profile Count
  13720. while(fscanf(filePtr, "%s", dataLine) != EOF)
  13721. {
  13722. //DEBUG_INFO("word=%s\n",word);
  13723. if(strstr((char*)dataLine, "id")!= NULL)
  13724. {
  13725. existProfileQuantity += 1;
  13726. }
  13727. }
  13728. }
  13729. fclose(filePtr);
  13730. }
  13731. }
  13732. }
  13733. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  13734. {
  13735. if((SetProfileReq.evseId > 0) && (SetProfileReq.evseId <= gunTotalNumber))
  13736. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
  13737. else
  13738. isConnectorMismatch = TRUE;
  13739. if(!isConnectorMismatch)
  13740. {
  13741. filePtr = fopen((char*)filename, "r");
  13742. if (!filePtr)
  13743. {
  13744. DEBUG_INFO("%s not exist, create it.\n", filename);
  13745. filePtr = fopen((char*)filename, "w+");
  13746. }
  13747. else
  13748. {
  13749. //Check Charging Profile Count
  13750. while(fscanf(filePtr, "%s", dataLine) != EOF)
  13751. {
  13752. //DEBUG_INFO("word=%s\n",word);
  13753. if(strstr((char*)dataLine, "id")!= NULL)
  13754. {
  13755. existProfileQuantity += 1;
  13756. }
  13757. }
  13758. }
  13759. fclose(filePtr);
  13760. if(SetProfileReq.chargingProfile.transactionId != ShmOCPP20Data->TransactionEvent[SetProfileReq.evseId-1].transactionInfo.transactionId)
  13761. isTransactiodIdMismatch = TRUE;
  13762. }
  13763. }
  13764. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  13765. {
  13766. /*
  13767. * TODO:
  13768. *
  13769. */
  13770. }
  13771. else
  13772. {}
  13773. if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
  13774. isProfileOverMax = TRUE;
  13775. }
  13776. // Profile replace or add info
  13777. if(!isLostConnectorId && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTransactiodIdMismatch)
  13778. {
  13779. FILE *infile;
  13780. FILE *outfile;
  13781. char tmpProfileName[] = "/Storage/OCPP/SetChargingProfiletemp_OCPP20.json";
  13782. char rmFileCmd[128];
  13783. int tempchargingProfileIdInt;
  13784. int chkChar;
  13785. for(int idxCon=1; idxCon <= (SetProfileReq.evseId==0?gunTotalNumber:1); idxCon++)
  13786. {
  13787. if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) == 0)
  13788. {
  13789. sprintf((char*)filename, "%s", ChargePointMaxProfile_JSON);
  13790. }
  13791. else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0)
  13792. {
  13793. if(SetProfileReq.evseId==0)
  13794. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
  13795. else
  13796. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
  13797. }
  13798. else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) == 0)
  13799. {
  13800. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
  13801. }
  13802. else
  13803. {
  13804. /*
  13805. * TODO:
  13806. *
  13807. */
  13808. }
  13809. infile = fopen ((char*)filename, "r");
  13810. outfile = fopen ((char*)tmpProfileName, "w");
  13811. chkChar = fgetc(infile);
  13812. rewind(infile);
  13813. if(chkChar == EOF)
  13814. {
  13815. // Profile is empty
  13816. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  13817. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  13818. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  13819. fclose(infile);
  13820. fclose(outfile);
  13821. sprintf(rmFileCmd,"rm -f %s",filename);
  13822. system(rmFileCmd);
  13823. rename((char*)tmpProfileName, (char*)filename);
  13824. }
  13825. else
  13826. {
  13827. // Profile is not empty
  13828. int ChargingProfileAdded = FALSE;
  13829. while (fgets((char*)dataLine, ARRAY_SIZE(dataLine), infile) != NULL)
  13830. {
  13831. dataLine[strlen((char*)dataLine) - 1] = '\0'; // eat the newline fgets() stores
  13832. json_object *tmpChargingProfile;
  13833. tmpChargingProfile = json_tokener_parse((char*)dataLine);
  13834. if(!is_error(tmpChargingProfile))
  13835. {
  13836. if(json_object_object_get(tmpChargingProfile, "chargingProfile") != NULL)
  13837. {
  13838. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id") != NULL)
  13839. {
  13840. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id"));
  13841. DEBUG_INFO("tempchargingProfileIdInt: %d\n", tempchargingProfileIdInt);
  13842. DEBUG_INFO("SetProfileReq.chargingProfile.id: %d\n", SetProfileReq.chargingProfile.id);
  13843. }
  13844. }
  13845. }
  13846. json_object_put(tmpChargingProfile);
  13847. if((tempchargingProfileIdInt == SetProfileReq.chargingProfile.id))
  13848. {
  13849. if(ChargingProfileAdded == FALSE)
  13850. {
  13851. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  13852. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  13853. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  13854. ChargingProfileAdded = TRUE;
  13855. }
  13856. }
  13857. else
  13858. {
  13859. fprintf(outfile,"%s\n",dataLine);
  13860. if(ChargingProfileAdded == FALSE)
  13861. {
  13862. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  13863. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  13864. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  13865. ChargingProfileAdded = TRUE;
  13866. }
  13867. }
  13868. } // end of while loop
  13869. fclose(infile);
  13870. fclose(outfile);
  13871. sprintf(rmFileCmd,"rm -f %s",filename);
  13872. system(rmFileCmd);
  13873. rename((char*)tmpProfileName, (char*)filename);
  13874. }
  13875. }
  13876. sleep(1);
  13877. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  13878. result = PASS;
  13879. }
  13880. else
  13881. {
  13882. if(isLostConnectorId)
  13883. DEBUG_WARN("Connector id is wrong.\n");
  13884. if(isConnectorMismatch)
  13885. DEBUG_WARN("Connector id is mismatch.\n");
  13886. if(isPeriodOverMax)
  13887. DEBUG_WARN("Profile periods quantity is over spec.\n");
  13888. if(isProfileOverMax)
  13889. DEBUG_WARN("Profile quantity is over spec.\n");
  13890. if(isTransactiodIdMismatch)
  13891. DEBUG_WARN("Transaction id is mismatch.\n");
  13892. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  13893. }
  13894. }
  13895. json_object_put(SetChargingProfile);
  13896. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  13897. {
  13898. if(SetProfileReq.evseId == 0)
  13899. {
  13900. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  13901. {
  13902. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  13903. }
  13904. }
  13905. else
  13906. checkCompositeSchedule(SetProfileReq.evseId, 86400, &ShmOCPP20Data->SmartChargingProfile[SetProfileReq.evseId-1], 0, TRUE);
  13907. }
  13908. sendSetChargingProfileConfirmation(uuid, (SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1));
  13909. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  13910. return result;
  13911. }
  13912. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  13913. {
  13914. mtrace();
  13915. int result = FAIL;
  13916. json_object *SetDisplayMessage;
  13917. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  13918. SetDisplayMessage = json_tokener_parse(payload);
  13919. if(!is_error(SetDisplayMessage))
  13920. {
  13921. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  13922. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  13923. // Required data
  13924. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  13925. {
  13926. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  13927. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  13928. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  13929. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  13930. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  13931. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  13932. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  13933. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  13934. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  13935. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  13936. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  13937. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  13938. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  13939. {
  13940. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  13941. 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"), "message"), "format")));
  13942. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  13943. 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"), "message"), "language")));
  13944. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  13945. 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"), "message"), "content")));
  13946. }
  13947. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  13948. {
  13949. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  13950. 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")));
  13951. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  13952. 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")));
  13953. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  13954. {
  13955. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  13956. 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"));
  13957. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  13958. 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"));
  13959. }
  13960. }
  13961. }
  13962. }
  13963. json_object_put(SetDisplayMessage);
  13964. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  13965. sendSetDisplayMessagesConfirmation(uuid);
  13966. // Announce CSU there is display request come from server
  13967. ShmOCPP20Data->MsMsg.bits.SetDisplayMessageReq = ON;
  13968. return result;
  13969. }
  13970. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  13971. {
  13972. mtrace();
  13973. int result = FAIL;
  13974. json_object *SetMonitoringBase;
  13975. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  13976. SetMonitoringBase = json_tokener_parse(payload);
  13977. if(!is_error(SetMonitoringBase))
  13978. {
  13979. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  13980. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  13981. // Required data
  13982. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  13983. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  13984. }
  13985. json_object_put(SetMonitoringBase);
  13986. /*
  13987. * TODO:
  13988. * 1. Configure monitor base and response
  13989. */
  13990. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  13991. sendSetMonitoringBaseConfirmation(uuid);
  13992. return result;
  13993. }
  13994. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  13995. {
  13996. mtrace();
  13997. int result = FAIL;
  13998. json_object *SetMonitoringLevel;
  13999. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  14000. SetMonitoringLevel = json_tokener_parse(payload);
  14001. if(!is_error(SetMonitoringLevel))
  14002. {
  14003. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  14004. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  14005. // Required data
  14006. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  14007. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  14008. }
  14009. json_object_put(SetMonitoringLevel);
  14010. /*
  14011. * TODO:
  14012. * Configure monitor status and response
  14013. */
  14014. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  14015. sendSetMonitoringLevelConfirmation(uuid);
  14016. return result;
  14017. }
  14018. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  14019. {
  14020. mtrace();
  14021. int result = FAIL;
  14022. json_object *SetNetworkProfile;
  14023. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  14024. SetNetworkProfile = json_tokener_parse(payload);
  14025. if(!is_error(SetNetworkProfile))
  14026. {
  14027. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  14028. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  14029. // Required data
  14030. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  14031. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  14032. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  14033. {
  14034. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  14035. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  14036. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  14037. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  14038. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  14039. {
  14040. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  14041. memcpy((char*)ShmOCPP20Data->OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  14042. }
  14043. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  14044. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  14045. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  14046. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  14047. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  14048. {
  14049. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  14050. 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")));
  14051. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  14052. 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")));
  14053. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  14054. 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")));
  14055. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  14056. 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")));
  14057. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  14058. 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")));
  14059. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  14060. 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")));
  14061. }
  14062. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  14063. {
  14064. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  14065. {
  14066. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  14067. 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")));
  14068. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  14069. }
  14070. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  14071. {
  14072. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  14073. 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")));
  14074. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  14075. }
  14076. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  14077. {
  14078. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  14079. 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")));
  14080. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  14081. }
  14082. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  14083. 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"));
  14084. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  14085. 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")));
  14086. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  14087. 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"));
  14088. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  14089. 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")));
  14090. }
  14091. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  14092. }
  14093. }
  14094. json_object_put(SetNetworkProfile);
  14095. /*
  14096. * TODO:
  14097. * 1. Process network configuration and response
  14098. */
  14099. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  14100. {
  14101. }
  14102. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  14103. {
  14104. }
  14105. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  14106. {
  14107. }
  14108. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  14109. {
  14110. }
  14111. else
  14112. {
  14113. }
  14114. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  14115. {
  14116. }
  14117. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  14118. {
  14119. }
  14120. else
  14121. {
  14122. }
  14123. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  14124. {
  14125. }
  14126. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  14127. {
  14128. }
  14129. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  14130. {
  14131. }
  14132. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  14133. {
  14134. }
  14135. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  14136. {
  14137. }
  14138. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  14139. {
  14140. }
  14141. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  14142. {
  14143. }
  14144. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  14145. {
  14146. }
  14147. else
  14148. {
  14149. }
  14150. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  14151. {
  14152. }
  14153. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  14154. {
  14155. }
  14156. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  14157. {
  14158. }
  14159. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  14160. {
  14161. }
  14162. else
  14163. {
  14164. }
  14165. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  14166. {
  14167. }
  14168. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  14169. {
  14170. }
  14171. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  14172. {
  14173. }
  14174. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  14175. {
  14176. }
  14177. else
  14178. {
  14179. }
  14180. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  14181. sendSetNetworkProfileConfirmation(uuid);
  14182. return result;
  14183. }
  14184. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  14185. {
  14186. mtrace();
  14187. int result = FAIL;
  14188. json_object *SetVariableMonitoring;
  14189. uint8_t variableQuantity = 0;
  14190. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  14191. SetVariableMonitoring = json_tokener_parse(payload);
  14192. if(!is_error(SetVariableMonitoring))
  14193. {
  14194. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  14195. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  14196. // Required data
  14197. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  14198. {
  14199. variableQuantity++;
  14200. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  14201. {
  14202. 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"));
  14203. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  14204. }
  14205. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  14206. {
  14207. 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"));
  14208. }
  14209. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  14210. {
  14211. 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")));
  14212. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  14213. }
  14214. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  14215. {
  14216. 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"));
  14217. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  14218. }
  14219. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  14220. {
  14221. 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"));
  14222. }
  14223. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  14224. {
  14225. 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)
  14226. {
  14227. 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")));
  14228. }
  14229. 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)
  14230. {
  14231. 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")));
  14232. }
  14233. 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)
  14234. {
  14235. 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)
  14236. {
  14237. 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"));
  14238. }
  14239. 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)
  14240. {
  14241. 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"));
  14242. }
  14243. }
  14244. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  14245. }
  14246. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  14247. {
  14248. 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)
  14249. {
  14250. 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")));
  14251. }
  14252. 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)
  14253. {
  14254. 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")));
  14255. }
  14256. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  14257. }
  14258. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, SetMonitoringStatusEnumTypeStr[SetMonitoringStatusEnumType_Accepted]);
  14259. }
  14260. }
  14261. json_object_put(SetVariableMonitoring);
  14262. sendSetVariableMonitoringConfirmation(uuid, variableQuantity);
  14263. return result;
  14264. }
  14265. int handleSetVariablesRequest(char *uuid, char *payload)
  14266. {
  14267. mtrace();
  14268. int result = FAIL;
  14269. json_object *SetVariables;
  14270. DEBUG_INFO("handleSetVariablesRequest...\n");
  14271. SetVariables = json_tokener_parse(payload);
  14272. if(!is_error(SetVariables))
  14273. {
  14274. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  14275. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  14276. // Required data
  14277. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  14278. {
  14279. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  14280. {
  14281. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  14282. {
  14283. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  14284. {
  14285. 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")));
  14286. }
  14287. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  14288. {
  14289. 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")));
  14290. }
  14291. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  14292. {
  14293. 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)
  14294. {
  14295. 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"));
  14296. }
  14297. 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)
  14298. {
  14299. 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"));
  14300. }
  14301. }
  14302. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  14303. }
  14304. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  14305. {
  14306. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  14307. {
  14308. 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")));
  14309. }
  14310. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  14311. {
  14312. 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")));
  14313. }
  14314. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  14315. }
  14316. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  14317. {
  14318. 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")));
  14319. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  14320. }
  14321. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  14322. {
  14323. 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")));
  14324. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  14325. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  14326. {
  14327. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  14328. (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) &&
  14329. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  14330. (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))
  14331. {
  14332. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  14333. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  14334. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  14335. {
  14336. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  14337. }
  14338. else
  14339. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  14340. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "WebSocketPingInterval") != NULL))
  14341. {
  14342. ChageWebSocketPingInterval(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value));
  14343. }
  14344. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SecurityCtrlr") != NULL) &&
  14345. ((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "SecurityProfile") != NULL) || (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "BasicAuthPassword") != NULL)))
  14346. {
  14347. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  14348. SetOcppConnStatus(FALSE);
  14349. }
  14350. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "HeartbeatInterval") != NULL))
  14351. {
  14352. HeartBeatWaitTime = (atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value)<10) ? 10 : atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  14353. }
  14354. }
  14355. }
  14356. }
  14357. }
  14358. }
  14359. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  14360. }
  14361. json_object_put(SetVariables);
  14362. return result;
  14363. }
  14364. int handleTriggerMessageRequest(char *uuid, char *payload)
  14365. {
  14366. mtrace();
  14367. int result = FAIL;
  14368. int connectorIdIsNULL = FALSE;
  14369. int connectorIdInt =0;
  14370. json_object *TriggerMessage;
  14371. DEBUG_INFO("handleTriggerMessageRequest\n");
  14372. TriggerMessage = json_tokener_parse(payload);
  14373. if(!is_error(TriggerMessage))
  14374. {
  14375. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  14376. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  14377. // Required data
  14378. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  14379. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  14380. // Optional data
  14381. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  14382. {
  14383. // Required data
  14384. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  14385. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  14386. // Optional data
  14387. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  14388. {
  14389. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  14390. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  14391. }
  14392. else
  14393. connectorIdIsNULL = TRUE;
  14394. }
  14395. else
  14396. connectorIdIsNULL = TRUE;
  14397. }
  14398. json_object_put(TriggerMessage);
  14399. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  14400. {
  14401. if((strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  14402. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  14403. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  14404. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  14405. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  14406. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  14407. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  14408. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  14409. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  14410. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  14411. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  14412. {
  14413. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  14414. sendTriggerMessageConfirmation(uuid);
  14415. return TRUE;
  14416. }
  14417. else
  14418. {
  14419. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  14420. sendTriggerMessageConfirmation(uuid);
  14421. }
  14422. }
  14423. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  14424. {
  14425. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  14426. sendTriggerMessageConfirmation(uuid);
  14427. return TRUE;
  14428. }
  14429. //==========================
  14430. // Trigger message
  14431. //==========================
  14432. if( strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  14433. {
  14434. if((strlen((char*)ShmOCPP20Data->FirmwareStatusNotification.status) == 0) ||
  14435. ((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing)))
  14436. {
  14437. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  14438. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  14439. }
  14440. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14441. }
  14442. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  14443. {
  14444. if(strlen((char*)ShmOCPP20Data->LogStatusNotification.status) == 0)
  14445. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Idle]);
  14446. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  14447. }
  14448. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  14449. {
  14450. if(DB_updateBootType(BootReasonEnumType_Triggered))
  14451. server_sign = FALSE;
  14452. }
  14453. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  14454. {
  14455. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  14456. }
  14457. else if (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  14458. {
  14459. if(connectorIdIsNULL == FALSE)
  14460. {
  14461. if((connectorIdInt > 0) && ((connectorIdInt-1) < gunTotalNumber))
  14462. {
  14463. cpinitateMsg.bits[connectorIdInt-1].TriggerMeterValueReq = ON;
  14464. }
  14465. }
  14466. else
  14467. {
  14468. for(int idx=0;idx< gunTotalNumber;idx++)
  14469. {
  14470. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  14471. }
  14472. }
  14473. }
  14474. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  14475. {
  14476. if(connectorIdIsNULL == FALSE)
  14477. {
  14478. if((connectorIdInt > 0) && ((connectorIdInt-1) < gunTotalNumber))
  14479. {
  14480. cpinitateMsg.bits[connectorIdInt-1].TriggerStatusNotificationReq = ON;
  14481. //clientTime.StatusNotification[connectorIdInt-1] = time((time_t*)NULL);
  14482. }
  14483. }
  14484. else
  14485. {
  14486. for(int idx=0;idx< gunTotalNumber;idx++)
  14487. {
  14488. cpinitateMsg.bits[idx].TriggerStatusNotificationReq = ON;
  14489. //clientTime.StatusNotification[idx] = time((time_t*)NULL);
  14490. }
  14491. }
  14492. }
  14493. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0 )
  14494. {
  14495. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  14496. if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
  14497. {
  14498. system("openssl req -newkey rsa:2048 -out /Storage/OCPP/certCP.csr -nodes -keyout /Storage/OCPP/certCP.key -subj \"/C=TW/ST=Taiwan/L=Taoyuan/O=Phihong Technology/OU=IT/CN=phihong.com\" &");
  14499. }
  14500. }
  14501. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) == 0 )
  14502. {
  14503. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  14504. if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
  14505. {
  14506. system("openssl req -newkey rsa:2048 -out /Storage/OCPP/certV2G.csr -nodes -keyout /Storage/OCPP/certV2G.key -subj \"/C=TW/ST=Taiwan/L=Taoyuan/O=Phihong Technology/OU=IT/CN=phihong.com\" &");
  14507. }
  14508. }
  14509. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) == 0 )
  14510. {
  14511. if(connectorIdIsNULL == FALSE)
  14512. {
  14513. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  14514. {
  14515. ShmOCPP20Data->CpMsg.bits[connectorIdInt -1].TransactionEventReq = ON;
  14516. }
  14517. }
  14518. else
  14519. {
  14520. for(int idx=0;idx< gunTotalNumber;idx++)
  14521. ShmOCPP20Data->CpMsg.bits[idx].TransactionEventReq = ON;
  14522. }
  14523. }
  14524. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) == 0 )
  14525. {
  14526. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  14527. if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
  14528. {
  14529. system("openssl req -newkey rsa:2048 -out /Storage/OCPP/certCP.csr -nodes -keyout /Storage/OCPP/certCP.key -subj \"/C=TW/ST=Taiwan/L=Taoyuan/O=Phihong Technology/OU=IT/CN=phihong.com\" &");
  14530. }
  14531. if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
  14532. {
  14533. system("openssl req -newkey rsa:2048 -out /Storage/OCPP/certV2G.csr -nodes -keyout /Storage/OCPP/certV2G.key -subj \"/C=TW/ST=Taiwan/L=Taoyuan/O=Phihong Technology/OU=IT/CN=phihong.com\" &");
  14534. }
  14535. }
  14536. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) == 0 )
  14537. {
  14538. ShmOCPP20Data->MsMsg.bits.PublishFirmwareReq = ON;
  14539. }
  14540. return result;
  14541. }
  14542. int handleUnlockConnectorRequest(char *uuid, char *payload)
  14543. {
  14544. mtrace();
  14545. int result = FAIL;
  14546. int connectorIdInt =0;
  14547. int tempIndex = 0;
  14548. json_object *UnlockConnector;
  14549. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  14550. UnlockConnector = json_tokener_parse(payload);
  14551. if(!is_error(UnlockConnector))
  14552. {
  14553. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  14554. {
  14555. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  14556. }
  14557. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  14558. {
  14559. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  14560. }
  14561. }
  14562. json_object_put(UnlockConnector);
  14563. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  14564. if(gunTotalNumber == 0)
  14565. {
  14566. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  14567. goto end;
  14568. }
  14569. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  14570. {
  14571. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  14572. goto end;
  14573. }
  14574. else
  14575. {
  14576. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  14577. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  14578. //check Transaction active
  14579. if(gunType[connectorIdInt-1] == GUN_TYPE_CHAdeMO)
  14580. {
  14581. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14582. {
  14583. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14584. }
  14585. else
  14586. {
  14587. tempIndex = connectorIdInt -1;
  14588. }
  14589. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14590. {
  14591. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ))
  14592. {
  14593. //stop Transaction
  14594. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  14595. }
  14596. }
  14597. }
  14598. else if(gunType[connectorIdInt-1] == GUN_TYPE_CCS)
  14599. {
  14600. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14601. {
  14602. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14603. }
  14604. else
  14605. {
  14606. tempIndex = connectorIdInt -1;
  14607. }
  14608. for (int index = 0; index < CCS_QUANTITY; index++)
  14609. {
  14610. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ))
  14611. {
  14612. //stop Transaction
  14613. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  14614. }
  14615. }
  14616. }
  14617. else if(gunType[connectorIdInt-1] == GUN_TYPE_GBT)
  14618. {
  14619. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14620. {
  14621. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14622. }
  14623. else
  14624. {
  14625. tempIndex = connectorIdInt -1;
  14626. }
  14627. for (int index = 0; index < GB_QUANTITY; index++)
  14628. {
  14629. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ))
  14630. {
  14631. //stop Transaction
  14632. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  14633. }
  14634. }
  14635. }
  14636. else if(gunType[connectorIdInt-1] == GUN_TYPE_DO)
  14637. {
  14638. tempIndex = connectorIdInt -1;
  14639. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  14640. {
  14641. if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex ))
  14642. {
  14643. //stop Transaction
  14644. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  14645. }
  14646. }
  14647. }
  14648. else
  14649. {
  14650. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  14651. {
  14652. tempIndex = 2;
  14653. }
  14654. else
  14655. {
  14656. tempIndex = connectorIdInt-1;
  14657. }
  14658. for (int index = 0; index < AC_QUANTITY; index++)
  14659. {
  14660. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ))
  14661. {
  14662. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  14663. }
  14664. }
  14665. }
  14666. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  14667. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  14668. result = TRUE;
  14669. return result;
  14670. }
  14671. end:
  14672. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorConf = ON;
  14673. return result;
  14674. }
  14675. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  14676. {
  14677. mtrace();
  14678. int result = FAIL;
  14679. json_object *UnpublishFirmware;
  14680. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  14681. UnpublishFirmware = json_tokener_parse(payload);
  14682. if(!is_error(UnpublishFirmware))
  14683. {
  14684. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  14685. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  14686. // Required data
  14687. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  14688. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  14689. }
  14690. json_object_put(UnpublishFirmware);
  14691. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  14692. /*
  14693. * TODO:
  14694. * 1. Check unpublished status
  14695. */
  14696. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  14697. sendUnpublishFirmwareConfirmation(uuid);
  14698. return result;
  14699. }
  14700. static char UpdateFirmwarepayloadData[512]={0};
  14701. void *UpdateFirmwareProcess(void *data)
  14702. {
  14703. pthread_detach(pthread_self());
  14704. mtrace();
  14705. char protocol[10], user[64],password[64],host[128], path[512], ftppath[512],host1[128],path1[512];
  14706. int port=0;
  14707. int isSuccess = 0;
  14708. char ftpbuf[1024];
  14709. char temp[1024];
  14710. char * pch;
  14711. DEBUG_INFO("handleUpdateFirmwareRequest...\n");
  14712. json_object *UpdateFirmware;
  14713. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  14714. if(!is_error(UpdateFirmware))
  14715. {
  14716. // Required data
  14717. if(json_object_object_get(UpdateFirmware, "requestId"))
  14718. {
  14719. ShmOCPP20Data->UpdateFirmware.requestId = json_object_get_int(json_object_object_get(UpdateFirmware, "requestId"));
  14720. }
  14721. if(json_object_object_get(UpdateFirmware, "firmware"))
  14722. {
  14723. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location") != NULL)
  14724. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location")));
  14725. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate") != NULL)
  14726. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate")));
  14727. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime") != NULL)
  14728. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime")));
  14729. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate") != NULL)
  14730. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate")));
  14731. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature") != NULL)
  14732. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature")));
  14733. }
  14734. // Optional data
  14735. if(json_object_object_get(UpdateFirmware, "retries"))
  14736. {
  14737. ShmOCPP20Data->UpdateFirmware.retries = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  14738. }
  14739. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  14740. {
  14741. ShmOCPP20Data->UpdateFirmware.retryInterval = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  14742. }
  14743. }
  14744. json_object_put(UpdateFirmware);
  14745. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  14746. memset(path, 0, ARRAY_SIZE(path));
  14747. // Wait retrieveData
  14748. if(strlen((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime) > 10)
  14749. {
  14750. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14751. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled]);
  14752. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14753. do
  14754. {
  14755. sleep(1);
  14756. }while(!isOvertNow(ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime));
  14757. }
  14758. system("rm -f /mnt/*");
  14759. if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"http", 4) == 0)
  14760. {
  14761. sscanf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  14762. sprintf(ftppath,"/%s", path);
  14763. DEBUG_INFO("locationstr: %s\n", ShmOCPP20Data->UpdateFirmware.firmware.location);
  14764. DEBUG_INFO("protocol: %s\n",protocol);
  14765. DEBUG_INFO("host: %s\n",host);
  14766. DEBUG_INFO("path: %s\n",path);
  14767. DEBUG_INFO("ftppath: %s\n",ftppath);
  14768. int ftppathlen=strlen(ftppath);
  14769. int i=1;
  14770. char filenametemp[50];
  14771. while(i < ftppathlen)
  14772. {
  14773. int len=ftppathlen-i;
  14774. if(ftppath[len]== 47) // '/' ascll code: 47
  14775. {
  14776. DEBUG_INFO("compare '/' all right\n");
  14777. break;
  14778. }
  14779. i=i+1;
  14780. }
  14781. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  14782. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  14783. filenametemp[i+1] = 0;
  14784. do
  14785. {
  14786. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14787. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  14788. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14789. sleep(3);
  14790. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  14791. if(!isSuccess)
  14792. {
  14793. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14794. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  14795. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14796. if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
  14797. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14798. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  14799. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14800. }
  14801. else
  14802. {
  14803. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14804. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  14805. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14806. }
  14807. ShmOCPP20Data->UpdateFirmware.retries--;
  14808. }while((isSuccess == 0)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
  14809. }
  14810. else if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"ftp", 3) == 0)
  14811. {
  14812. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  14813. memset(temp, 0, ARRAY_SIZE(temp));
  14814. strcpy(ftpbuf, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  14815. int ftppathlen=strlen(ftpbuf);
  14816. int i=1;
  14817. char filenametemp[50];
  14818. while(i < ftppathlen)
  14819. {
  14820. int len=ftppathlen-i;
  14821. if(ftpbuf[len]== 47) // '/' ascll code: 47
  14822. {
  14823. DEBUG_INFO(" compare '/' all right\n");
  14824. break;
  14825. }
  14826. i=i+1;
  14827. }
  14828. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  14829. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  14830. filenametemp[i+1] = 0;
  14831. strncpy(temp, ftpbuf, ftppathlen-i+1);
  14832. pch=strchr(temp,'@');
  14833. if(pch==NULL)
  14834. {
  14835. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  14836. protocol, host, &port, path);
  14837. strcpy(user,"anonymous");
  14838. strcpy(password,"");
  14839. }
  14840. else
  14841. {
  14842. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  14843. protocol, user, password, host, &port, path);
  14844. }
  14845. sscanf(host,"%[^/]%s",host1, path1);
  14846. sprintf(ftppath,"%s", path1);
  14847. if(port == 0)
  14848. {
  14849. port = 21;
  14850. }
  14851. do
  14852. {
  14853. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14854. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  14855. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14856. sleep(3);
  14857. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  14858. if(!isSuccess)
  14859. {
  14860. //BulldogUtil.sleepMs(interval*1000);
  14861. DEBUG_INFO("Update firmware request and download file fail.\n");
  14862. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14863. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  14864. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14865. if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
  14866. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14867. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  14868. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14869. }
  14870. else
  14871. {
  14872. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14873. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  14874. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14875. }
  14876. ShmOCPP20Data->UpdateFirmware.retries--;
  14877. }while((!isSuccess)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
  14878. }
  14879. else
  14880. {
  14881. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14882. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  14883. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14884. sleep(1);
  14885. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  14886. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  14887. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14888. }
  14889. if(strstr((char*)ShmOCPP20Data->FirmwareStatusNotification.status, FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]) != NULL)ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  14890. interLock.isUpdateFirmwareGoing = OFF;
  14891. pthread_exit(NULL);
  14892. }
  14893. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  14894. {
  14895. mtrace();
  14896. int result = FAIL;
  14897. pthread_t t;
  14898. sendUpdateFirmwareConfirmation(uuid);
  14899. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  14900. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  14901. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  14902. if(!interLock.isUpdateFirmwareGoing)
  14903. {
  14904. interLock.isUpdateFirmwareGoing = ON;
  14905. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  14906. sleep(1);
  14907. }
  14908. else
  14909. DEBUG_WARN("Other UpdateFirmware request on going.\n");
  14910. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  14911. return result;
  14912. }
  14913. int handleUnknownRequest(char *uuid, char *payload)
  14914. {
  14915. mtrace();
  14916. int result = FAIL;
  14917. DEBUG_INFO("handleUnknownRequest...\n");
  14918. sendUnknownConfirmation(uuid);
  14919. result = PASS;
  14920. return result;
  14921. }
  14922. //==========================================
  14923. // Handle server response routine
  14924. //==========================================
  14925. void handleAuthorizeResponse(char *payload, int gun_index)
  14926. {
  14927. mtrace();
  14928. DEBUG_INFO("handleAuthorizeResponse...\n");
  14929. json_object *Authorize;
  14930. Authorize = json_tokener_parse(payload);
  14931. if(!is_error(Authorize))
  14932. {
  14933. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  14934. {
  14935. // Required data
  14936. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  14937. // Optional data
  14938. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  14939. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  14940. else
  14941. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  14942. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  14943. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  14944. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  14945. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  14946. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  14947. {
  14948. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  14949. {
  14950. 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));
  14951. }
  14952. }
  14953. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  14954. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  14955. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  14956. {
  14957. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  14958. 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")));
  14959. else
  14960. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  14961. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  14962. 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")));
  14963. }
  14964. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  14965. {
  14966. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  14967. 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")));
  14968. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  14969. 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")));
  14970. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  14971. 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")));
  14972. }
  14973. }
  14974. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  14975. {
  14976. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  14977. }
  14978. }
  14979. json_object_put(Authorize);
  14980. //Update idTag information to authorization cache if supported
  14981. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  14982. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  14983. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  14984. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  14985. {
  14986. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  14987. }
  14988. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  14989. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  14990. authorizeRetryTimes = 0;
  14991. }
  14992. void handleBootNotificationResponse(char *payload, int gun_index)
  14993. {
  14994. mtrace();
  14995. char statusStr[12]={0};
  14996. char currentTimeStr[30]={0};
  14997. int intervalInt = 0;
  14998. DEBUG_INFO("handleBootNotificationResponse...\n");
  14999. json_object *BootNotification;
  15000. BootNotification = json_tokener_parse(payload);
  15001. if(!is_error(BootNotification))
  15002. {
  15003. // Required data
  15004. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  15005. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  15006. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  15007. }
  15008. json_object_put(BootNotification);
  15009. DEBUG_INFO("statusStr: %s\n", statusStr);
  15010. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  15011. BootNotificationInterval = intervalInt;
  15012. HeartBeatWaitTime = intervalInt;
  15013. //write back to ShmOCPP20Data->BootNotification
  15014. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  15015. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  15016. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  15017. {
  15018. server_sign = TRUE;
  15019. server_pending =FALSE;
  15020. DB_updateBootType(BootReasonEnumType_PowerUp);
  15021. }
  15022. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  15023. {
  15024. server_pending = TRUE;
  15025. }
  15026. syncDateTimeRTC(ShmOCPP20Data->BootNotification.Response_currentTime);
  15027. srand(time(NULL));
  15028. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  15029. SetOcppConnStatus(TRUE);
  15030. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  15031. }
  15032. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  15033. {
  15034. mtrace();
  15035. json_object *ClearedChargingLimit;
  15036. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  15037. ClearedChargingLimit = json_tokener_parse(payload);
  15038. if(!is_error(ClearedChargingLimit))
  15039. {
  15040. // Required data
  15041. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  15042. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  15043. }
  15044. json_object_put(ClearedChargingLimit);
  15045. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  15046. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitConf = ON;
  15047. }
  15048. void handleDataTransferResponse(char *payload, int gun_index)
  15049. {
  15050. mtrace();
  15051. json_object *DataTrans;
  15052. DEBUG_INFO("handleDataTransferResponse...\n");
  15053. DataTrans = json_tokener_parse(payload);
  15054. if(!is_error(DataTrans))
  15055. {
  15056. // Required data
  15057. if(json_object_object_get(DataTrans,"status") != NULL)
  15058. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  15059. // Optional data
  15060. if(json_object_object_get(DataTrans,"data") != NULL)
  15061. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  15062. }
  15063. json_object_put(DataTrans);
  15064. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  15065. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  15066. }
  15067. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  15068. {
  15069. mtrace();
  15070. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  15071. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  15072. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  15073. }
  15074. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  15075. {
  15076. mtrace();
  15077. json_object *Get15118EVCertificate;
  15078. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  15079. Get15118EVCertificate = json_tokener_parse(payload);
  15080. if(!is_error(Get15118EVCertificate))
  15081. {
  15082. // Required data
  15083. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  15084. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  15085. // Optional data
  15086. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  15087. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  15088. }
  15089. json_object_put(Get15118EVCertificate);
  15090. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  15091. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  15092. }
  15093. void handleGetCertificateStatusResponse(char *payload, int gun_index)
  15094. {
  15095. mtrace();
  15096. json_object *GetCertificateStatus;
  15097. DEBUG_INFO("handleGetCertificateStatusResponse...\n");
  15098. GetCertificateStatus = json_tokener_parse(payload);
  15099. if(!is_error(GetCertificateStatus))
  15100. {
  15101. // Required data
  15102. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  15103. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  15104. // Optional data
  15105. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  15106. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  15107. if(json_object_object_get(GetCertificateStatus,"statusInfo") != NULL)
  15108. {
  15109. if(json_object_object_get(json_object_object_get(GetCertificateStatus,"statusInfo"), "reasonCode") != NULL)
  15110. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(GetCertificateStatus,"ocspResult"), "reasonCode")));
  15111. if(json_object_object_get(json_object_object_get(GetCertificateStatus,"statusInfo"), "additionalInfo") != NULL)
  15112. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(GetCertificateStatus,"ocspResult"), "additionalInfo")));
  15113. }
  15114. }
  15115. json_object_put(GetCertificateStatus);
  15116. if(strstr((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, GetCertificateStatusEnumTypeStr[GetCertificateStatusEnumType_Accepted]) != NULL)
  15117. {
  15118. /*
  15119. * TODO:
  15120. * 1. If get certificate response accepted process something here
  15121. */
  15122. }
  15123. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  15124. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  15125. }
  15126. void handleHeartbeatResponse(char *payload, int gun_index)
  15127. {
  15128. mtrace();
  15129. DEBUG_INFO("handleHeartbeatResponse...\n");
  15130. json_object *Heartbeat;
  15131. Heartbeat = json_tokener_parse(payload);
  15132. if(!is_error(Heartbeat))
  15133. {
  15134. // Required data
  15135. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  15136. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  15137. }
  15138. json_object_put(Heartbeat);
  15139. if(FirstHeartBeat == OFF)
  15140. {
  15141. FirstHeartBeat = ON;
  15142. DEBUG_INFO("FirstHeartBeat \n");
  15143. }
  15144. HeartBeatWithNOResponse = 0;
  15145. clientTime.Heartbeat=time((time_t*)NULL);
  15146. syncDateTimeRTC(ShmOCPP20Data->Heartbeat.Response_currentTime);
  15147. }
  15148. void handleLogStatusNotificationResponse(char *payload, int gun_index)
  15149. {
  15150. mtrace();
  15151. DEBUG_INFO("handleLogStatusNotificationResponse...\n");
  15152. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  15153. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  15154. }
  15155. void handleMeterValuesResponse(char *payload, int gun_index)
  15156. {
  15157. mtrace();
  15158. DEBUG_INFO("handleMeterValuesResponse...\n");
  15159. }
  15160. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  15161. {
  15162. mtrace();
  15163. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  15164. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  15165. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  15166. }
  15167. void handleNotifyCustomerInformationResponse(char *payload, int gun_index)
  15168. {
  15169. mtrace();
  15170. DEBUG_INFO("handleNotifyCustomerInformationResponse...\n");
  15171. }
  15172. void handleNotifyDisplayMessagesResponse(char *payload, int gun_index)
  15173. {
  15174. mtrace();
  15175. DEBUG_INFO("handleNotifyDisplayMessagesResponse...\n");
  15176. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  15177. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  15178. }
  15179. void handleNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  15180. {
  15181. mtrace();
  15182. json_object *NotifyEVChargingNeeds;
  15183. DEBUG_INFO("handleNotifyEVChargingNeedsResponse...\n");
  15184. NotifyEVChargingNeeds = json_tokener_parse(payload);
  15185. if(!is_error(NotifyEVChargingNeeds))
  15186. {
  15187. // Required data
  15188. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  15189. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  15190. }
  15191. json_object_put(NotifyEVChargingNeeds);
  15192. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  15193. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  15194. }
  15195. void handleNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  15196. {
  15197. mtrace();
  15198. json_object *NotifyEVChargingSchedule;
  15199. DEBUG_INFO("handleNotifyEVChargingScheduleResponse...\n");
  15200. NotifyEVChargingSchedule = json_tokener_parse(payload);
  15201. if(!is_error(NotifyEVChargingSchedule))
  15202. {
  15203. // Required data
  15204. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  15205. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  15206. }
  15207. json_object_put(NotifyEVChargingSchedule);
  15208. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  15209. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  15210. }
  15211. void handleNotifyEventResponse(char *payload, int gun_index)
  15212. {
  15213. mtrace();
  15214. DEBUG_INFO("handleNotifyEventResponse...\n");
  15215. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  15216. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  15217. }
  15218. void handleNotifyMonitoringReportResponse(char *payload, int gun_index)
  15219. {
  15220. mtrace();
  15221. DEBUG_INFO("handleNotifyMonitoringReportResponse...\n");
  15222. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  15223. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  15224. }
  15225. void handleNotifyReportResponse(char *payload, int gun_index)
  15226. {
  15227. mtrace();
  15228. DEBUG_INFO("handleNotifyReportResponse...\n");
  15229. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  15230. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  15231. }
  15232. void handlePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  15233. {
  15234. mtrace();
  15235. DEBUG_INFO("handlePublishFirmwareStatusNotificationResponse...\n");
  15236. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  15237. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  15238. }
  15239. void handleReportChargingProfilesResponse(char *payload, int gun_index)
  15240. {
  15241. mtrace();
  15242. DEBUG_INFO("handleReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  15243. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  15244. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  15245. }
  15246. void handleReservationStatusUpdateResponse(char *payload, int gun_index)
  15247. {
  15248. mtrace();
  15249. DEBUG_INFO("handleReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  15250. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  15251. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  15252. }
  15253. void handleSecurityEventNotificationResponse(char *payload, int gun_index)
  15254. {
  15255. mtrace();
  15256. DEBUG_INFO("handleSecurityEventNotificationResponse...\n");
  15257. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  15258. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  15259. }
  15260. void handleSignCertificateResponse(char *payload, int gun_index)
  15261. {
  15262. mtrace();
  15263. json_object *SignCertificate;
  15264. DEBUG_INFO("handleSignCertificateResponse...\n");
  15265. SignCertificate = json_tokener_parse(payload);
  15266. if(!is_error(SignCertificate))
  15267. {
  15268. // Required data
  15269. if(json_object_object_get(SignCertificate,"status") != NULL)
  15270. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  15271. // Optional data
  15272. if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode") != NULL)
  15273. {
  15274. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode")));
  15275. if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo") != NULL)
  15276. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo")));
  15277. }
  15278. }
  15279. json_object_put(SignCertificate);
  15280. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  15281. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  15282. }
  15283. void handleStatusNotificationResponse(char *payload, int gun_index)
  15284. {
  15285. mtrace();
  15286. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  15287. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  15288. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  15289. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  15290. }
  15291. void handleTransactionEvenResponse(char *payload, int gun_index)
  15292. {
  15293. mtrace();
  15294. json_object *TransactionEven;
  15295. DEBUG_INFO("handleTransactionEvenResponse...\n");
  15296. TransactionEven = json_tokener_parse(payload);
  15297. if(!is_error(TransactionEven))
  15298. {
  15299. // Required data
  15300. // Optional data
  15301. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  15302. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  15303. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  15304. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  15305. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  15306. {
  15307. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  15308. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  15309. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  15310. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  15311. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  15312. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  15313. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  15314. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  15315. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  15316. {
  15317. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  15318. 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")));
  15319. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  15320. 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")));
  15321. }
  15322. }
  15323. if(json_object_object_get(TransactionEven,"updatedPersonalMessage") != NULL)
  15324. {
  15325. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "format") != NULL)
  15326. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.format, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "format")));
  15327. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "language") != NULL)
  15328. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.language, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "language")));
  15329. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "content") != NULL)
  15330. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.content, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "content")));
  15331. }
  15332. }
  15333. json_object_put(TransactionEven);
  15334. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  15335. }
  15336. //==========================================
  15337. // Handle Error routine
  15338. //==========================================
  15339. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  15340. {
  15341. mtrace();
  15342. #ifdef SystemLogMessage
  15343. DEBUG_INFO("errorCode: %s\n", errorCode);
  15344. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  15345. DEBUG_INFO("errorDetails: %s\n", payload);
  15346. #endif
  15347. }
  15348. //===============================================
  15349. // Common routine
  15350. //===============================================
  15351. int initialConfigurationTable(void)
  15352. {
  15353. DEBUG_INFO("initialConfigurationTable...\n");
  15354. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  15355. DB_variableIsCreate();
  15356. DB_variableLoadFromDb();
  15357. if(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].value) != variableVersion)
  15358. {
  15359. DEBUG_WARN("EVSE variable version in local db older than firmware.\n");
  15360. DB_variableClear();
  15361. DB_variableIsCreate();
  15362. DB_variableLoadFromDb();
  15363. }
  15364. DB_getNetworkProfileFromDb();
  15365. return 0;
  15366. }
  15367. int TransactionMessageAttemptsGet(void)
  15368. {
  15369. return TransactionMessageAttemptsValue;
  15370. }
  15371. int FirstHeartBeatResponse(void)
  15372. {
  15373. return FirstHeartBeat;
  15374. }
  15375. int TransactionMessageRetryIntervalGet(void)
  15376. {
  15377. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  15378. }
  15379. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  15380. {
  15381. int result = TRUE;
  15382. char rmFileCmd[100]={0};
  15383. char FilePath[100]={0};
  15384. char ftpbuf[200];
  15385. int systemresult;
  15386. sprintf(FilePath,"/mnt/%s",filename);
  15387. system("ping 8.8.8.8 &");
  15388. if((access(FilePath,F_OK))!=-1)
  15389. {
  15390. DEBUG_INFO("filename=%s exist.\n",FilePath);
  15391. sprintf(rmFileCmd,"rm -f %s",FilePath);
  15392. system(rmFileCmd);
  15393. }
  15394. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  15395. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
  15396. DEBUG_INFO("Download command: %s\n",ftpbuf);
  15397. systemresult = system(ftpbuf);
  15398. if(systemresult != 0)
  15399. {
  15400. DEBUG_INFO("http DownLoad error!\n");
  15401. result = FALSE;
  15402. }
  15403. system("pkill ping");
  15404. return result;
  15405. }
  15406. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  15407. {
  15408. int result = TRUE;
  15409. char rmFileCmd[100]={0};
  15410. char FilePath[100]={0};
  15411. char ftpbuf[200];
  15412. int systemresult;
  15413. sprintf(FilePath,"/mnt/%s",filename);
  15414. system("ping 8.8.8.8 &");
  15415. if((access(FilePath,F_OK))!=-1)
  15416. {
  15417. DEBUG_INFO("filename=%s exist.\n",FilePath);
  15418. sprintf(rmFileCmd,"rm -f %s",FilePath);
  15419. system(rmFileCmd);
  15420. }
  15421. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  15422. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  15423. DEBUG_INFO("Download command: %s\n",ftpbuf);
  15424. systemresult = system(ftpbuf);
  15425. if(systemresult != 0)
  15426. {
  15427. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
  15428. DEBUG_INFO("Download command: %s\n",ftpbuf);
  15429. systemresult = system(ftpbuf);
  15430. if(systemresult != 0)
  15431. {
  15432. DEBUG_WARN("wget error!\n");
  15433. result = FALSE;
  15434. }
  15435. }
  15436. system("pkill ping");
  15437. return result;
  15438. }
  15439. int httpUploadFile(char *location, char *path, char *filename,char *url)
  15440. {
  15441. char rmFileCmd[100]={0};
  15442. char FilePath[100]={0};
  15443. char buf[512];
  15444. int systemresult = 0;
  15445. //DEBUG_INFO("filename=%s\n",filename);
  15446. //DEBUG_INFO("url=%s\n",url);
  15447. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  15448. if((access(FilePath,F_OK))!=-1)
  15449. {
  15450. DEBUG_INFO("filename=%s exist.\n",FilePath);
  15451. sprintf(rmFileCmd,"rm -f %s",FilePath);
  15452. system(rmFileCmd);
  15453. }
  15454. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  15455. if(fp == NULL)
  15456. {
  15457. DEBUG_INFO("log is NULL\n");
  15458. return FALSE;
  15459. }
  15460. else
  15461. {
  15462. fprintf(fp, "%s\n", url);
  15463. fprintf(fp, "%s\n", filename);
  15464. fclose(fp);
  15465. }
  15466. FILE *phpFP = popen("/bin/php-cgi /var/www/ocpp_upload.php", "r");
  15467. if(phpFP == NULL)
  15468. {
  15469. DEBUG_INFO("PHP upload fail.\n");
  15470. return FALSE;
  15471. }
  15472. else
  15473. {
  15474. while(fgets(buf, sizeof(buf), phpFP) != NULL)
  15475. {
  15476. if(strstr(buf, "result") != NULL)
  15477. {
  15478. sscanf(buf, "result: %d", &systemresult);
  15479. DEBUG_INFO("PHP HTTP upload result: %d\n", systemresult);
  15480. }
  15481. }
  15482. pclose(phpFP);
  15483. }
  15484. if(systemresult != 1)
  15485. {
  15486. DEBUG_INFO("HTTP upload error!\n");
  15487. return FALSE;
  15488. }
  15489. return TRUE;
  15490. }
  15491. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  15492. {
  15493. struct hostent* server;
  15494. char *IPbuffer;
  15495. char ftpbuf[200];
  15496. int systemresult;
  15497. // To retrieve host information
  15498. server = gethostbyname(location);
  15499. // To convert an Internet network
  15500. // address into ASCII string
  15501. IPbuffer = inet_ntoa(*((struct in_addr*)
  15502. server->h_addr_list[0]));
  15503. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  15504. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  15505. /* format : ftpput -u username -p passwd IP target source*/
  15506. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  15507. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  15508. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  15509. systemresult = system(ftpbuf);
  15510. DEBUG_INFO("systemresult=%d\n",systemresult);
  15511. if(systemresult != 0)
  15512. {
  15513. DEBUG_INFO("ftpput error!\n");
  15514. return FALSE;
  15515. }
  15516. return TRUE;
  15517. }
  15518. //=========================================
  15519. // Routine
  15520. //=========================================
  15521. int GetOcppServerURL()
  15522. {
  15523. int result = FALSE;
  15524. struct yuarel url;
  15525. char urlStr[512];
  15526. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  15527. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  15528. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  15529. if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  15530. {
  15531. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  15532. if(yuarel_parse(&url, urlStr) != -1)
  15533. {
  15534. sprintf(OcppProtocol, "%s", url.scheme);
  15535. sprintf(OcppHost, "%s", url.host);
  15536. if(url.path == NULL)
  15537. OcppTempPath[0] = '\0';
  15538. else
  15539. sprintf(OcppTempPath, "%s", url.path);
  15540. if(url.port == 0)
  15541. {
  15542. if(strcmp(OcppProtocol, "wss") == 0)
  15543. OcppPort = 443;
  15544. else
  15545. OcppPort = 80;
  15546. }
  15547. else
  15548. OcppPort = url.port;
  15549. result = TRUE;
  15550. }
  15551. }
  15552. else
  15553. {
  15554. strcpy(OcppHost,"");
  15555. }
  15556. return result;
  15557. }
  15558. int GetOcppPath()
  15559. {
  15560. int result = FALSE;
  15561. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  15562. {
  15563. if(OcppTempPath == NULL)
  15564. {
  15565. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  15566. }
  15567. else
  15568. {
  15569. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  15570. }
  15571. result = TRUE;
  15572. }
  15573. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  15574. {
  15575. if(OcppTempPath == NULL)
  15576. {
  15577. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  15578. }
  15579. else
  15580. {
  15581. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  15582. }
  15583. result = TRUE;
  15584. }
  15585. else
  15586. {
  15587. strcpy(OcppPath,"");
  15588. }
  15589. return result;
  15590. }
  15591. int GetOcppPort()
  15592. {
  15593. return OcppPort;
  15594. }
  15595. int GetOcppConnStatus(void)
  15596. {
  15597. return ShmOCPP20Data->OcppConnStatus;
  15598. }
  15599. void SetOcppConnStatus(uint8_t status)
  15600. {
  15601. ShmOCPP20Data->OcppConnStatus = status;
  15602. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  15603. }
  15604. int GetHeartBeatWithNOResponse(void)
  15605. {
  15606. return HeartBeatWithNOResponse;
  15607. }
  15608. void SetHeartBeatWithNOResponse(void)
  15609. {
  15610. HeartBeatWithNOResponse = 0;
  15611. }
  15612. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  15613. void storeTempStopTransaction(int gun_index)
  15614. {
  15615. char TempStopTransaction[256];
  15616. char message[1024*20]={0};
  15617. char guid[37]={0};
  15618. json_object *TransactionEvent = json_object_new_object();
  15619. json_object *transactionInfo = json_object_new_object();
  15620. json_object *idToken = json_object_new_object();
  15621. json_object *evse = json_object_new_object();
  15622. json_object *meterValues = json_object_new_array();
  15623. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  15624. DEBUG_INFO("storeTempStopTransaction...\n");
  15625. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  15626. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  15627. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  15628. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  15629. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  15630. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  15631. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  15632. // Message
  15633. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  15634. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  15635. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  15636. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo+1));
  15637. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  15638. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  15639. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  15640. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  15641. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  15642. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  15643. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  15644. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  15645. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  15646. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  15647. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  15648. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  15649. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  15650. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  15651. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  15652. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  15653. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  15654. {
  15655. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  15656. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  15657. json_object_object_add(TransactionEvent, "idToken", idToken);
  15658. }
  15659. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  15660. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  15661. json_object_object_add(TransactionEvent, "evse", evse);
  15662. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  15663. {
  15664. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  15665. {
  15666. json_object *meterValue = json_object_new_object();
  15667. json_object *sampledValues = json_object_new_array();
  15668. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  15669. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  15670. {
  15671. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  15672. ((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) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) == 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) == 0)))
  15673. {
  15674. if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, (char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) != NULL)
  15675. {
  15676. json_object *sampledValue = json_object_new_object();
  15677. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  15678. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  15679. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  15680. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  15681. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  15682. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  15683. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  15684. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  15685. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  15686. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  15687. {
  15688. json_object *unitOfMeasure = json_object_new_object();
  15689. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  15690. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  15691. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  15692. }
  15693. json_object_array_add(sampledValues, sampledValue);
  15694. }
  15695. }
  15696. }
  15697. json_object_object_add(meterValue, "sampledValue", sampledValues);
  15698. json_object_array_add(meterValues, meterValue);
  15699. }
  15700. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  15701. }
  15702. random_uuid(guid);
  15703. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL
  15704. , guid
  15705. , "TransactionEvent"
  15706. , json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  15707. json_object_put(TransactionEvent);
  15708. // open file for writing
  15709. FILE *outfile;
  15710. outfile = fopen (TempStopTransaction, "w+");
  15711. //DEBUG_INFO("data = %s\n", queuedata);
  15712. fputs(message, outfile);
  15713. fputs("\n", outfile);
  15714. fclose (outfile);
  15715. }
  15716. void checkTempStopTransaction(int gun_index)
  15717. {
  15718. FILE *fptr1;
  15719. char ch;
  15720. char str[QUEUE_MESSAGE_LENGTH]={0};
  15721. char guid[37]={0};
  15722. char tempdata[65]={0};
  15723. char TempStopTransaction[256];
  15724. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  15725. fptr1 = fopen(TempStopTransaction, "r");
  15726. if (!fptr1)
  15727. {
  15728. //DEBUG_INFO("TempStopTransaction20_%d not found or unable to open the input file!\n", (gun_index+1));
  15729. return ;
  15730. }
  15731. ch=fgetc(fptr1);
  15732. rewind(fptr1);
  15733. if(ch!=EOF)
  15734. {
  15735. // copy all contents to the temporary file except the specific line
  15736. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  15737. {
  15738. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  15739. if(str[0]=='\0')
  15740. {
  15741. break;
  15742. }
  15743. strncpy(guid, str+4, 36); //copy guid
  15744. sprintf(tempdata, "TransactionEvent,%d", (gun_index));
  15745. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  15746. {
  15747. //DEBUG_INFO("StopTransaction mapitem pass\n");
  15748. }
  15749. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  15750. memset(str,0,ARRAY_SIZE(str));
  15751. }
  15752. }
  15753. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  15754. fclose(fptr1);
  15755. remove(TempStopTransaction); // remove the original file
  15756. }
  15757. int GetWebSocketPingInterval(void)
  15758. {
  15759. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  15760. }
  15761. int GetServerSign(void)
  15762. {
  15763. return server_sign;
  15764. }
  15765. uint8_t GetOcppSecurityProfile()
  15766. {
  15767. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  15768. }
  15769. void GetOcppChargerBoxId(uint8_t *data)
  15770. {
  15771. sprintf((char*)data, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  15772. }
  15773. void GetOcppSecurityPassword(uint8_t *data)
  15774. {
  15775. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  15776. }
  15777. void SetServerSign(int value)
  15778. {
  15779. server_sign = value;
  15780. }
  15781. int GetBootNotificationInterval(void)
  15782. {
  15783. return BootNotificationInterval;
  15784. }
  15785. int GetInternetConn(void)
  15786. {
  15787. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  15788. }
  15789. int GetBackendConnectionTimeout(void)
  15790. {
  15791. return ShmSysConfigAndInfo->SysConfig.BackendConnTimeout>=0?ShmSysConfigAndInfo->SysConfig.BackendConnTimeout:300;
  15792. }
  15793. int isConnectorInitMode(int gun_index)
  15794. {
  15795. int tempIndex = 0;
  15796. int result = TRUE;
  15797. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  15798. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  15799. {
  15800. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15801. {
  15802. tempIndex = ((gun_index==2) ? 1: 0);
  15803. }
  15804. else
  15805. {
  15806. tempIndex = gun_index;
  15807. }
  15808. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  15809. {
  15810. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  15811. {
  15812. result = (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  15813. } //end of the same index
  15814. }//end of for CHAdeMO_QUANTITY
  15815. }
  15816. else if(gunType[gun_index] == GUN_TYPE_CCS)
  15817. {
  15818. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15819. {
  15820. tempIndex = ((gun_index==2) ? 1: 0);
  15821. }
  15822. else
  15823. {
  15824. tempIndex = gun_index;
  15825. }
  15826. for (int index = 0; index < CCS_QUANTITY; index++)
  15827. {
  15828. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  15829. {
  15830. result = (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  15831. } //end of the same index
  15832. } // end of for CCS_QUANTITY
  15833. }
  15834. else if(gunType[gun_index] == GUN_TYPE_GBT)
  15835. {
  15836. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15837. {
  15838. tempIndex = ((gun_index==2) ? 1: 0);
  15839. }
  15840. else
  15841. {
  15842. tempIndex = gun_index;
  15843. }
  15844. for (int index = 0; index < GB_QUANTITY; index++)
  15845. {
  15846. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  15847. {
  15848. result = (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  15849. } //end of the same index
  15850. } // end of for GB_QUANTITY
  15851. }
  15852. else if(gunType[gun_index] == GUN_TYPE_DO)
  15853. {
  15854. tempIndex = gun_index;
  15855. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  15856. {
  15857. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  15858. {
  15859. result = (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  15860. } //end of the same index
  15861. }
  15862. }
  15863. else
  15864. {
  15865. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  15866. {
  15867. tempIndex = 2;
  15868. }
  15869. else
  15870. {
  15871. tempIndex = gun_index;
  15872. }
  15873. for (int index = 0; index < AC_QUANTITY; index++)
  15874. {
  15875. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  15876. {
  15877. result = (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  15878. }//end of the same index
  15879. }//end of for AC_QUANTITY
  15880. }
  15881. return result;
  15882. }
  15883. void refreshProcDogTimer()
  15884. {
  15885. ShmOCPP20Data->procDogTime = time((time_t*)NULL);
  15886. }
  15887. void InitialSystemValue(void)
  15888. {
  15889. int connectorIndex = 0;
  15890. gunTotalNumber=0;
  15891. SystemInitial = 0;
  15892. localversion=0;
  15893. BootNotificationInterval = 10;
  15894. authorizeRetryTimes = 0;
  15895. GunStatusInterval = 10;
  15896. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  15897. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  15898. //Hear Beat
  15899. HeartBeatWithNOResponse = 0;
  15900. HeartBeatCountPerHour = 0;
  15901. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  15902. FirstHeartBeat = 0;
  15903. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  15904. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  15905. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  15906. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  15907. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  15908. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  15909. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  15910. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  15911. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  15912. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  15913. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  15914. memset(gunType, 0, ARRAY_SIZE(gunType));
  15915. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  15916. {
  15917. if((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
  15918. (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
  15919. (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
  15920. {
  15921. // DO series
  15922. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  15923. {
  15924. SystemInitial = SystemInitial + 1;
  15925. gunTotalNumber = gunTotalNumber + 1;
  15926. gunType[connectorIndex] = GUN_TYPE_DO;
  15927. connectorIndex = connectorIndex + 1;
  15928. }
  15929. }
  15930. else
  15931. {
  15932. // DM, DW, DS series
  15933. //check connector / socket type (index: 8, 9, 10)
  15934. for(int index=7; index <10 ; index++)
  15935. {
  15936. if(index != 8)
  15937. {
  15938. // DC Connector
  15939. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'J'))
  15940. {
  15941. SystemInitial = SystemInitial + 1;
  15942. gunTotalNumber = gunTotalNumber + 1;
  15943. gunType[connectorIndex] = GUN_TYPE_CHAdeMO;
  15944. connectorIndex = connectorIndex + 1;
  15945. }
  15946. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'D') ||
  15947. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'E') ||
  15948. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'F') ||
  15949. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'U') ||
  15950. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'T') ||
  15951. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'V'))
  15952. {
  15953. SystemInitial = SystemInitial + 1;
  15954. gunTotalNumber = gunTotalNumber + 1;
  15955. gunType[connectorIndex] = GUN_TYPE_CCS;
  15956. connectorIndex = connectorIndex + 1;
  15957. }
  15958. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'G'))
  15959. {
  15960. SystemInitial = SystemInitial + 1;
  15961. gunTotalNumber = gunTotalNumber + 1;
  15962. gunType[connectorIndex] = GUN_TYPE_GBT;
  15963. connectorIndex = connectorIndex + 1;
  15964. }
  15965. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'O'))
  15966. {
  15967. SystemInitial = SystemInitial + 1;
  15968. gunTotalNumber = gunTotalNumber + 1;
  15969. gunType[connectorIndex] = GUN_TYPE_DO;
  15970. connectorIndex = connectorIndex + 1;
  15971. }
  15972. }
  15973. else
  15974. {
  15975. // AC Connector
  15976. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  15977. {
  15978. SystemInitial = SystemInitial + 1;
  15979. gunTotalNumber = gunTotalNumber + 1;
  15980. gunType[connectorIndex] = GUN_TYPE_AC;
  15981. connectorIndex = connectorIndex + 1;
  15982. }
  15983. }
  15984. }
  15985. }
  15986. //DEBUG_INFO("DC ...\n");
  15987. }
  15988. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  15989. {
  15990. //check connector / socket type (index: 8, 9, 10)
  15991. for(int index=7; index <10 ; index++)
  15992. {
  15993. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  15994. {
  15995. SystemInitial = SystemInitial + 1;
  15996. gunTotalNumber = gunTotalNumber + 1;
  15997. gunType[connectorIndex] = GUN_TYPE_AC;
  15998. connectorIndex = connectorIndex + 1;
  15999. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  16000. }
  16001. }
  16002. }
  16003. //Status && ConnectorPlugIn Setting
  16004. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  16005. {
  16006. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  16007. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  16008. }
  16009. for (int index = 0; index < CCS_QUANTITY; index++)
  16010. {
  16011. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  16012. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  16013. }
  16014. for (int index = 0; index < GB_QUANTITY; index++)
  16015. {
  16016. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  16017. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  16018. }
  16019. for (int index = 0; index < AC_QUANTITY; index++)
  16020. {
  16021. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  16022. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  16023. }
  16024. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  16025. {
  16026. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  16027. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  16028. }
  16029. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  16030. {
  16031. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  16032. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  16033. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  16034. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  16035. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  16036. memset(&ShmOCPP20Data->StatusNotification[gun_index], 0x00, sizeof(struct StatusNotification_20));
  16037. }
  16038. clientTime.Heartbeat=time((time_t*)NULL);
  16039. sleep(1);
  16040. }
  16041. void LWS_Send(char *str)
  16042. {
  16043. //=====================================================
  16044. // Check InternetConn 0: disconnected, 1: connected
  16045. //====================================================
  16046. if(GetOcppConnStatus() == 0)
  16047. {
  16048. DEBUG_INFO("offline now !!!\n");
  16049. return;
  16050. }
  16051. // Only disable isWebsocketSendable operation initiated by charger
  16052. if((strstr((char*)str, "\"Authorize\"") != NULL)
  16053. || (strstr((char*)str, "\"BootNotification\"") != NULL)
  16054. || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
  16055. || (strstr((char*)str, "\"DataTransfer\"") != NULL)
  16056. || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
  16057. || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
  16058. || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
  16059. || (strstr((char*)str, "\"Heartbeat\"") != NULL)
  16060. || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
  16061. || (strstr((char*)str, "\"MeterValues\"") != NULL)
  16062. || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
  16063. || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
  16064. || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
  16065. || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
  16066. || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
  16067. || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
  16068. || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
  16069. || (strstr((char*)str, "\"NotifyReport\"") != NULL)
  16070. || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
  16071. || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
  16072. || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
  16073. || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
  16074. || (strstr((char*)str, "\"SignCertificate\"") != NULL)
  16075. || (strstr((char*)str, "\"StatusNotification\"") != NULL)
  16076. || (strstr((char*)str, "\"TransactionEven\"") != NULL))
  16077. {
  16078. isWebsocketSendable = OFF;
  16079. }
  16080. pthread_mutex_lock(&lock_send);
  16081. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  16082. sprintf((char *)SendBuffer, "%s", str);
  16083. SendBufLen = strlen(str);
  16084. pthread_mutex_unlock(&lock_send);
  16085. lws_callback_on_writable(wsi_client);
  16086. //lws_service(context, 0);
  16087. //sleep(1);
  16088. }
  16089. void LWS_SendNow(char *str)
  16090. {
  16091. //=====================================================
  16092. // Check InternetConn 0: disconnected, 1: connected
  16093. //====================================================
  16094. if(GetOcppConnStatus() == 0)
  16095. {
  16096. DEBUG_INFO("offline now !!!\n");
  16097. return;
  16098. }
  16099. // Only disable isWebsocketSendable operation initiated by charger
  16100. if((strstr((char*)str, "\"Authorize\"") != NULL)
  16101. || (strstr((char*)str, "\"BootNotification\"") != NULL)
  16102. || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
  16103. || (strstr((char*)str, "\"DataTransfer\"") != NULL)
  16104. || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
  16105. || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
  16106. || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
  16107. || (strstr((char*)str, "\"Heartbeat\"") != NULL)
  16108. || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
  16109. || (strstr((char*)str, "\"MeterValues\"") != NULL)
  16110. || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
  16111. || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
  16112. || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
  16113. || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
  16114. || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
  16115. || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
  16116. || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
  16117. || (strstr((char*)str, "\"NotifyReport\"") != NULL)
  16118. || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
  16119. || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
  16120. || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
  16121. || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
  16122. || (strstr((char*)str, "\"SignCertificate\"") != NULL)
  16123. || (strstr((char*)str, "\"StatusNotification\"") != NULL)
  16124. || (strstr((char*)str, "\"TransactionEven\"") != NULL))
  16125. {
  16126. isWebsocketSendable = OFF;
  16127. }
  16128. pthread_mutex_lock(&lock_send);
  16129. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  16130. sprintf((char *)SendBuffer, "%s", str);
  16131. SendBufLen = strlen(str);
  16132. pthread_mutex_unlock(&lock_send);
  16133. lws_callback_on_writable(wsi_client);
  16134. lws_service(context, 0);
  16135. //sleep(1);
  16136. }