MessageHandler.c 998 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202
  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 ParsingRatedCur modelnameInfo = {0};
  679. static int gunTotalNumber = 0;
  680. static uint8_t gunType[4] = {0};
  681. //===============================
  682. // Local List Version
  683. //===============================
  684. static int localversion=0;
  685. //===============================
  686. // Variable Version
  687. //===============================
  688. static int variableVersion=5;
  689. //===============================
  690. // OCPP sign variable
  691. //===============================
  692. static int server_sign = FALSE;
  693. int server_pending = FALSE;
  694. static int BootNotificationInterval = 10;
  695. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  696. //===============================
  697. // OCPP auth variable
  698. //===============================
  699. static int authorizeRetryTimes = 0; //number of Retry times
  700. //===============================
  701. // OCPP other variables
  702. //===============================
  703. static int HeartBeatWaitTime = 10;
  704. static int FirstHeartBeat = 0;
  705. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  706. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  707. static char CurrentChargingProfileScheduleStr[30] = {0};
  708. //========================================
  709. // OCPP status/previous related variables
  710. //========================================
  711. static int GunStatusInterval = 10;
  712. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  713. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  714. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  715. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  716. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  717. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  718. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  719. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  720. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  721. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  722. static int TransactionMessageAttemptsValue = 0;
  723. static int TransactionMessageRetryIntervalValue = 0;
  724. static struct AuthorizationData idTagQuery;
  725. //=============================================
  726. // OCPP HeartBeat Response Not Receive Counts
  727. //============================================
  728. static int HeartBeatWithNOResponse = 0;
  729. static int HeartBeatCountPerHour = 0;
  730. sqlite3 *db;
  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. struct timespec Heartbeat;
  746. struct timespec StatusNotification[CONNECTOR_QUANTITY];
  747. struct timespec StartTransaction;
  748. struct timespec StopTransaction;
  749. struct timespec MeterValues[CONNECTOR_QUANTITY];
  750. struct timespec RemoteStartWait;
  751. }clientTime;
  752. typedef union
  753. {
  754. //Operations Initiated by Central System
  755. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  756. struct
  757. {
  758. //CsMsgValue[0]
  759. unsigned char StatusNotificationReq:1; //bit 0,
  760. unsigned char StatusNotificationConf:1; //bit 1,
  761. unsigned char TriggerMeterValueReq:1; //bit 2,
  762. unsigned char SampleMeterReq:1; //bit 3,
  763. unsigned char ClockAlignMeterReq:1; //bit 4,
  764. unsigned char TriggerStatusNotificationReq:1; //bit 5,
  765. unsigned char isOnCharging:1; //bit6,
  766. unsigned char :1; //bit7
  767. }bits[CONNECTOR_QUANTITY];
  768. }CpinitiateMsg;
  769. CpinitiateMsg cpinitateMsg;
  770. //=========================================
  771. // Save configuration
  772. //=========================================
  773. int runShellCmd(const char*cmd)
  774. {
  775. int result = FAIL;
  776. char buf[256];
  777. FILE *fp;
  778. fp = popen(cmd, "r");
  779. if(fp != NULL)
  780. {
  781. while(fgets(buf, sizeof(buf), fp) != NULL)
  782. {
  783. DEBUG_INFO("%s\n", buf);
  784. }
  785. result = PASS;
  786. }
  787. pclose(fp);
  788. return result;
  789. }
  790. int StoreUsrConfigData(struct SysConfigData *UsrData)
  791. {
  792. int result = PASS;
  793. int fd,wrd;
  794. unsigned int i,Chk;
  795. unsigned char *ptr, *BufTmp;
  796. int MtdBlockSize = 0x300000;
  797. Chk=0;
  798. ptr=(unsigned char *)UsrData;
  799. if((BufTmp=malloc(MtdBlockSize))!=NULL)
  800. {
  801. memset(BufTmp,0,MtdBlockSize);
  802. memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
  803. for(i=ARRAY_SIZE(UsrData->CsuBootLoadFwRev);i<MtdBlockSize-4;i++)
  804. Chk+=*(BufTmp+i);
  805. memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
  806. // Output configuration to file.
  807. fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
  808. if (fd < 0)
  809. {
  810. DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
  811. free(BufTmp);
  812. return 0;
  813. }
  814. wrd=write(fd, BufTmp, MtdBlockSize);
  815. close(fd);
  816. if(wrd<MtdBlockSize)
  817. {
  818. DEBUG_ERROR("write /mnt/EvseConfig.bin NG\n");
  819. free(BufTmp);
  820. return 0;
  821. }
  822. DEBUG_INFO("EvseConfig write to file in /mnt OK.\n");
  823. DEBUG_INFO("Erase /dev/mtd10.\n");
  824. runShellCmd("flash_erase /dev/mtd10 0 0");
  825. DEBUG_INFO("Write /dev/mtd10.\n");
  826. runShellCmd("nandwrite -p /dev/mtd10 /mnt/EvseConfig.bin");
  827. DEBUG_INFO("Erase /dev/mtd11.\n");
  828. runShellCmd("flash_erase /dev/mtd11 0 0");
  829. DEBUG_INFO("Write /dev/mtd11.\n");
  830. runShellCmd("nandwrite -p /dev/mtd11 /mnt/EvseConfig.bin");
  831. system("rm -f /mnt/EvseConfig.bin");
  832. DEBUG_INFO("EvseConfig write to flash OK\n");
  833. }
  834. else
  835. {
  836. DEBUG_ERROR("alloc BlockSize NG\r\n");
  837. result = FAIL;
  838. }
  839. if(BufTmp!=NULL)
  840. free(BufTmp);
  841. return result;
  842. }
  843. //=========================================
  844. // Date time related function
  845. //=========================================
  846. void getNowDatetime(uint8_t *data)
  847. {
  848. time_t t = time(NULL);
  849. struct tm tm = *localtime(&t);
  850. 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);
  851. }
  852. //=========================================
  853. // Sqlite3 related function
  854. //=========================================
  855. int DB_Initial()
  856. {
  857. int result = PASS;
  858. char* errMsg = NULL;
  859. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  860. "idToken text UNIQUE,"
  861. "type text,"
  862. "status text,"
  863. "cacheExpiryDateTime text,"
  864. "chargingPriority integer,"
  865. "language1 text,"
  866. "evseId text,"
  867. "language2 text,"
  868. "groupIdToken_idToken text,"
  869. "groupIdToken_type text,"
  870. "personalMessage text);";
  871. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  872. "idToken text UNIQUE,"
  873. "type text,"
  874. "status text,"
  875. "cacheExpiryDateTime text,"
  876. "chargingPriority integer,"
  877. "language1 text,"
  878. "evseId text,"
  879. "language2 text,"
  880. "groupIdToken_idToken text,"
  881. "groupIdToken_type text,"
  882. "personalMessage text,"
  883. "version text);";
  884. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  885. "componentName text NOT NULL ,"
  886. "componentInstance text, "
  887. "variableName text NOT NULL, "
  888. "variableInstance text, "
  889. "variableCharacteristicsDataType integer, "
  890. "variableCharacteristicsUnit text, "
  891. "variableCharacteristicsMaxLimit real,"
  892. "variableAttributesType text, "
  893. "variableAttributesTypeMutability text, "
  894. "variableAttributesTypeValue text, "
  895. "variableCharacteristicsMinLimit real,"
  896. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  897. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  898. "type text);";
  899. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  900. "slot integer UNIQUE, connectionData text);";
  901. char *sqlTransaction = "create table if not exists ocpp20_transaction_record (idx integer primary key,"
  902. "occurDatetime text,"
  903. "message_type text,"
  904. "message_content text)";
  905. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  906. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  907. {
  908. result = FAIL;
  909. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  910. sqlite3_close(db);
  911. }
  912. else
  913. {
  914. DEBUG_INFO( "OCPP local database open successfully.\n");
  915. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  916. {
  917. result = FAIL;
  918. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  919. }
  920. else
  921. {
  922. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  923. }
  924. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  925. {
  926. result = FAIL;
  927. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  928. }
  929. else
  930. {
  931. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  932. }
  933. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  934. {
  935. result = FAIL;
  936. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  937. }
  938. else
  939. {
  940. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  941. }
  942. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  943. {
  944. result = FAIL;
  945. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  946. }
  947. else
  948. {
  949. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  950. }
  951. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  952. {
  953. result = FAIL;
  954. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  955. }
  956. else
  957. {
  958. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  959. }
  960. if (sqlite3_exec(db, sqlTransaction, 0, 0, &errMsg) != SQLITE_OK)
  961. {
  962. result = FAIL;
  963. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_transaction_record table error message: %s\n", errMsg);
  964. }
  965. else
  966. {
  967. DEBUG_INFO( "Create OCPP 2.0 ocpp20_transaction_record table successfully\n");
  968. }
  969. //sqlite3_close(db);
  970. }
  971. return result;
  972. }
  973. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  974. {
  975. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  976. return 0;
  977. }
  978. void DB_getListVerion()
  979. {
  980. char sql[256];
  981. char* errMsg = NULL;
  982. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  983. /* Execute SQL statement */
  984. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  985. {
  986. DEBUG_INFO("SQL error: %s", errMsg);
  987. }
  988. }
  989. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  990. {
  991. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  992. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  993. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  994. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  995. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  996. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  997. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  998. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  999. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  1000. return 0;
  1001. }
  1002. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  1003. {
  1004. char sql[256];
  1005. char* errMsg = NULL;
  1006. memset(&idTagQuery, 0, sizeof(idTagQuery));
  1007. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  1008. if(isQueryFromCache)
  1009. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  1010. else
  1011. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  1012. /* Execute SQL statement */
  1013. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  1014. {
  1015. DEBUG_INFO("SQL error: %s", errMsg);
  1016. }
  1017. }
  1018. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  1019. {
  1020. for (int i = 0; i < columnCount; i++)
  1021. {
  1022. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  1023. }
  1024. return 0;
  1025. }
  1026. void DB_get_TableAuthlocalAllData(void)
  1027. {
  1028. char sql[256];
  1029. char* errMsg = NULL;
  1030. sprintf(sql,"select * from ocpp20_auth_local;");
  1031. /* Execute SQL statement */
  1032. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  1033. {
  1034. DEBUG_INFO("SQL error: %s", errMsg);
  1035. }
  1036. }
  1037. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  1038. {
  1039. for(int i = 0; i<columnCount; i++)
  1040. {
  1041. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1042. }
  1043. return 0;
  1044. }
  1045. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  1046. {
  1047. int result = PASS;
  1048. char sql[512];
  1049. char* errMsg = NULL;
  1050. 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;",
  1051. data->idToken.idToken,
  1052. data->idToken.type,
  1053. data->idTokenInfo.status,
  1054. data->idTokenInfo.cacheExpiryDateTime,
  1055. data->idTokenInfo.chargingPriority,
  1056. data->idTokenInfo.language1,
  1057. data->idTokenInfo.language2,
  1058. data->idTokenInfo.groupIdToken.idToken,
  1059. data->idTokenInfo.groupIdToken.type,
  1060. listVersion);
  1061. //* Execute SQL statement */
  1062. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1063. {
  1064. DEBUG_INFO("SQL error: %s\n", errMsg);
  1065. result = FAIL;
  1066. }
  1067. else
  1068. {
  1069. memset(sql, 0, ARRAY_SIZE(sql));
  1070. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  1071. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  1072. {
  1073. DEBUG_INFO("SQL error: %s\n", errMsg);
  1074. result = FAIL;
  1075. }
  1076. }
  1077. return result;
  1078. }
  1079. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  1080. {
  1081. int result = PASS;
  1082. char sql[512];
  1083. char* errMsg = NULL;
  1084. 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;",
  1085. idToken->idToken,
  1086. idToken->type,
  1087. idTokenInfo->status,
  1088. idTokenInfo->cacheExpiryDateTime,
  1089. idTokenInfo->chargingPriority,
  1090. idTokenInfo->language1,
  1091. idTokenInfo->language2,
  1092. idTokenInfo->groupIdToken.idToken,
  1093. idTokenInfo->groupIdToken.type);
  1094. //* Execute SQL statement */
  1095. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1096. {
  1097. DEBUG_INFO("SQL error: %s\n", errMsg);
  1098. result = FAIL;
  1099. }
  1100. return result;
  1101. }
  1102. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1103. {
  1104. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1105. // printf("localversion=%d\n", localversion);
  1106. return 0;
  1107. }
  1108. void DB_deleteIdTag(char idTag[])
  1109. {
  1110. char sql[512];
  1111. char* errMsg = NULL;
  1112. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1113. //* Execute SQL statement */
  1114. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1115. {
  1116. DEBUG_INFO("SQL error: %s", errMsg);
  1117. }
  1118. }
  1119. int DB_cleanLocalList()
  1120. {
  1121. int result = PASS;
  1122. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1123. char *errMsg = 0;
  1124. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1125. {
  1126. DEBUG_INFO("%s\n", errMsg);
  1127. result = FAIL;
  1128. }
  1129. return result;
  1130. }
  1131. int DB_cleanLocalCache()
  1132. {
  1133. int result = PASS;
  1134. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1135. char *errMsg = 0;
  1136. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1137. {
  1138. DEBUG_INFO("%s\n", errMsg);
  1139. result = FAIL;
  1140. }
  1141. return result;
  1142. }
  1143. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1144. {
  1145. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1146. return 0;
  1147. }
  1148. void DB_getBooType()
  1149. {
  1150. char sql[256];
  1151. char* errMsg = NULL;
  1152. sprintf(sql,"select * from ocpp20_boot_type;");
  1153. /* Execute SQL statement */
  1154. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1155. {
  1156. DEBUG_INFO("SQL error: %s\n", errMsg);
  1157. }
  1158. }
  1159. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1160. {
  1161. for(int i = 0; i<columnCount; i++)
  1162. {
  1163. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1164. }
  1165. return 0;
  1166. }
  1167. int DB_updateBootType(BootReasonEnumType reason)
  1168. {
  1169. int result = PASS;
  1170. char sql[512];
  1171. char* errMsg = NULL;
  1172. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1173. //* Execute SQL statement */
  1174. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1175. {
  1176. DEBUG_INFO("SQL error: %s\n", errMsg);
  1177. result = FAIL;
  1178. }
  1179. return result;
  1180. }
  1181. int DB_variableClear()
  1182. {
  1183. int result = PASS;
  1184. char * sqlcleanLocalList = "delete from ocpp20_variable";
  1185. char *errMsg = 0;
  1186. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1187. {
  1188. DEBUG_INFO("%s\n", errMsg);
  1189. result = FAIL;
  1190. }
  1191. return result;
  1192. }
  1193. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1194. {
  1195. for(int i = 0; i<columnCount; i++)
  1196. {
  1197. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1198. }
  1199. return 0;
  1200. }
  1201. int DB_variableSaveToDb(struct ReportDataType *variable)
  1202. {
  1203. int result = FAIL;
  1204. char sql[4096];
  1205. char* errMsg = NULL;
  1206. sprintf(sql,"insert or replace into ocpp20_variable (componentName, componentInstance, variableName, variableInstance, variableCharacteristicsDataType, variableCharacteristicsUnit, variableCharacteristicsMaxLimit, variableAttributesType, variableAttributesTypeMutability, variableAttributesTypeValue, variableCharacteristicsMinLimit) VALUES('%s', '%s', '%s', '%s', '%s', '%s', %f, '%s', '%s', '%s', '%f'); SELECT * from ocpp20_variable;",
  1207. variable->component.name,
  1208. variable->component.instance,
  1209. variable->variable.name,
  1210. variable->variable.instance,
  1211. variable->variableCharacteristics.dataType,
  1212. variable->variableCharacteristics.unit,
  1213. variable->variableCharacteristics.maxLimit,
  1214. variable->variableAttribute[0].type,
  1215. variable->variableAttribute[0].mutability,
  1216. variable->variableAttribute[0].value,
  1217. variable->variableCharacteristics.minLimit);
  1218. //* Execute SQL statement */
  1219. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1220. {
  1221. DEBUG_INFO("SQL error: %s\n", errMsg);
  1222. result = FAIL;
  1223. }
  1224. return result;
  1225. }
  1226. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1227. {
  1228. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1229. if(atoi(columnValue[0]) == 0)
  1230. {
  1231. DB_updateBootType(BootReasonEnumType_PowerUp);
  1232. // Create variable table content
  1233. /* AlignedDataCtrlr Required item */
  1234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1240. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1247. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1251. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.maxLimit = 20;
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1254. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,"
  1256. "Energy.Active.Import.Register,"
  1257. "Energy.Active.Import.Interval,"
  1258. "Power.Active.Import,"
  1259. "Voltage,"
  1260. "SoC,"
  1261. "Current.Offered,"
  1262. "Power.Offered");
  1263. else
  1264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,"
  1265. "Energy.Active.Import.Register,"
  1266. "Energy.Active.Import.Interval,"
  1267. "Power.Active.Import,"
  1268. "Voltage,"
  1269. "Current.Offered");
  1270. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1275. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 5;
  1276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1279. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1286. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1293. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1297. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1300. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1302. "Energy.Active.Import.Register,"
  1303. "Energy.Active.Import.Interval,"
  1304. "Power.Active.Import,"
  1305. "Voltage,"
  1306. "SoC");
  1307. else
  1308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1309. "Energy.Active.Import.Register,"
  1310. "Energy.Active.Import.Interval,"
  1311. "Power.Active.Import,"
  1312. "Voltage");
  1313. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1321. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1322. /* AuthCtrlrVariable Required item */
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1329. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1336. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1343. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1350. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1357. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1364. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1368. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1372. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1373. /* AuthCacheCtrlr Variable Required item*/
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1380. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1387. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1395. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1399. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
  1400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1403. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1410. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1411. /* ClockCtrlr Variable Required item */
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1417. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1418. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1425. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1433. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1440. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1447. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1455. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1462. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1469. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1470. /* ChargingStation Required item */
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1477. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1484. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1491. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].component.name, "ChargingStation");
  1493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variable.name, "SystemUptimeSec");
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].value, "0");
  1498. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].component.name, "ChargingStation");
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variable.name, "FreeVend");
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].value, (ShmSysConfigAndInfo->SysConfig.AuthorisationMode?"TRUE":"FALSE"));
  1505. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend]);
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].component.name, "ChargingStation");
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variable.name, "FreeVendIdtag");
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].value, "FreeVendIdtag");
  1512. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag]);
  1513. /* Connector Required item */
  1514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1520. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1527. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1534. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1535. /* CustomizationCtrlr Required item */
  1536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1542. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1543. /* DeviceDataCtrlr Required item */
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1551. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1559. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1567. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1575. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1578. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1583. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1586. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1591. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1599. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1607. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1608. /* DisplayMessageCtrlr Required item */
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1615. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1622. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1626. ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.maxLimit = 1;
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "1");
  1630. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1637. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1644. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1645. /* EVSE Required item */
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1652. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1659. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1660. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1666. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1673. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1674. /* LocalAuthListCtrlr Required item */
  1675. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1681. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1685. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.maxLimit = 5000;
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1689. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1696. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "500");
  1704. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "20480");
  1712. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1716. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "100000");
  1720. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1721. /* MonitoringCtrlr Required item */
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1728. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1730. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1735. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1743. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1751. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1752. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1759. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1767. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1774. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1775. /* OCPPCommCtrlr Required item */
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1782. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1788. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1791. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1796. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1798. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1802. ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.minLimit = 10;
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1807. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1814. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1821. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1829. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1836. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1843. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1845. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1850. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "30");
  1854. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1857. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1861. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1865. ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.minLimit = 10;
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1870. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1871. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1877. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1878. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1884. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].component.name, "OCPPCommCtrlr");
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variable.name, "VariableVersion");
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].value, "%d", variableVersion);
  1891. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion]);
  1892. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].component.name, "OCPPCommCtrlr");
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variable.name, "StatusNotificationPeriodically");
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "FALSE");
  1898. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically]);
  1899. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].component.name, "OCPPCommCtrlr");
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variable.name, "StatusNotificationInterval");
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.unit, "Seconds");
  1902. ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.minLimit = 10;
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].value, "120");
  1907. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval]);
  1908. /* ReservationCtrlr Required item */
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1913. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1915. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1920. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1922. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1927. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1928. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1929. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1930. /* SampledDataCtrlr Required item */
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1937. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1944. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1951. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1952. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1955. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1958. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1959. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1960. "Energy.Active.Import.Register,"
  1961. "Energy.Active.Import.Interval,"
  1962. "Power.Active.Import,"
  1963. "Voltage,"
  1964. "SoC");
  1965. else
  1966. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1967. "Energy.Active.Import.Register,"
  1968. "Energy.Active.Import.Interval,"
  1969. "Power.Active.Import,"
  1970. "Voltage");
  1971. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1979. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1983. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.maxLimit = 10;
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1987. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1988. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1991. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.maxLimit = 10;
  1992. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1994. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, "Current.Import,"
  1996. "Energy.Active.Import.Register,"
  1997. "Energy.Active.Import.Interval,"
  1998. "Power.Active.Import,"
  1999. "Voltage,"
  2000. "SoC,"
  2001. "Current.Offered,"
  2002. "Power.Offered");
  2003. else
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, "Current.Import,"
  2005. "Energy.Active.Import.Register,"
  2006. "Energy.Active.Import.Interval,"
  2007. "Power.Active.Import,"
  2008. "Voltage,"
  2009. "Current.Offered");
  2010. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2015. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 3;
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
  2019. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  2020. /* SecurityCtrlr Required item */
  2021. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2024. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]);
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword);
  2028. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2032. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  2036. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  2043. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  2044. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2045. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2046. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2047. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.maxLimit = 1;
  2048. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  2051. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
  2058. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  2065. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  2066. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2069. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.maxLimit = 10000;
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].value, "10000");
  2073. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize]);
  2074. /* SmartChargingCtrlr Required item */
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  2081. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  2088. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  2095. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  2102. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  2109. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  2116. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  2123. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  2130. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  2137. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2141. ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.maxLimit = 10;
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "10");
  2145. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  2152. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  2153. /* TariffCostCtrlr Required item */
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  2161. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  2169. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2173. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  2177. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  2185. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  2193. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2197. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  2201. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2205. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  2209. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  2210. /* TxCtrlr Required item */
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2217. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2225. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2232. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2239. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2246. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2253. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "0");
  2261. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2268. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2269. }
  2270. else
  2271. {
  2272. // Variable name init
  2273. /* AlignedDataCtrlr Required item */
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2290. /* AuthCtrlrVariable Required item */
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2305. /* AuthCacheCtrlr Variable Required item */
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2316. /* ClockCtrlr Variable Required item */
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2335. /* ChargingStation Required item */
  2336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].component.name, "ChargingStation");
  2343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variable.name, "SystemUptimeSec");
  2344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].component.name, "ChargingStation");
  2345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variable.name, "FreeVend");
  2346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].component.name, "ChargingStation");
  2347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variable.name, "FreeVendIdtag");
  2348. /* Connector Required item */
  2349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2355. /* CustomizationCtrlr Required item */
  2356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  2357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  2358. /* DeviceDataCtrlr Required item */
  2359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2381. /* DisplayMessageCtrlr Required item */
  2382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2392. /* EVSE Required item */
  2393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2401. /* LocalAuthListCtrlr Required item */
  2402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2416. /* MonitoringCtrlr Required item */
  2417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2435. /* OCPPCommCtrlr Required item */
  2436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].component.name, "OCPPCommCtrlr");
  2468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variable.name, "VariableVersion");
  2469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].component.name, "OCPPCommCtrlr");
  2470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variable.name, "StatusNotificationPeriodically");
  2471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].component.name, "OCPPCommCtrlr");
  2472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variable.name, "StatusNotificationInterval");
  2473. /* ReservationCtrlr Required item */
  2474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2480. /* SampledDataCtrlr Required item */
  2481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2497. /* SecurityCtrlr Required item */
  2498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
  2511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
  2512. /* SmartChargingCtrlr Required item */
  2513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2535. /* TariffCostCtrlr Required item */
  2536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2554. /* TxCtrlr Required item */
  2555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2571. }
  2572. return 0;
  2573. }
  2574. void DB_variableIsCreate()
  2575. {
  2576. char sql[512];
  2577. char* errMsg = NULL;
  2578. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2579. /* Execute SQL statement */
  2580. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2581. {
  2582. DEBUG_INFO("SQL error: %s\n", errMsg);
  2583. }
  2584. }
  2585. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2586. {
  2587. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2588. {
  2589. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) == 0) &&
  2590. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) == 0) &&
  2591. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) == 0) &&
  2592. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) == 0))
  2593. {
  2594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2596. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2600. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.minLimit = strlen(columnValue[11])>=0?atoi(columnValue[11]):0;
  2601. }
  2602. }
  2603. return 0;
  2604. }
  2605. void DB_variableLoadFromDb()
  2606. {
  2607. char sql[512];
  2608. char* errMsg = NULL;
  2609. sprintf(sql,"select * from ocpp20_variable order by idx;");
  2610. /* Execute SQL statement */
  2611. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2612. {
  2613. DEBUG_INFO("SQL error: %s\n", errMsg);
  2614. }
  2615. }
  2616. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2617. {
  2618. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2619. if(columnCount > 0)
  2620. {
  2621. for(int idx=0;idx<columnCount;idx++)
  2622. {
  2623. json_object *SetNetworkProfile;
  2624. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2625. if(!is_error(SetNetworkProfile))
  2626. {
  2627. // Required data
  2628. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2629. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2630. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2631. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2632. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2633. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2634. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2635. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2636. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2637. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2638. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2639. {
  2640. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2641. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2642. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2643. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2644. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2645. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2646. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2647. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2648. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2649. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2650. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2651. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2652. }
  2653. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2654. {
  2655. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2656. {
  2657. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2658. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2659. }
  2660. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2661. {
  2662. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2663. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2664. }
  2665. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2666. {
  2667. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2668. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2669. }
  2670. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2671. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2672. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2673. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2674. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2675. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2676. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2677. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2678. }
  2679. }
  2680. json_object_put(SetNetworkProfile);
  2681. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2682. }
  2683. }
  2684. return 0;
  2685. }
  2686. void DB_getNetworkProfileFromDb()
  2687. {
  2688. char sql[512];
  2689. char* errMsg = NULL;
  2690. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2691. /* Execute SQL statement */
  2692. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2693. {
  2694. DEBUG_INFO("SQL error: %s\n", errMsg);
  2695. }
  2696. }
  2697. int DB_addNetworkProfile(int slot, char *data)
  2698. {
  2699. int result = PASS;
  2700. char sql[512];
  2701. char* errMsg = NULL;
  2702. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2703. slot,
  2704. data);
  2705. //* Execute SQL statement */
  2706. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2707. {
  2708. DEBUG_INFO("SQL error: %s\n", errMsg);
  2709. result = FAIL;
  2710. }
  2711. return result;
  2712. }
  2713. int DB_deleteNetworkProfile(int slot)
  2714. {
  2715. int result = PASS;
  2716. char sql[512];
  2717. char* errMsg = NULL;
  2718. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2719. //* Execute SQL statement */
  2720. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2721. {
  2722. DEBUG_INFO("SQL error: %s", errMsg);
  2723. result = FAIL;
  2724. }
  2725. return result;
  2726. }
  2727. int getCurrentYear()
  2728. {
  2729. int result = 0;
  2730. time_t CurrentTime;
  2731. struct tm *tm;
  2732. CurrentTime = time(NULL);
  2733. tm=localtime(&CurrentTime);
  2734. result = (tm->tm_year + 1900);
  2735. return result;
  2736. }
  2737. int OCPP_insert_transaction_msg(uint8_t isStartTransaction, char *transactionMsg)
  2738. {
  2739. int result = PASS;
  2740. char* errMsg = NULL;
  2741. char sqlStr[8192];
  2742. sprintf(sqlStr, "insert into ocpp20_transaction_record(occurDatetime, message_type, message_content) values(CURRENT_TIMESTAMP, '%s', '%s');", (isStartTransaction?"startTransaction":"stopTransaction"), transactionMsg);
  2743. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2744. {
  2745. result = FAIL;
  2746. DEBUG_WARN( "Insert local transaction record error message: %s\n", errMsg);
  2747. }
  2748. 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));
  2749. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2750. {
  2751. result = FAIL;
  2752. DEBUG_WARN( "delete local transaction record error message: %s\n", errMsg);
  2753. }
  2754. return result;
  2755. }
  2756. //==========================================
  2757. // Check time passed since today
  2758. //==========================================
  2759. long long DiffTimebWithNow(struct timeb ST)
  2760. {
  2761. //return milli-second
  2762. struct timeb ET;
  2763. long long StartTime,StopTime;
  2764. ftime(&ET);
  2765. StartTime=(long long)ST.time;
  2766. StopTime=(long long)ET.time;
  2767. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2768. }
  2769. int getTimePassSinceToday(uint8_t gun_index)
  2770. {
  2771. int result = -1;
  2772. static time_t lastTime[4];
  2773. time_t t;
  2774. struct tm *tmStartToday;
  2775. struct timeb tbStartToday;
  2776. t=time(NULL);
  2777. if(difftime(t, lastTime[gun_index])>0)
  2778. {
  2779. tmStartToday=localtime(&t);
  2780. tmStartToday->tm_hour = 0;
  2781. tmStartToday->tm_min = 0;
  2782. tmStartToday->tm_sec = 0;
  2783. tbStartToday.time = mktime(tmStartToday);
  2784. tbStartToday.millitm = 0;
  2785. result = DiffTimebWithNow(tbStartToday)/1000;
  2786. lastTime[gun_index] = t;
  2787. }
  2788. return result;
  2789. }
  2790. int syncDateTimeRTC(uint8_t *data)
  2791. {
  2792. struct ParsingResult
  2793. {
  2794. int result;
  2795. int scanedElement;
  2796. int year;
  2797. int month;
  2798. int mday;
  2799. int hour;
  2800. int min;
  2801. int sec;
  2802. int tz_hour;
  2803. int tz_min;
  2804. float minSec;
  2805. }result;
  2806. struct tm tmOrg;
  2807. struct tm *tmTarget;
  2808. struct timeb tbTarget;
  2809. char buf[128];
  2810. memset(&result, 0x00, sizeof(struct ParsingResult));
  2811. result.result = PASS;
  2812. if(strstr((char*)data, ".") != NULL)
  2813. {
  2814. // Original data with mini second
  2815. if(strstr((char*)data, "Z") != NULL)
  2816. {
  2817. // Original data with Z
  2818. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%fZ",
  2819. &result.year,
  2820. &result.month,
  2821. &result.mday,
  2822. &result.hour,
  2823. &result.min,
  2824. &result.sec,
  2825. &result.minSec);
  2826. }
  2827. else
  2828. {
  2829. // Original data without Z
  2830. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  2831. &result.year,
  2832. &result.month,
  2833. &result.mday,
  2834. &result.hour,
  2835. &result.min,
  2836. &result.sec,
  2837. &result.minSec,
  2838. &result.tz_hour,
  2839. &result.tz_min);
  2840. }
  2841. }
  2842. else
  2843. {
  2844. // Original data without mini second
  2845. if(strstr((char*)data, "Z") != NULL)
  2846. {
  2847. // Original data with Z
  2848. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%dZ",
  2849. &result.year,
  2850. &result.month,
  2851. &result.mday,
  2852. &result.hour,
  2853. &result.min,
  2854. &result.sec);
  2855. }
  2856. else
  2857. {
  2858. // Original data without Z
  2859. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d%d:%d",
  2860. &result.year,
  2861. &result.month,
  2862. &result.mday,
  2863. &result.hour,
  2864. &result.min,
  2865. &result.sec,
  2866. &result.tz_hour,
  2867. &result.tz_min);
  2868. }
  2869. }
  2870. tmOrg.tm_year = result.year - 1900;
  2871. tmOrg.tm_mon = result.month - 1;
  2872. tmOrg.tm_mday = result.mday;
  2873. tmOrg.tm_hour = result.hour;
  2874. tmOrg.tm_min = result.min;
  2875. tmOrg.tm_sec = result.sec;
  2876. tmOrg.tm_gmtoff = 0;
  2877. tbTarget.time = mktime(&tmOrg);
  2878. tbTarget.timezone = 0;
  2879. tbTarget.time -= (result.tz_hour*3600) + (result.tz_min*60*(result.tz_hour>=0?1:-1));
  2880. tmTarget = gmtime(&tbTarget.time);
  2881. 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);
  2882. //DEBUG_INFO(" org date time: %s\n", data);
  2883. //DEBUG_INFO("parse date time: %s\n", buf);
  2884. system(buf);
  2885. system("/sbin/hwclock -w --systohc");
  2886. if(result.scanedElement < 6)
  2887. result.result = FAIL;
  2888. return result.result;
  2889. }
  2890. //==========================================
  2891. // GetCompositeSchedule logic related function
  2892. //==========================================
  2893. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2894. {
  2895. //return milli-second
  2896. unsigned int StartTime,StopTime;
  2897. StartTime=(unsigned int)ST.time;
  2898. StopTime=(unsigned int)ET.time;
  2899. return (StopTime-StartTime);
  2900. }
  2901. int DiffTimebWithNowSec(struct timeb ST)
  2902. {
  2903. //return milli-second
  2904. struct timeb ET;
  2905. unsigned int StartTime,StopTime;
  2906. ftime(&ET);
  2907. StartTime=(unsigned int)ST.time;
  2908. StopTime=(unsigned int)ET.time;
  2909. return (StopTime-StartTime);
  2910. }
  2911. int getStartStop(uint8_t *start, uint8_t *stop)
  2912. {
  2913. int result = -1;
  2914. struct tm tmStart;
  2915. struct timeb tbStart;
  2916. struct tm tmStop;
  2917. struct timeb tbStop;
  2918. 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) &&
  2919. (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))
  2920. {
  2921. //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);
  2922. //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);
  2923. tmStart.tm_year -= 1900;
  2924. tmStart.tm_mon -= 1;
  2925. tbStart.time = mktime(&tmStart);
  2926. tbStart.millitm = 0;
  2927. tmStop.tm_year -= 1900;
  2928. tmStop.tm_mon -= 1;
  2929. tbStop.time = mktime(&tmStop);
  2930. tbStop.millitm = 0;
  2931. result = DiffTimebSec(tbStart, tbStop);
  2932. //DEBUG_INFO("getStartStop(): %d\n", result);
  2933. }
  2934. else
  2935. {
  2936. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2937. }
  2938. return result;
  2939. }
  2940. int isOvertNow(uint8_t *start)
  2941. {
  2942. int result = NO;
  2943. struct ParsingResult
  2944. {
  2945. int result;
  2946. int scanedElement;
  2947. int year;
  2948. int month;
  2949. int mday;
  2950. int hour;
  2951. int min;
  2952. int sec;
  2953. int tz_hour;
  2954. int tz_min;
  2955. float minSec;
  2956. }parsingResult;
  2957. struct tm tmStart;
  2958. struct timeb tbStart;
  2959. memset(&parsingResult, 0x00, sizeof(struct ParsingResult));
  2960. if(strstr((char*)start, ".") != NULL)
  2961. {
  2962. // Original data with mini second
  2963. if(strstr((char*)start, "Z") != NULL)
  2964. {
  2965. // Original data with Z
  2966. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
  2967. &parsingResult.year,
  2968. &parsingResult.month,
  2969. &parsingResult.mday,
  2970. &parsingResult.hour,
  2971. &parsingResult.min,
  2972. &parsingResult.sec,
  2973. &parsingResult.minSec);
  2974. }
  2975. else
  2976. {
  2977. // Original data without Z
  2978. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  2979. &parsingResult.year,
  2980. &parsingResult.month,
  2981. &parsingResult.mday,
  2982. &parsingResult.hour,
  2983. &parsingResult.min,
  2984. &parsingResult.sec,
  2985. &parsingResult.minSec,
  2986. &parsingResult.tz_hour,
  2987. &parsingResult.tz_min);
  2988. }
  2989. }
  2990. else
  2991. {
  2992. // Original data without mini second
  2993. if(strstr((char*)start, "Z") != NULL)
  2994. {
  2995. // Original data with Z
  2996. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
  2997. &parsingResult.year,
  2998. &parsingResult.month,
  2999. &parsingResult.mday,
  3000. &parsingResult.hour,
  3001. &parsingResult.min,
  3002. &parsingResult.sec);
  3003. }
  3004. else
  3005. {
  3006. // Original data without Z
  3007. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
  3008. &parsingResult.year,
  3009. &parsingResult.month,
  3010. &parsingResult.mday,
  3011. &parsingResult.hour,
  3012. &parsingResult.min,
  3013. &parsingResult.sec,
  3014. &parsingResult.tz_hour,
  3015. &parsingResult.tz_min);
  3016. }
  3017. }
  3018. if(parsingResult.scanedElement >= 6)
  3019. {
  3020. tmStart.tm_year = parsingResult.year - 1900;
  3021. tmStart.tm_mon = parsingResult.month - 1;
  3022. tmStart.tm_mday = parsingResult.mday;
  3023. tmStart.tm_hour = parsingResult.hour;
  3024. tmStart.tm_min = parsingResult.min;
  3025. tmStart.tm_sec = parsingResult.sec;
  3026. tmStart.tm_gmtoff = 0;
  3027. tbStart.time = mktime(&tmStart);
  3028. tbStart.timezone = 0;
  3029. tbStart.millitm = 0;
  3030. tbStart.time -= (parsingResult.tz_hour*3600) + (parsingResult.tz_min*60*(parsingResult.tz_hour>=0?1:-1));
  3031. if(DiffTimebWithNowSec(tbStart) <= 0)
  3032. result = NO;
  3033. else
  3034. result = YES;
  3035. }
  3036. else
  3037. {
  3038. DEBUG_WARN("Start date parsing error.\n");
  3039. }
  3040. return result;
  3041. }
  3042. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  3043. {
  3044. int result = -1;
  3045. struct tm tmStart;
  3046. struct timeb tbStart;
  3047. struct tm tmStop;
  3048. struct timeb tbStop;
  3049. 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) &&
  3050. (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))
  3051. {
  3052. tmStart.tm_year -= 1900;
  3053. tmStart.tm_mon -= 1;
  3054. tbStart.time = mktime(&tmStart);
  3055. tbStart.millitm = 0;
  3056. tmStop.tm_year -= 1900;
  3057. tmStop.tm_mon -= 1;
  3058. tbStop.time = mktime(&tmStop);
  3059. tbStop.millitm = 0;
  3060. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  3061. }
  3062. return result;
  3063. }
  3064. void checkChargePointMaxProfile(uint32_t durationReq, struct ChargingProfileType *targetCompositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  3065. {
  3066. FILE *fp;
  3067. char profileFileName[128];
  3068. char *line = NULL;
  3069. size_t len = 0;
  3070. time_t CurrentTime;
  3071. struct tm *tmComposite;
  3072. struct ChargingProfileType maxProfile;
  3073. struct ChargingProfileType compositeProfile;
  3074. uint8_t limitMax=0;
  3075. int compositePeriodIdx = 0;
  3076. CurrentTime = time(NULL);
  3077. tmComposite=localtime(&CurrentTime);
  3078. 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);
  3079. if(isUnitA)
  3080. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3081. else
  3082. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3083. compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
  3084. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3085. {
  3086. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3087. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3088. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3089. }
  3090. compositeProfile.id = 0;
  3091. compositeProfile.stackLevel = 99 ;
  3092. sprintf((char*)compositeProfile.chargingProfileKind ,"Absolute");
  3093. maxProfile.id = -1;
  3094. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  3095. system("rm -f /tmp/*.json");
  3096. system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
  3097. // Search max profile
  3098. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  3099. if((access(profileFileName, F_OK))!=-1)
  3100. {
  3101. fp = fopen(profileFileName, "r");
  3102. while(getline(&line, &len, fp) != -1)
  3103. {
  3104. json_object *obj = NULL;
  3105. obj = json_tokener_parse(line);
  3106. if(is_error(obj))
  3107. {
  3108. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3109. }
  3110. else
  3111. {
  3112. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != maxProfile.id) &&
  3113. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= maxProfile.stackLevel)
  3114. )
  3115. {
  3116. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  3117. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3118. )
  3119. {
  3120. struct tm tmFrom, tmTo;
  3121. struct timeb tbFrom, tbTo;
  3122. 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) &&
  3123. (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))
  3124. {
  3125. tmFrom.tm_year -= 1900;
  3126. tmFrom.tm_mon -= 1;
  3127. tbFrom.time = mktime(&tmFrom);
  3128. tmTo.tm_year -= 1900;
  3129. tmTo.tm_mon -= 1;
  3130. tbTo.time = mktime(&tmTo);
  3131. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3132. {
  3133. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3134. {
  3135. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3136. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3137. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3138. }
  3139. maxProfile.id = -1;
  3140. maxProfile.stackLevel = -1;
  3141. if(maxProfile.id == -1)
  3142. DEBUG_INFO("MaxProfile found.\n");
  3143. else
  3144. DEBUG_INFO("MaxProfile updated.\n");
  3145. // Required item
  3146. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3147. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3148. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3149. if(isUnitA)
  3150. {
  3151. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3152. 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++)
  3153. {
  3154. 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"));
  3155. 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?
  3156. 3:
  3157. 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")));
  3158. 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")));
  3159. }
  3160. }
  3161. else
  3162. {
  3163. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3164. 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++)
  3165. {
  3166. 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"));
  3167. 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?
  3168. 3:
  3169. 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")));
  3170. 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));
  3171. }
  3172. }
  3173. // Optional item
  3174. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3175. {
  3176. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3177. }
  3178. else
  3179. {
  3180. sprintf((char*)maxProfile.validFrom, " ");
  3181. }
  3182. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3183. {
  3184. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3185. }
  3186. else
  3187. {
  3188. sprintf((char*)maxProfile.validTo, " ");
  3189. }
  3190. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3191. {
  3192. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3193. }
  3194. else
  3195. {
  3196. sprintf((char*)maxProfile.recurrencyKind, " ");
  3197. }
  3198. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3199. {
  3200. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3201. }
  3202. else
  3203. {
  3204. sprintf((char*)maxProfile.transactionId, " ");
  3205. }
  3206. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  3207. {
  3208. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  3209. }
  3210. else
  3211. {
  3212. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3213. }
  3214. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  3215. {
  3216. 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")));
  3217. }
  3218. else
  3219. {
  3220. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  3221. }
  3222. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  3223. {
  3224. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  3225. }
  3226. else
  3227. {
  3228. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3229. }
  3230. }
  3231. }
  3232. }
  3233. else
  3234. {
  3235. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3236. {
  3237. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3238. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3239. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3240. }
  3241. maxProfile.id = -1;
  3242. maxProfile.stackLevel = -1;
  3243. if(maxProfile.id == -1)
  3244. DEBUG_INFO("MaxProfile found.\n");
  3245. else
  3246. DEBUG_INFO("MaxProfile updated.\n");
  3247. // Required item
  3248. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3249. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3250. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3251. if(isUnitA)
  3252. {
  3253. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3254. 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++)
  3255. {
  3256. 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"));
  3257. 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?
  3258. 3:
  3259. 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")));
  3260. 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")));
  3261. }
  3262. }
  3263. else
  3264. {
  3265. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3266. 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++)
  3267. {
  3268. 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"));
  3269. 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?
  3270. 3:
  3271. 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")));
  3272. 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));
  3273. }
  3274. }
  3275. // Optional item
  3276. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3277. {
  3278. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3279. }
  3280. else
  3281. {
  3282. sprintf((char*)maxProfile.validFrom, " ");
  3283. }
  3284. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3285. {
  3286. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3287. }
  3288. else
  3289. {
  3290. sprintf((char*)maxProfile.validTo, " ");
  3291. }
  3292. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3293. {
  3294. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3295. }
  3296. else
  3297. {
  3298. sprintf((char*)maxProfile.recurrencyKind, " ");
  3299. }
  3300. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3301. {
  3302. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3303. }
  3304. else
  3305. {
  3306. sprintf((char*)maxProfile.transactionId, " ");
  3307. }
  3308. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  3309. {
  3310. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  3311. }
  3312. else
  3313. {
  3314. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3315. }
  3316. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  3317. {
  3318. 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")));
  3319. }
  3320. else
  3321. {
  3322. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  3323. }
  3324. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  3325. {
  3326. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  3327. }
  3328. else
  3329. {
  3330. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3331. }
  3332. }
  3333. }
  3334. }
  3335. json_object_put(obj);
  3336. }
  3337. fclose(fp);
  3338. /*
  3339. if(maxProfile.id !=-1)
  3340. {
  3341. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  3342. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3343. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3344. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3345. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3346. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3347. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  3348. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  3349. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3350. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3351. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3352. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3353. {
  3354. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3355. {
  3356. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3357. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3358. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3359. }
  3360. }
  3361. }
  3362. else
  3363. DEBUG_INFO("MaxProfile not found.\n");
  3364. DEBUG_INFO("------------------------------------\n");*/
  3365. }
  3366. if(maxProfile.id != -1)
  3367. {
  3368. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3369. {
  3370. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3371. {
  3372. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  3373. 0:
  3374. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  3375. }
  3376. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3377. {
  3378. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3379. {
  3380. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  3381. 0:
  3382. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  3383. if(idxPeriod > 0)
  3384. {
  3385. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3386. {
  3387. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3388. }
  3389. }
  3390. }
  3391. }
  3392. }
  3393. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3394. {
  3395. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3396. {
  3397. maxProfile.chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
  3398. }
  3399. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3400. {
  3401. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3402. {
  3403. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod;
  3404. if(idxPeriod > 0)
  3405. {
  3406. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3407. {
  3408. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3409. }
  3410. }
  3411. }
  3412. }
  3413. }
  3414. else
  3415. {
  3416. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3417. {
  3418. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3419. {
  3420. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3421. 0:
  3422. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3423. }
  3424. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3425. {
  3426. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3427. {
  3428. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3429. 0:
  3430. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3431. if(idxPeriod > 0)
  3432. {
  3433. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3434. {
  3435. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3436. }
  3437. }
  3438. }
  3439. }
  3440. }
  3441. else
  3442. {
  3443. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3444. {
  3445. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3446. 0:
  3447. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3448. }
  3449. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3450. {
  3451. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3452. {
  3453. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3454. 0:
  3455. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3456. if(idxPeriod > 0)
  3457. {
  3458. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3459. {
  3460. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3461. }
  3462. }
  3463. }
  3464. }
  3465. }
  3466. }
  3467. /*
  3468. DEBUG_INFO("MaxProfile after align.\n");
  3469. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  3470. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3471. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3472. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3473. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3474. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3475. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  3476. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3477. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3478. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3479. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3480. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3481. {
  3482. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3483. {
  3484. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3485. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3486. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3487. }
  3488. }
  3489. DEBUG_INFO("------------------------------------\n");*/
  3490. }
  3491. // Find each profile period quantity
  3492. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  3493. {
  3494. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  3495. limitMax = idx+1;
  3496. }
  3497. if(maxProfile.id != -1)
  3498. {
  3499. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3500. {
  3501. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3502. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3503. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  3504. {
  3505. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3506. {
  3507. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3508. compositePeriodIdx++;
  3509. }
  3510. else
  3511. {
  3512. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3513. }
  3514. }
  3515. }
  3516. }
  3517. DEBUG_INFO("ChargePointMaxProfile ready.\n");
  3518. DEBUG_INFO("Schedule start: %s\n", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  3519. DEBUG_INFO("Schedule duration: %d\n", compositeProfile.chargingSchedule[idxSchedule].duration);
  3520. DEBUG_INFO("Rate unit: %s\n", compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit);
  3521. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3522. {
  3523. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  3524. {
  3525. compositeProfile.id = 1;
  3526. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  3527. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  3528. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  3529. }
  3530. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  3531. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  3532. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  3533. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  3534. }
  3535. memcpy(targetCompositeProfile, &compositeProfile, sizeof(struct StructChargingProfile));
  3536. if(line)
  3537. free(line);
  3538. }
  3539. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *targetCompositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  3540. {
  3541. FILE *fp;
  3542. char profileFileName[128];
  3543. char *line = NULL;
  3544. size_t len = 0;
  3545. time_t CurrentTime;
  3546. struct tm *tmComposite;
  3547. struct ChargingProfileType maxProfile;
  3548. struct ChargingProfileType defaultTxProfile;
  3549. struct ChargingProfileType txProfile;
  3550. struct ChargingProfileType compositeProfile;
  3551. struct ChargingSchedulePeriodType tmpPeriod;
  3552. uint8_t limitMax=0;
  3553. uint8_t limitDef=0;
  3554. uint8_t limitTx=0;
  3555. int compositePeriodIdx = 0;
  3556. CurrentTime = time(NULL);
  3557. tmComposite=localtime(&CurrentTime);
  3558. 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);
  3559. if(isUnitA)
  3560. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3561. else
  3562. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3563. compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
  3564. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3565. {
  3566. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3567. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3568. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3569. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  3570. }
  3571. compositeProfile.id = 0;
  3572. compositeProfile.stackLevel = 99 ;
  3573. sprintf((char*)compositeProfile.chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  3574. maxProfile.id = -1;
  3575. defaultTxProfile.id = -1;
  3576. txProfile.id = -1;
  3577. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  3578. defaultTxProfile.chargingSchedule[idxSchedule].duration = -1;
  3579. txProfile.chargingSchedule[idxSchedule].duration = -1;
  3580. system("rm -f /tmp/*.json");
  3581. system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
  3582. /*
  3583. * Search valid charging profile
  3584. */
  3585. //DEBUG_INFO("====================================\n");
  3586. // Search tx profile
  3587. sprintf(profileFileName, "/tmp/TxProfile_%d_OCPP20.json", connectorId);
  3588. if((access(profileFileName, F_OK))!=-1)
  3589. {
  3590. fp = fopen(profileFileName, "r");
  3591. while(getline(&line, &len, fp) != -1)
  3592. {
  3593. json_object *obj = NULL;
  3594. obj = json_tokener_parse(line);
  3595. if(is_error(obj))
  3596. {
  3597. DEBUG_ERROR("Parse txProfile from file error.\n");
  3598. }
  3599. else
  3600. {
  3601. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != txProfile.id) &&
  3602. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= txProfile.stackLevel)
  3603. )
  3604. {
  3605. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  3606. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3607. )
  3608. {
  3609. struct tm tmFrom, tmTo;
  3610. struct timeb tbFrom, tbTo;
  3611. 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) &&
  3612. (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))
  3613. {
  3614. tmFrom.tm_year -= 1900;
  3615. tmFrom.tm_mon -= 1;
  3616. tbFrom.time = mktime(&tmFrom);
  3617. tmTo.tm_year -= 1900;
  3618. tmTo.tm_mon -= 1;
  3619. tbTo.time = mktime(&tmTo);
  3620. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3621. {
  3622. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3623. {
  3624. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3625. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3626. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3627. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3628. }
  3629. txProfile.id = -1;
  3630. txProfile.stackLevel = -1;
  3631. if(txProfile.id == -1)
  3632. DEBUG_INFO("TxProfile found.\n");
  3633. else
  3634. DEBUG_INFO("TxProfile updated.\n");
  3635. // Required item
  3636. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3637. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3638. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3639. if(isUnitA)
  3640. {
  3641. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3642. 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++)
  3643. {
  3644. 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"));
  3645. 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?
  3646. 3:
  3647. 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")));
  3648. 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")));
  3649. }
  3650. }
  3651. else
  3652. {
  3653. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3654. 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++)
  3655. {
  3656. 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"));
  3657. 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?
  3658. 3:
  3659. 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")));
  3660. 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));
  3661. }
  3662. }
  3663. // Optional item
  3664. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3665. {
  3666. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3667. }
  3668. else
  3669. {
  3670. sprintf((char*)txProfile.validFrom, " ");
  3671. }
  3672. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3673. {
  3674. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3675. }
  3676. else
  3677. {
  3678. sprintf((char*)txProfile.validTo, " ");
  3679. }
  3680. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3681. {
  3682. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3683. }
  3684. else
  3685. {
  3686. sprintf((char*)txProfile.recurrencyKind, " ");
  3687. }
  3688. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3689. {
  3690. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3691. }
  3692. else
  3693. {
  3694. sprintf((char*)txProfile.transactionId, " ");
  3695. }
  3696. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  3697. {
  3698. txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  3699. }
  3700. else
  3701. {
  3702. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  3703. }
  3704. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  3705. {
  3706. 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")));
  3707. }
  3708. else
  3709. {
  3710. 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));
  3711. }
  3712. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  3713. {
  3714. txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  3715. }
  3716. else
  3717. {
  3718. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3719. }
  3720. }
  3721. }
  3722. }
  3723. else
  3724. {
  3725. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3726. {
  3727. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3728. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3729. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3730. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3731. }
  3732. txProfile.id = -1;
  3733. txProfile.stackLevel = -1;
  3734. if(txProfile.id == -1)
  3735. DEBUG_INFO("TxProfile found.\n");
  3736. else
  3737. DEBUG_INFO("TxProfile updated.\n");
  3738. // Required item
  3739. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3740. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3741. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3742. if(isUnitA)
  3743. {
  3744. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3745. 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++)
  3746. {
  3747. 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"));
  3748. 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?
  3749. 3:
  3750. 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")));
  3751. 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")));
  3752. }
  3753. }
  3754. else
  3755. {
  3756. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3757. 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++)
  3758. {
  3759. 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"));
  3760. 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?
  3761. 3:
  3762. 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")));
  3763. 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));
  3764. }
  3765. }
  3766. // Optional item
  3767. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3768. {
  3769. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3770. }
  3771. else
  3772. {
  3773. sprintf((char*)txProfile.validFrom, " ");
  3774. }
  3775. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3776. {
  3777. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3778. }
  3779. else
  3780. {
  3781. sprintf((char*)txProfile.validTo, " ");
  3782. }
  3783. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3784. {
  3785. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3786. }
  3787. else
  3788. {
  3789. sprintf((char*)txProfile.recurrencyKind, " ");
  3790. }
  3791. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3792. {
  3793. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3794. }
  3795. else
  3796. {
  3797. sprintf((char*)txProfile.transactionId, " ");
  3798. }
  3799. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  3800. {
  3801. txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  3802. }
  3803. else
  3804. {
  3805. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  3806. }
  3807. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  3808. {
  3809. 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")));
  3810. }
  3811. else
  3812. {
  3813. 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));
  3814. }
  3815. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  3816. {
  3817. txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  3818. }
  3819. else
  3820. {
  3821. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3822. }
  3823. }
  3824. }
  3825. }
  3826. json_object_put(obj);
  3827. }
  3828. fclose(fp);
  3829. /*
  3830. if(txProfile.id != -1)
  3831. {
  3832. DEBUG_INFO("Profile ID: %d\n", txProfile.id);
  3833. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3834. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3835. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3836. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3837. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3838. DEBUG_INFO("Profile recurrencyKind: %s\n", txProfile.recurrencyKind);
  3839. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[idxSchedule].StartSchedule);
  3840. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  3841. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3842. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3843. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3844. {
  3845. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3846. {
  3847. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3848. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3849. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3850. }
  3851. }
  3852. }
  3853. else
  3854. DEBUG_INFO("TxProfile not found.\n");*/
  3855. }
  3856. // Search default tx profile
  3857. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d_OCPP20.json", connectorId);
  3858. if((access(profileFileName, F_OK))==-1)
  3859. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  3860. if((access(profileFileName, F_OK))!=-1)
  3861. {
  3862. fp = fopen(profileFileName, "r");
  3863. while(getline(&line, &len, fp) != -1)
  3864. {
  3865. json_object *obj = NULL;
  3866. obj = json_tokener_parse(line);
  3867. if(is_error(obj))
  3868. {
  3869. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  3870. }
  3871. else
  3872. {
  3873. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != defaultTxProfile.id) &&
  3874. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= defaultTxProfile.stackLevel)
  3875. )
  3876. {
  3877. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  3878. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3879. )
  3880. {
  3881. struct tm tmFrom, tmTo;
  3882. struct timeb tbFrom, tbTo;
  3883. 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) &&
  3884. (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))
  3885. {
  3886. tmFrom.tm_year -= 1900;
  3887. tmFrom.tm_mon -= 1;
  3888. tbFrom.time = mktime(&tmFrom);
  3889. tmTo.tm_year -= 1900;
  3890. tmTo.tm_mon -= 1;
  3891. tbTo.time = mktime(&tmTo);
  3892. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3893. {
  3894. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3895. {
  3896. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3897. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3898. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3899. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3900. }
  3901. defaultTxProfile.id = -1;
  3902. defaultTxProfile.stackLevel = -1;
  3903. if(defaultTxProfile.id == -1)
  3904. DEBUG_INFO("TxDefaultProfile found.\n");
  3905. else
  3906. DEBUG_INFO("TxDefaultProfile updated.\n");
  3907. // Required item
  3908. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3909. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3910. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3911. if(isUnitA)
  3912. {
  3913. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3914. 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++)
  3915. {
  3916. 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"));
  3917. 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?
  3918. 3:
  3919. 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")));
  3920. 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")));
  3921. }
  3922. }
  3923. else
  3924. {
  3925. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3926. 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++)
  3927. {
  3928. 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"));
  3929. 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?
  3930. 3:
  3931. 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")));
  3932. 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));
  3933. }
  3934. }
  3935. // Optional item
  3936. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3937. {
  3938. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3939. }
  3940. else
  3941. {
  3942. sprintf((char*)defaultTxProfile.validFrom, " ");
  3943. }
  3944. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3945. {
  3946. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3947. }
  3948. else
  3949. {
  3950. sprintf((char*)defaultTxProfile.validTo, " ");
  3951. }
  3952. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3953. {
  3954. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3955. }
  3956. else
  3957. {
  3958. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3959. }
  3960. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3961. {
  3962. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3963. }
  3964. else
  3965. {
  3966. sprintf((char*)defaultTxProfile.transactionId, " ");
  3967. }
  3968. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  3969. {
  3970. defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  3971. }
  3972. else
  3973. {
  3974. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3975. }
  3976. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  3977. {
  3978. 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")));
  3979. }
  3980. else
  3981. {
  3982. 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));
  3983. }
  3984. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  3985. {
  3986. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  3987. }
  3988. else
  3989. {
  3990. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3991. }
  3992. }
  3993. }
  3994. }
  3995. else
  3996. {
  3997. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3998. {
  3999. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4000. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4001. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4002. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  4003. }
  4004. defaultTxProfile.id = -1;
  4005. defaultTxProfile.stackLevel = -1;
  4006. if(defaultTxProfile.id == -1)
  4007. DEBUG_INFO("TxDefaultProfile found.\n");
  4008. else
  4009. DEBUG_INFO("TxDefaultProfile updated.\n");
  4010. // Required item
  4011. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4012. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4013. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4014. if(isUnitA)
  4015. {
  4016. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4017. 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++)
  4018. {
  4019. 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"));
  4020. 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?
  4021. 3:
  4022. 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")));
  4023. 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")));
  4024. }
  4025. }
  4026. else
  4027. {
  4028. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4029. 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++)
  4030. {
  4031. 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"));
  4032. 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?
  4033. 3:
  4034. 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")));
  4035. 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));
  4036. }
  4037. }
  4038. // Optional item
  4039. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4040. {
  4041. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4042. }
  4043. else
  4044. {
  4045. sprintf((char*)defaultTxProfile.validFrom, " ");
  4046. }
  4047. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4048. {
  4049. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4050. }
  4051. else
  4052. {
  4053. sprintf((char*)defaultTxProfile.validTo, " ");
  4054. }
  4055. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4056. {
  4057. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4058. }
  4059. else
  4060. {
  4061. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  4062. }
  4063. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4064. {
  4065. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4066. }
  4067. else
  4068. {
  4069. sprintf((char*)defaultTxProfile.transactionId, " ");
  4070. }
  4071. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  4072. {
  4073. defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  4074. }
  4075. else
  4076. {
  4077. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4078. }
  4079. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  4080. {
  4081. 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")));
  4082. }
  4083. else
  4084. {
  4085. 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));
  4086. }
  4087. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  4088. {
  4089. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  4090. }
  4091. else
  4092. {
  4093. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4094. }
  4095. }
  4096. }
  4097. }
  4098. json_object_put(obj);
  4099. }
  4100. fclose(fp);
  4101. /*
  4102. if(defaultTxProfile.id != -1)
  4103. {
  4104. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.id);
  4105. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  4106. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  4107. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  4108. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  4109. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  4110. DEBUG_INFO("Profile recurrencyKind: %s\n", defaultTxProfile.recurrencyKind);
  4111. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].StartSchedule);
  4112. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  4113. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4114. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4115. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4116. {
  4117. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4118. {
  4119. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4120. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4121. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4122. }
  4123. }
  4124. }
  4125. else
  4126. DEBUG_INFO("TxDefaultProfile not found.\n");
  4127. DEBUG_INFO("------------------------------------\n");*/
  4128. }
  4129. // Search max profile
  4130. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  4131. if((access(profileFileName, F_OK))!=-1)
  4132. {
  4133. fp = fopen(profileFileName, "r");
  4134. while(getline(&line, &len, fp) != -1)
  4135. {
  4136. json_object *obj = NULL;
  4137. obj = json_tokener_parse(line);
  4138. if(is_error(obj))
  4139. {
  4140. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  4141. }
  4142. else
  4143. {
  4144. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != maxProfile.id) &&
  4145. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= maxProfile.stackLevel)
  4146. )
  4147. {
  4148. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  4149. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4150. )
  4151. {
  4152. struct tm tmFrom, tmTo;
  4153. struct timeb tbFrom, tbTo;
  4154. 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) &&
  4155. (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))
  4156. {
  4157. tmFrom.tm_year -= 1900;
  4158. tmFrom.tm_mon -= 1;
  4159. tbFrom.time = mktime(&tmFrom);
  4160. tmTo.tm_year -= 1900;
  4161. tmTo.tm_mon -= 1;
  4162. tbTo.time = mktime(&tmTo);
  4163. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  4164. {
  4165. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4166. {
  4167. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4168. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4169. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4170. }
  4171. maxProfile.id = -1;
  4172. maxProfile.stackLevel = -1;
  4173. if(maxProfile.id == -1)
  4174. DEBUG_INFO("MaxProfile found.\n");
  4175. else
  4176. DEBUG_INFO("MaxProfile updated.\n");
  4177. // Required item
  4178. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4179. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4180. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4181. if(isUnitA)
  4182. {
  4183. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4184. 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++)
  4185. {
  4186. 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"));
  4187. 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?
  4188. 3:
  4189. 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")));
  4190. 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")));
  4191. }
  4192. }
  4193. else
  4194. {
  4195. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4196. 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++)
  4197. {
  4198. 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"));
  4199. 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?
  4200. 3:
  4201. 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")));
  4202. 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));
  4203. }
  4204. }
  4205. // Optional item
  4206. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4207. {
  4208. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4209. }
  4210. else
  4211. {
  4212. sprintf((char*)maxProfile.validFrom, " ");
  4213. }
  4214. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4215. {
  4216. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4217. }
  4218. else
  4219. {
  4220. sprintf((char*)maxProfile.validTo, " ");
  4221. }
  4222. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4223. {
  4224. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4225. }
  4226. else
  4227. {
  4228. sprintf((char*)maxProfile.recurrencyKind, " ");
  4229. }
  4230. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4231. {
  4232. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4233. }
  4234. else
  4235. {
  4236. sprintf((char*)maxProfile.transactionId, " ");
  4237. }
  4238. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  4239. {
  4240. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  4241. }
  4242. else
  4243. {
  4244. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4245. }
  4246. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  4247. {
  4248. 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")));
  4249. }
  4250. else
  4251. {
  4252. 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));
  4253. }
  4254. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  4255. {
  4256. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  4257. }
  4258. else
  4259. {
  4260. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4261. }
  4262. }
  4263. }
  4264. }
  4265. else
  4266. {
  4267. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4268. {
  4269. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4270. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4271. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4272. }
  4273. maxProfile.id = -1;
  4274. maxProfile.stackLevel = -1;
  4275. if(maxProfile.id == -1)
  4276. DEBUG_INFO("MaxProfile found.\n");
  4277. else
  4278. DEBUG_INFO("MaxProfile updated.\n");
  4279. // Required item
  4280. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4281. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4282. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4283. if(isUnitA)
  4284. {
  4285. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4286. 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++)
  4287. {
  4288. 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"));
  4289. 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?
  4290. 3:
  4291. 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")));
  4292. 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")));
  4293. }
  4294. }
  4295. else
  4296. {
  4297. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4298. 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++)
  4299. {
  4300. 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"));
  4301. 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?
  4302. 3:
  4303. 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")));
  4304. 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));
  4305. }
  4306. }
  4307. // Optional item
  4308. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4309. {
  4310. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4311. }
  4312. else
  4313. {
  4314. sprintf((char*)maxProfile.validFrom, " ");
  4315. }
  4316. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4317. {
  4318. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4319. }
  4320. else
  4321. {
  4322. sprintf((char*)maxProfile.validTo, " ");
  4323. }
  4324. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4325. {
  4326. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4327. }
  4328. else
  4329. {
  4330. sprintf((char*)maxProfile.recurrencyKind, " ");
  4331. }
  4332. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4333. {
  4334. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4335. }
  4336. else
  4337. {
  4338. sprintf((char*)maxProfile.transactionId, " ");
  4339. }
  4340. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
  4341. {
  4342. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "duration"));
  4343. }
  4344. else
  4345. {
  4346. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4347. }
  4348. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
  4349. {
  4350. 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")));
  4351. }
  4352. else
  4353. {
  4354. 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));
  4355. }
  4356. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
  4357. {
  4358. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
  4359. }
  4360. else
  4361. {
  4362. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4363. }
  4364. }
  4365. }
  4366. }
  4367. json_object_put(obj);
  4368. }
  4369. fclose(fp);
  4370. /*
  4371. if(maxProfile.id !=-1)
  4372. {
  4373. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  4374. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  4375. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  4376. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  4377. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  4378. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  4379. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  4380. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  4381. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  4382. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4383. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4384. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4385. {
  4386. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4387. {
  4388. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4389. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4390. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4391. }
  4392. }
  4393. }
  4394. else
  4395. DEBUG_INFO("MaxProfile not found.\n");
  4396. DEBUG_INFO("------------------------------------\n");*/
  4397. }
  4398. /*
  4399. * Align found profile start schedule & periods
  4400. */
  4401. //DEBUG_INFO("====================================\n");
  4402. /*
  4403. // For local test usage, force modify found profile start schedule info
  4404. 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);
  4405. 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);
  4406. 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);
  4407. */
  4408. if(txProfile.id != -1)
  4409. {
  4410. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4411. {
  4412. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4413. {
  4414. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4415. 0:
  4416. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4417. }
  4418. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4419. {
  4420. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4421. {
  4422. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4423. 0:
  4424. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4425. if(idxPeriod > 0)
  4426. {
  4427. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4428. {
  4429. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4430. }
  4431. }
  4432. }
  4433. }
  4434. }
  4435. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4436. {
  4437. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4438. {
  4439. 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?
  4440. 0:
  4441. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4442. }
  4443. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4444. {
  4445. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4446. {
  4447. 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?
  4448. 0:
  4449. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4450. if(idxPeriod > 0)
  4451. {
  4452. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4453. {
  4454. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4455. }
  4456. }
  4457. }
  4458. }
  4459. }
  4460. else
  4461. {
  4462. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4463. {
  4464. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4465. {
  4466. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4467. 0:
  4468. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4469. }
  4470. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4471. {
  4472. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4473. {
  4474. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4475. 0:
  4476. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4477. if(idxPeriod > 0)
  4478. {
  4479. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4480. {
  4481. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4482. }
  4483. }
  4484. }
  4485. }
  4486. }
  4487. else
  4488. {
  4489. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4490. {
  4491. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4492. 0:
  4493. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4494. }
  4495. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4496. {
  4497. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4498. {
  4499. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4500. 0:
  4501. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4502. if(idxPeriod > 0)
  4503. {
  4504. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4505. {
  4506. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4507. }
  4508. }
  4509. }
  4510. }
  4511. }
  4512. }
  4513. /*
  4514. DEBUG_INFO("txProfile after align.\n");
  4515. DEBUG_INFO("Profile ID: %d\n", txProfile.id);
  4516. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  4517. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  4518. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  4519. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  4520. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  4521. DEBUG_INFO("Profile recurrencyKind: %s\n", txProfile.recurrencyKind);
  4522. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  4523. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  4524. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4525. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4526. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4527. {
  4528. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4529. {
  4530. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4531. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4532. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4533. }
  4534. }*/
  4535. }
  4536. if(defaultTxProfile.id != -1)
  4537. {
  4538. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4539. {
  4540. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4541. {
  4542. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4543. 0:
  4544. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4545. }
  4546. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4547. {
  4548. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4549. {
  4550. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4551. 0:
  4552. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4553. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4554. {
  4555. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4556. }
  4557. if(idxPeriod > 0)
  4558. {
  4559. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4560. {
  4561. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4562. }
  4563. }
  4564. }
  4565. }
  4566. }
  4567. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4568. {
  4569. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4570. {
  4571. 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?
  4572. 0:
  4573. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4574. }
  4575. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4576. {
  4577. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4578. {
  4579. 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?
  4580. 0:
  4581. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4582. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4583. {
  4584. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4585. }
  4586. if(idxPeriod > 0)
  4587. {
  4588. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4589. {
  4590. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4591. }
  4592. }
  4593. }
  4594. }
  4595. }
  4596. else
  4597. {
  4598. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4599. {
  4600. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4601. {
  4602. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4603. 0:
  4604. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4605. }
  4606. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4607. {
  4608. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4609. {
  4610. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4611. 0:
  4612. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4613. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4614. {
  4615. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4616. }
  4617. if(idxPeriod > 0)
  4618. {
  4619. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4620. {
  4621. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4622. }
  4623. }
  4624. }
  4625. }
  4626. }
  4627. else
  4628. {
  4629. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4630. {
  4631. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4632. 0:
  4633. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4634. }
  4635. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4636. {
  4637. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4638. {
  4639. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4640. 0:
  4641. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4642. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4643. {
  4644. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4645. }
  4646. if(idxPeriod > 0)
  4647. {
  4648. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4649. {
  4650. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4651. }
  4652. }
  4653. }
  4654. }
  4655. }
  4656. }
  4657. /*
  4658. DEBUG_INFO("defaultTxProfile after align.\n");
  4659. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.id);
  4660. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  4661. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  4662. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  4663. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  4664. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  4665. DEBUG_INFO("Profile recurrencyKind: %s\n", defaultTxProfile.recurrencyKind);
  4666. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  4667. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  4668. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4669. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4670. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4671. {
  4672. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4673. {
  4674. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4675. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4676. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4677. }
  4678. }
  4679. DEBUG_INFO("------------------------------------\n");*/
  4680. }
  4681. if(maxProfile.id != -1)
  4682. {
  4683. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4684. {
  4685. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4686. {
  4687. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4688. 0:
  4689. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4690. }
  4691. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4692. {
  4693. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4694. {
  4695. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4696. 0:
  4697. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4698. if(idxPeriod > 0)
  4699. {
  4700. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4701. {
  4702. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4703. }
  4704. }
  4705. }
  4706. }
  4707. }
  4708. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4709. {
  4710. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4711. {
  4712. 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?
  4713. 0:
  4714. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[9].startSchedule)));
  4715. }
  4716. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4717. {
  4718. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4719. {
  4720. 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?
  4721. 0:
  4722. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4723. if(idxPeriod > 0)
  4724. {
  4725. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4726. {
  4727. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4728. }
  4729. }
  4730. }
  4731. }
  4732. }
  4733. else
  4734. {
  4735. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4736. {
  4737. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4738. {
  4739. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4740. 0:
  4741. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4742. }
  4743. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4744. {
  4745. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4746. {
  4747. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4748. 0:
  4749. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4750. if(idxPeriod > 0)
  4751. {
  4752. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4753. {
  4754. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4755. }
  4756. }
  4757. }
  4758. }
  4759. }
  4760. else
  4761. {
  4762. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4763. {
  4764. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4765. 0:
  4766. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4767. }
  4768. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4769. {
  4770. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4771. {
  4772. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4773. 0:
  4774. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4775. if(idxPeriod > 0)
  4776. {
  4777. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4778. {
  4779. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4780. }
  4781. }
  4782. }
  4783. }
  4784. }
  4785. }
  4786. /*
  4787. DEBUG_INFO("MaxProfile after align.\n");
  4788. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  4789. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  4790. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  4791. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  4792. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  4793. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  4794. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  4795. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  4796. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  4797. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4798. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4799. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4800. {
  4801. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4802. {
  4803. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4804. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4805. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4806. }
  4807. }
  4808. DEBUG_INFO("------------------------------------\n");*/
  4809. }
  4810. /*
  4811. * Merge to conposite schedule
  4812. */
  4813. //DEBUG_INFO("====================================\n");
  4814. // Find each profile period quantity
  4815. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4816. {
  4817. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4818. limitMax = idx+1;
  4819. }
  4820. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4821. {
  4822. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4823. limitDef = idx+1;
  4824. }
  4825. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4826. {
  4827. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4828. limitTx = idx+1;
  4829. }
  4830. // TxProfile found, composite schedule based on it
  4831. if(txProfile.id != -1)
  4832. {
  4833. compositeProfile.chargingSchedule[idxSchedule].duration = txProfile.chargingSchedule[idxSchedule].duration;
  4834. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  4835. {
  4836. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  4837. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  4838. (txProfile.chargingSchedule[idxSchedule].duration > 0))
  4839. {
  4840. if(maxProfile.id != -1)
  4841. {
  4842. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4843. {
  4844. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  4845. {
  4846. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4847. {
  4848. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  4849. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  4850. 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);
  4851. }
  4852. else
  4853. {
  4854. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  4855. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  4856. tmpPeriod.limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit;
  4857. }
  4858. }
  4859. if(idxMaxPeriod == (limitMax-1))
  4860. {
  4861. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4862. {
  4863. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4864. {
  4865. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4866. compositePeriodIdx++;
  4867. }
  4868. else
  4869. {
  4870. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4871. }
  4872. }
  4873. }
  4874. }
  4875. }
  4876. else
  4877. {
  4878. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4879. {
  4880. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  4881. compositePeriodIdx++;
  4882. }
  4883. else
  4884. {
  4885. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  4886. }
  4887. }
  4888. }
  4889. if(idxTxPeriod == (limitTx-1))
  4890. {
  4891. if(defaultTxProfile.id != -1)
  4892. {
  4893. compositeProfile.chargingSchedule[idxSchedule].duration = (defaultTxProfile.chargingSchedule[idxSchedule].duration>compositeProfile.chargingSchedule[idxSchedule].duration)?defaultTxProfile.chargingSchedule[idxSchedule].duration:compositeProfile.chargingSchedule[idxSchedule].duration;
  4894. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  4895. {
  4896. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  4897. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  4898. (defaultTxProfile.chargingSchedule[idxSchedule].duration>0))
  4899. {
  4900. if(maxProfile.id != -1)
  4901. {
  4902. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4903. {
  4904. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  4905. {
  4906. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4907. {
  4908. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4909. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4910. 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);
  4911. }
  4912. else
  4913. {
  4914. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4915. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4916. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  4917. }
  4918. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4919. {
  4920. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4921. {
  4922. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4923. compositePeriodIdx++;
  4924. }
  4925. else
  4926. {
  4927. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4928. }
  4929. }
  4930. // Delete duplicate period
  4931. if(compositePeriodIdx > 1)
  4932. {
  4933. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  4934. {
  4935. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  4936. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  4937. compositePeriodIdx -= 1;
  4938. }
  4939. }
  4940. }
  4941. else
  4942. {
  4943. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4944. {
  4945. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4946. compositePeriodIdx++;
  4947. }
  4948. else
  4949. {
  4950. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4951. }
  4952. break;
  4953. }
  4954. }
  4955. }
  4956. else
  4957. {
  4958. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4959. {
  4960. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4961. compositePeriodIdx++;
  4962. }
  4963. else
  4964. {
  4965. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4966. }
  4967. }
  4968. }
  4969. }
  4970. }
  4971. }
  4972. }
  4973. }
  4974. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  4975. else if(defaultTxProfile.id != -1)
  4976. {
  4977. compositeProfile.chargingSchedule[idxSchedule].duration = defaultTxProfile.chargingSchedule[idxSchedule].duration;
  4978. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  4979. {
  4980. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  4981. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  4982. (defaultTxProfile.chargingSchedule[idxSchedule].duration > 0))
  4983. {
  4984. if(maxProfile.id != -1)
  4985. {
  4986. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4987. {
  4988. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  4989. {
  4990. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4991. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4992. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4993. {
  4994. 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);
  4995. }
  4996. else
  4997. {
  4998. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  4999. }
  5000. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  5001. {
  5002. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5003. {
  5004. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5005. compositePeriodIdx++;
  5006. }
  5007. else
  5008. {
  5009. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5010. }
  5011. }
  5012. // Delete duplicate period
  5013. if(compositePeriodIdx > 1)
  5014. {
  5015. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  5016. {
  5017. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  5018. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  5019. compositePeriodIdx -= 1;
  5020. }
  5021. }
  5022. }
  5023. else
  5024. {
  5025. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5026. {
  5027. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5028. compositePeriodIdx++;
  5029. }
  5030. else
  5031. {
  5032. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5033. }
  5034. break;
  5035. }
  5036. }
  5037. }
  5038. else
  5039. {
  5040. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5041. {
  5042. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5043. compositePeriodIdx++;
  5044. }
  5045. else
  5046. {
  5047. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5048. }
  5049. }
  5050. }
  5051. }
  5052. }
  5053. // Fill other period by MaxProfile
  5054. if(maxProfile.id != -1)
  5055. {
  5056. if(compositePeriodIdx==0)
  5057. {
  5058. compositeProfile.chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
  5059. for(int idxMaxPeriod=0;idxMaxPeriod<limitDef;idxMaxPeriod++)
  5060. {
  5061. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  5062. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  5063. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5064. {
  5065. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5066. {
  5067. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
  5068. compositePeriodIdx++;
  5069. }
  5070. else
  5071. {
  5072. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
  5073. }
  5074. }
  5075. }
  5076. }
  5077. else
  5078. {
  5079. int lastCompositePeriodIdx = compositePeriodIdx;
  5080. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  5081. {
  5082. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  5083. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  5084. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5085. {
  5086. if((maxProfile.chargingSchedule[idxSchedule].duration >= compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod))
  5087. {
  5088. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit > compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit)
  5089. {
  5090. tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
  5091. tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  5092. tmpPeriod.limit = compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit;
  5093. }
  5094. else
  5095. {
  5096. tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
  5097. tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  5098. tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
  5099. }
  5100. }
  5101. if(tmpPeriod.limit != -1)
  5102. {
  5103. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].limit)
  5104. {
  5105. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].startPeriod)
  5106. {
  5107. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5108. compositePeriodIdx++;
  5109. }
  5110. else
  5111. {
  5112. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5113. }
  5114. }
  5115. // Delete duplicate period
  5116. if(compositePeriodIdx > 1)
  5117. {
  5118. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  5119. {
  5120. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  5121. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  5122. compositePeriodIdx -= 1;
  5123. }
  5124. }
  5125. }
  5126. }
  5127. }
  5128. }
  5129. }
  5130. compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
  5131. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  5132. DEBUG_INFO("Schedule start: %s\n", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  5133. DEBUG_INFO("Schedule duration: %d\n", compositeProfile.chargingSchedule[idxSchedule].duration);
  5134. DEBUG_INFO("Rate unit: %s\n", compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit);
  5135. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5136. {
  5137. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  5138. {
  5139. compositeProfile.id = 1;
  5140. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  5141. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  5142. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  5143. }
  5144. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  5145. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  5146. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  5147. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  5148. }
  5149. memcpy(targetCompositeProfile, &compositeProfile, sizeof(struct StructChargingProfile));
  5150. if(line)
  5151. free(line);
  5152. checkChargePointMaxProfile(durationReq, &ShmOCPP20Data->MaxChargingProfile, idxSchedule, isUnitA);
  5153. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  5154. }
  5155. //==========================================
  5156. // Init all share memory
  5157. //==========================================
  5158. int InitShareMemory()
  5159. {
  5160. int result = PASS;
  5161. int MeterSMId;
  5162. //creat ShmSysConfigAndInfo
  5163. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  5164. {
  5165. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  5166. result = FAIL;
  5167. }
  5168. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5169. {
  5170. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  5171. result = FAIL;
  5172. }
  5173. else
  5174. {}
  5175. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  5176. {
  5177. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  5178. result = FAIL;
  5179. }
  5180. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5181. {
  5182. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  5183. result = FAIL;
  5184. }
  5185. else
  5186. {}
  5187. //creat ShmPsuData
  5188. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  5189. {
  5190. DEBUG_ERROR("shmget ShmPsuData NG\n");
  5191. result = FAIL;
  5192. }
  5193. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5194. {
  5195. DEBUG_ERROR("shmat ShmPsuData NG\n");
  5196. result = FAIL;
  5197. }
  5198. else
  5199. {}
  5200. //creat ShmOCPP20Data
  5201. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  5202. {
  5203. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  5204. result = FAIL;
  5205. }
  5206. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5207. {
  5208. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  5209. result = FAIL;
  5210. }
  5211. else
  5212. {}
  5213. /****************************** For Initial Settings************************************************/
  5214. /*
  5215. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  5216. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  5217. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  5218. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  5219. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  5220. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  5221. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  5222. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  5223. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  5224. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  5225. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  5226. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  5227. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  5228. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  5229. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  5230. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  5231. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  5232. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  5233. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  5234. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  5235. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  5236. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  5237. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  5238. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  5239. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  5240. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  5241. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  5242. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  5243. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  5244. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  5245. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  5246. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  5247. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  5248. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  5249. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  5250. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  5251. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  5252. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  5253. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  5254. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  5255. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  5256. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  5257. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  5258. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  5259. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  5260. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  5261. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  5262. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  5263. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  5264. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  5265. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  5266. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  5267. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  5268. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  5269. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  5270. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  5271. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  5272. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  5273. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  5274. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  5275. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  5276. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  5277. */
  5278. return result;
  5279. }
  5280. int ProcessShareMemory()
  5281. {
  5282. int result = PASS;
  5283. if(InitShareMemory() == FAIL)
  5284. {
  5285. DEBUG_ERROR("InitShareMemory NG\n");
  5286. if(ShmStatusCodeData!=NULL)
  5287. {
  5288. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  5289. }
  5290. result = FAIL;
  5291. }
  5292. if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
  5293. {
  5294. DEBUG_INFO("Model name rated power: %d\n", modelnameInfo.ratedPower);
  5295. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  5296. ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
  5297. (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
  5298. (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
  5299. ) // 'D' means DC
  5300. {
  5301. // DO series
  5302. for(int gun_index=0; gun_index<GENERAL_GUN_QUANTITY ; gun_index++)
  5303. {
  5304. SystemInitial += 1;
  5305. gunTotalNumber += 1;
  5306. gunType[gun_index] = GUN_TYPE_DO;
  5307. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  5308. {
  5309. case Gun_Type_Chademo:
  5310. DEBUG_INFO("Gun-%02d type: Cabinet CHAdeMO\n", gun_index);
  5311. break;
  5312. case Gun_Type_CCS_2:
  5313. DEBUG_INFO("Gun-%02d type: Cabinet CCS\n", gun_index);
  5314. break;
  5315. case Gun_Type_GB:
  5316. DEBUG_INFO("Gun-%02d type: Cabinet GBT\n", gun_index);
  5317. break;
  5318. case Gun_Type_AC:
  5319. DEBUG_INFO("Gun-%02d type: Cabinet AC\n", gun_index);
  5320. break;
  5321. default:
  5322. DEBUG_WARN("Gun-%02d type: Cabinet unknown\n", gun_index);
  5323. break;
  5324. }
  5325. }
  5326. }
  5327. else
  5328. {
  5329. for(int gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
  5330. {
  5331. SystemInitial += 1;
  5332. gunTotalNumber += 1;
  5333. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  5334. {
  5335. case Gun_Type_Chademo:
  5336. gunType[gun_index] = GUN_TYPE_CHAdeMO;
  5337. DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
  5338. break;
  5339. case Gun_Type_CCS_2:
  5340. gunType[gun_index] = GUN_TYPE_CCS;
  5341. DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
  5342. break;
  5343. case Gun_Type_GB:
  5344. gunType[gun_index] = GUN_TYPE_GBT;
  5345. DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
  5346. break;
  5347. case Gun_Type_AC:
  5348. gunType[gun_index] = GUN_TYPE_AC;
  5349. DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
  5350. break;
  5351. default:
  5352. DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
  5353. break;
  5354. }
  5355. }
  5356. }
  5357. }
  5358. else
  5359. {
  5360. DEBUG_ERROR("Model name parsing fail.\n");
  5361. result = FAIL;
  5362. }
  5363. if(result != PASS)sleep(5);
  5364. return result;
  5365. }
  5366. //---------------------common routine---------------------------//
  5367. void checkNetworkProfile(void)
  5368. {
  5369. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  5370. json_object *priority;
  5371. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  5372. if(!is_error(priority))
  5373. {
  5374. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  5375. {
  5376. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  5377. {
  5378. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  5379. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  5380. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  5381. {
  5382. memcpy(ShmOCPP20Data->OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  5383. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  5384. break;
  5385. }
  5386. }
  5387. }
  5388. }
  5389. json_object_put(priority);
  5390. DEBUG_INFO("Get network profile URL: %s\n", ShmOCPP20Data->OcppServerURL);
  5391. }
  5392. void checkRemoteStart(uint8_t connectorIdx)
  5393. {
  5394. uint8_t tempIndex;
  5395. int isAllowStart = TRUE;
  5396. char cmdBuf[512];
  5397. //check Transaction active
  5398. if(gunType[connectorIdx-1] == GUN_TYPE_CHAdeMO)
  5399. {
  5400. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5401. {
  5402. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  5403. }
  5404. else
  5405. {
  5406. tempIndex = (connectorIdx-1);
  5407. }
  5408. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5409. {
  5410. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
  5411. {
  5412. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  5413. {
  5414. //Reserved
  5415. DEBUG_INFO("CHAdeMO connector already reserved and idTag match.\n");
  5416. }
  5417. 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[connectorIdx-1].idToken.idToken) != 0))
  5418. {
  5419. //Reserved
  5420. DEBUG_INFO("CHAdeMO connector already reserved and idTag does not match.\n");
  5421. isAllowStart = FALSE;
  5422. }
  5423. else
  5424. {
  5425. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5426. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) //S_PRECHARGE
  5427. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) //S_PREPARING_FOR_EV
  5428. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE )) // S_PREPARING_FOR_EVSE
  5429. {
  5430. DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n.");
  5431. isAllowStart = FALSE;
  5432. }
  5433. }//END FOR ELSE
  5434. }
  5435. }// END FOR CHAdeMO_QUANTITY
  5436. }
  5437. else if(gunType[connectorIdx-1] == GUN_TYPE_CCS)
  5438. {
  5439. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5440. {
  5441. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  5442. }
  5443. else
  5444. {
  5445. tempIndex = (connectorIdx-1);
  5446. }
  5447. for (int index = 0; index < CCS_QUANTITY; index++)
  5448. {
  5449. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5450. {
  5451. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  5452. {
  5453. //Reserved
  5454. DEBUG_INFO("CCS connector already reserved and idTag match.\n");
  5455. }
  5456. 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[connectorIdx-1].idToken.idToken) != 0))
  5457. {
  5458. //Reserved
  5459. DEBUG_INFO("CCS connector already reserved and idTag does not match.\n");
  5460. isAllowStart = FALSE;
  5461. }
  5462. else
  5463. {
  5464. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5465. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5466. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5467. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5468. {
  5469. DEBUG_WARN("CCS connector not allow start cause busy.\n.");
  5470. isAllowStart = FALSE;
  5471. }
  5472. }// END FOR ELSE
  5473. }
  5474. }// END FOR CCS_QUANTITY
  5475. }
  5476. else if(gunType[connectorIdx-1] == GUN_TYPE_GBT)
  5477. {
  5478. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5479. {
  5480. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  5481. }
  5482. else
  5483. {
  5484. tempIndex = (connectorIdx-1);
  5485. }
  5486. for (int index = 0; index < GB_QUANTITY; index++)
  5487. {
  5488. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
  5489. {
  5490. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  5491. {
  5492. //Reserved
  5493. DEBUG_INFO("GBT connector already reserved and idTag match.\n");
  5494. }
  5495. 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[connectorIdx-1].idToken.idToken) != 0))
  5496. {
  5497. //Reserved
  5498. DEBUG_INFO("GBT connector already reserved and idTag does not match.\n");
  5499. isAllowStart = FALSE;
  5500. }
  5501. else
  5502. {
  5503. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5504. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5505. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5506. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5507. {
  5508. DEBUG_WARN("GBT connector not allow start cause busy.\n");
  5509. isAllowStart = FALSE;
  5510. }
  5511. }// END FOR ELSE
  5512. }
  5513. } // END FOR GB_QUANTITY
  5514. }
  5515. else if(gunType[connectorIdx-1] == GUN_TYPE_DO)
  5516. {
  5517. tempIndex = (connectorIdx-1);
  5518. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5519. {
  5520. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
  5521. {
  5522. 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[connectorIdx-1].idToken.idToken) == 0))
  5523. {
  5524. //Reserved
  5525. DEBUG_INFO("Dispenser connector already reserved and idTag match.\n");
  5526. }
  5527. 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[connectorIdx-1].idToken.idToken) != 0))
  5528. {
  5529. //Reserved
  5530. DEBUG_INFO("Dispenser connector already reserved and idTag does not match.\n");
  5531. isAllowStart = FALSE;
  5532. }
  5533. else
  5534. {
  5535. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5536. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5537. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5538. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5539. {
  5540. DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
  5541. isAllowStart = FALSE;
  5542. }
  5543. }// END FOR ELSE
  5544. }
  5545. } // END FOR GB_QUANTITY
  5546. }
  5547. else
  5548. {
  5549. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  5550. {
  5551. tempIndex = 2;
  5552. }
  5553. else
  5554. {
  5555. tempIndex = (connectorIdx-1);
  5556. }
  5557. for (int index = 0; index < AC_QUANTITY; index++)
  5558. {
  5559. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
  5560. {
  5561. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  5562. {
  5563. //Reserved
  5564. DEBUG_INFO("AC connector already reserved and idTag match.\n");
  5565. }
  5566. 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[connectorIdx-1].idToken.idToken) != 0))
  5567. {
  5568. //Reserved
  5569. DEBUG_INFO("AC connector already reserved and idTag does not match.\n");
  5570. isAllowStart = FALSE;
  5571. }
  5572. else
  5573. {
  5574. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5575. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5576. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5577. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5578. {
  5579. DEBUG_WARN("AC connector not allow start cause busy.\n");
  5580. isAllowStart = FALSE;
  5581. }
  5582. }//END FOR ELSE
  5583. }
  5584. }// END FOR AC_QUANTITY
  5585. }
  5586. if(isAllowStart == TRUE)
  5587. {
  5588. if(ShmOCPP20Data->RequestStartTransaction[connectorIdx -1].chargingProfile.id > 0)
  5589. {
  5590. if((access("/Storage/OCPP/TxProfile_Tmp_OCPP20.json", F_OK))!=-1)
  5591. {
  5592. sprintf(cmdBuf, "mv /Storage/OCPP/TxProfile_Tmp_OCPP20.json /Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdx);
  5593. system(cmdBuf);
  5594. }
  5595. }
  5596. ShmOCPP20Data->CsMsg.bits[connectorIdx-1].RequestStartTransactionReq = ON;
  5597. }
  5598. }
  5599. void CheckSystemValue(void)
  5600. {
  5601. char filenmae[100]={0};
  5602. char str[100]={0};
  5603. int tempIndex = 0;
  5604. //===============================
  5605. // EVSE operation check
  5606. //===============================
  5607. //===============================
  5608. // Heartbeat check
  5609. //===============================
  5610. if((server_sign == TRUE) && (getDiffSecNow(clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  5611. {
  5612. //parameter for test
  5613. sendHeartbeatRequest(0);
  5614. //==============================================
  5615. // Reset Waiting Time
  5616. //==============================================
  5617. HeartBeatWithNOResponse += 1;
  5618. }
  5619. //===============================
  5620. // CSU Trigger Authorize Request
  5621. //===============================
  5622. if(isWebsocketSendable &&
  5623. (server_sign == TRUE) &&
  5624. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  5625. (authorizeRetryTimes < 3))
  5626. {
  5627. sendAuthorizeRequest(0);
  5628. authorizeRetryTimes = authorizeRetryTimes + 1;
  5629. if(authorizeRetryTimes < 3)
  5630. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5631. }
  5632. else if((server_sign == TRUE) &&
  5633. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  5634. (authorizeRetryTimes >= 3))
  5635. {
  5636. authorizeRetryTimes = 0;
  5637. SetOcppConnStatus(FALSE);
  5638. server_sign = FALSE;
  5639. }
  5640. else if((server_sign == FALSE) &&
  5641. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  5642. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  5643. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  5644. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  5645. {
  5646. sendAuthorizeRequest(0);
  5647. }
  5648. if(isWebsocketSendable &&
  5649. (server_sign == TRUE) &&
  5650. (ShmOCPP20Data->GetMonitoringReport.requestId > 0))
  5651. {
  5652. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.monitoringCriteria);idxCriterion++)
  5653. {
  5654. if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_ThresholdMonitoring]) == 0)
  5655. {
  5656. /*
  5657. * TODO:
  5658. * 1. Report component that are ThresholdMonitoring
  5659. */
  5660. }
  5661. else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_DeltaMonitoring]) == 0)
  5662. {
  5663. /*
  5664. * TODO:
  5665. * 1. Report component that are DeltaMonitoring
  5666. */
  5667. }
  5668. else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_PeriodicMonitoring]) == 0)
  5669. {
  5670. /*
  5671. * TODO:
  5672. * 1. Report component that are PeriodicMonitoring
  5673. */
  5674. }
  5675. else
  5676. {
  5677. /*
  5678. * TODO:
  5679. * 1. Process unknown criteria condition
  5680. */
  5681. }
  5682. }
  5683. ShmOCPP20Data->GetMonitoringReport.requestId = 0;
  5684. }
  5685. if(isWebsocketSendable &&
  5686. (server_sign == TRUE) &&
  5687. (ShmOCPP20Data->GetReport.requestId > 0))
  5688. {
  5689. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetReport.componentCriteria);idxCriterion++)
  5690. {
  5691. if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Active]) == 0)
  5692. {
  5693. /*
  5694. * TODO:
  5695. * 1. Report component that are active
  5696. */
  5697. }
  5698. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Available]) == 0)
  5699. {
  5700. /*
  5701. * TODO:
  5702. * 1. Report component that are available
  5703. */
  5704. }
  5705. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Enabled]) == 0)
  5706. {
  5707. /*
  5708. * TODO:
  5709. * 1. Report component that are enable
  5710. */
  5711. }
  5712. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Problem]) == 0)
  5713. {
  5714. /*
  5715. * TODO:
  5716. * 1. Report component that are problem
  5717. */
  5718. }
  5719. else
  5720. {
  5721. /*
  5722. * TODO:
  5723. * 1. Process unknown criteria condition
  5724. */
  5725. }
  5726. }
  5727. ShmOCPP20Data->GetReport.requestId = 0;
  5728. }
  5729. if(isWebsocketSendable &&
  5730. (server_sign == TRUE) &&
  5731. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  5732. {
  5733. uint8_t reportIdx = 0;
  5734. ShmOCPP20Data->NotifyReport.requestId = ShmOCPP20Data->GetBaseReport.requestId;
  5735. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  5736. {
  5737. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  5738. {
  5739. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  5740. {
  5741. 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))
  5742. {
  5743. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  5744. reportIdx++;
  5745. }
  5746. }
  5747. else
  5748. {
  5749. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  5750. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  5751. ShmOCPP20Data->NotifyReport.seqNo += 1;
  5752. else
  5753. ShmOCPP20Data->NotifyReport.seqNo = 0;
  5754. sendNotifyReportRequest();
  5755. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  5756. reportIdx = 0;
  5757. }
  5758. }
  5759. }
  5760. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  5761. {
  5762. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  5763. {
  5764. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  5765. {
  5766. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  5767. reportIdx++;
  5768. }
  5769. else
  5770. {
  5771. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  5772. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  5773. ShmOCPP20Data->NotifyReport.seqNo += 1;
  5774. else
  5775. ShmOCPP20Data->NotifyReport.seqNo = 0;
  5776. sendNotifyReportRequest();
  5777. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  5778. reportIdx = 0;
  5779. }
  5780. }
  5781. }
  5782. else
  5783. {
  5784. /*
  5785. * TODO:
  5786. * 1. Fill out summary inventory to response message, currently not support
  5787. */
  5788. }
  5789. if(reportIdx > 0)
  5790. {
  5791. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  5792. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  5793. ShmOCPP20Data->NotifyReport.seqNo += 1;
  5794. else
  5795. ShmOCPP20Data->NotifyReport.seqNo = 0;
  5796. sendNotifyReportRequest();
  5797. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  5798. reportIdx = 0;
  5799. }
  5800. ShmOCPP20Data->GetBaseReport.requestId = 0;
  5801. }
  5802. if(isWebsocketSendable &&
  5803. (server_sign == TRUE) &&
  5804. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  5805. {
  5806. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  5807. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  5808. if(ShmOCPP20Data->NotifyEvent.seqNo < INT_MAX)
  5809. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  5810. else
  5811. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  5812. sendNotifyEventRequest();
  5813. memset(&ShmOCPP20Data->NotifyEvent.eventData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)* sizeof(struct EventDataType ));
  5814. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  5815. }
  5816. if(isWebsocketSendable &&
  5817. (server_sign == TRUE) &&
  5818. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq)
  5819. {
  5820. if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Install]) == 0)
  5821. {
  5822. /*
  5823. * TODO:
  5824. * 1.
  5825. */
  5826. }
  5827. else if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Update]) == 0)
  5828. {
  5829. /*
  5830. * TODO:
  5831. * 1.
  5832. */
  5833. }
  5834. else
  5835. {
  5836. /*
  5837. * TODO:
  5838. * 1.
  5839. */
  5840. }
  5841. sendGet15118EVCertificateRequest();
  5842. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  5843. }
  5844. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  5845. {
  5846. // ClockAlign MeterValue
  5847. 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))
  5848. {
  5849. //check Transaction active
  5850. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5851. {
  5852. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5853. {
  5854. tempIndex = ((gun_index==2) ? 1: 0);
  5855. }
  5856. else
  5857. {
  5858. tempIndex = gun_index;
  5859. }
  5860. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5861. {
  5862. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5863. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5864. {
  5865. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5866. }
  5867. }// End for CHAdeMO
  5868. }
  5869. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5870. {
  5871. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5872. {
  5873. tempIndex = ((gun_index==2) ? 1: 0);
  5874. }
  5875. else
  5876. {
  5877. tempIndex = gun_index;
  5878. }
  5879. for (int index = 0; index < CCS_QUANTITY; index++)
  5880. {
  5881. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5882. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5883. {
  5884. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5885. }
  5886. } // End for CCS
  5887. }
  5888. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5889. {
  5890. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5891. {
  5892. tempIndex = ((gun_index==2) ? 1: 0);
  5893. }
  5894. else
  5895. {
  5896. tempIndex = gun_index;
  5897. }
  5898. for (int index = 0; index < GB_QUANTITY; index++)
  5899. {
  5900. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5901. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5902. {
  5903. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5904. }
  5905. }// End for GB
  5906. }
  5907. else if(gunType[gun_index] == GUN_TYPE_DO)
  5908. {
  5909. tempIndex = gun_index;
  5910. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5911. {
  5912. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5913. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5914. {
  5915. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5916. }
  5917. }
  5918. }
  5919. else
  5920. {
  5921. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5922. {
  5923. tempIndex = 2;
  5924. }
  5925. else
  5926. {
  5927. tempIndex = gun_index;
  5928. }
  5929. for (int index = 0; index < AC_QUANTITY; index++)
  5930. {
  5931. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5932. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5933. {
  5934. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5935. }
  5936. }//End for AC
  5937. }
  5938. }
  5939. }
  5940. //===============================
  5941. // Each connector operation check
  5942. //===============================
  5943. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  5944. {
  5945. //==========================================
  5946. // Check remote start without connector id
  5947. //==========================================
  5948. if(ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
  5949. {
  5950. int connectorIdInt = -1;
  5951. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  5952. {
  5953. if(!cpinitateMsg.bits[gun_index].isOnCharging && (strstr((char*)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[ConnectorStatusEnumType_Occupied]) != NULL))
  5954. {
  5955. connectorIdInt = (gun_index+1);
  5956. DEBUG_INFO("Detect connector-%02d connected ready to start.\n", connectorIdInt);
  5957. checkRemoteStart(connectorIdInt);
  5958. ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = OFF;
  5959. break;
  5960. }
  5961. }
  5962. if(getDiffSecNow(clientTime.RemoteStartWait) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value))
  5963. {
  5964. DEBUG_WARN("Remote start request without connector id wait link over %s seconds.\n", (char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value);
  5965. ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = OFF;
  5966. }
  5967. }
  5968. //==========================================
  5969. // csu trigger DataTransferReq
  5970. //==========================================
  5971. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  5972. {
  5973. sendDataTransferRequest(gun_index);
  5974. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  5975. }
  5976. //==============================================
  5977. // Charger status notification & Transaction event report
  5978. //==============================================
  5979. //--- Check Mode Change ---//
  5980. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  5981. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5982. {
  5983. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5984. {
  5985. tempIndex = ((gun_index==2) ? 1: 0);
  5986. }
  5987. else
  5988. {
  5989. tempIndex = gun_index;
  5990. }
  5991. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5992. {
  5993. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5994. {
  5995. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  5996. {
  5997. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  5998. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  5999. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6000. if((SystemInitial == 0) &&
  6001. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6002. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  6003. {
  6004. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6005. }
  6006. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6007. {
  6008. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6009. if((access(filenmae,F_OK))!=-1)
  6010. {
  6011. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6012. sprintf(str,"rm -f %s",filenmae);
  6013. system(str);
  6014. }
  6015. }
  6016. }
  6017. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6018. #if 1 // for TempStopTransaction
  6019. if(((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6020. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6021. {
  6022. checkTempStopTransaction(gun_index);
  6023. }
  6024. #endif
  6025. }
  6026. }
  6027. }
  6028. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6029. {
  6030. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6031. {
  6032. tempIndex = ((gun_index==2) ? 1: 0);
  6033. }
  6034. else
  6035. {
  6036. tempIndex = gun_index;
  6037. }
  6038. for (int index = 0; index < CCS_QUANTITY; index++)
  6039. {
  6040. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6041. {
  6042. 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]*/ )
  6043. {
  6044. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  6045. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  6046. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6047. if((SystemInitial == 0) &&
  6048. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6049. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  6050. {
  6051. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6052. }
  6053. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6054. {
  6055. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6056. if((access(filenmae,F_OK))!=-1)
  6057. {
  6058. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6059. sprintf(str,"rm -f %s",filenmae);
  6060. system(str);
  6061. }
  6062. }
  6063. }
  6064. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6065. #if 1 // for TempStopTransaction
  6066. if(((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6067. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6068. {
  6069. checkTempStopTransaction(gun_index);
  6070. }
  6071. #endif
  6072. }
  6073. }
  6074. }
  6075. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6076. {
  6077. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6078. {
  6079. tempIndex = ((gun_index==2) ? 1: 0);
  6080. }
  6081. else
  6082. {
  6083. tempIndex = gun_index;
  6084. }
  6085. for (int index = 0; index < GB_QUANTITY; index++)
  6086. {
  6087. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6088. {
  6089. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  6090. {
  6091. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  6092. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  6093. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6094. if((SystemInitial == 0) &&
  6095. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6096. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  6097. {
  6098. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6099. }
  6100. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6101. {
  6102. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6103. if((access(filenmae,F_OK))!=-1)
  6104. {
  6105. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6106. sprintf(str,"rm -f %s",filenmae);
  6107. system(str);
  6108. }
  6109. }
  6110. }
  6111. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6112. #if 1 // for TempStopTransaction
  6113. if(((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6114. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6115. {
  6116. checkTempStopTransaction(gun_index);
  6117. }
  6118. #endif
  6119. }
  6120. }
  6121. }
  6122. else if(gunType[gun_index] == GUN_TYPE_DO)
  6123. {
  6124. tempIndex = gun_index;
  6125. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6126. {
  6127. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6128. {
  6129. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  6130. {
  6131. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  6132. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  6133. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6134. if((SystemInitial == 0) &&
  6135. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CHARGING) &&
  6136. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE))
  6137. {
  6138. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6139. }
  6140. 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
  6141. {
  6142. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6143. if((access(filenmae,F_OK))!=-1)
  6144. {
  6145. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6146. sprintf(str,"rm -f %s",filenmae);
  6147. system(str);
  6148. }
  6149. }
  6150. }
  6151. 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);
  6152. #if 1 // for TempStopTransaction
  6153. if(((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)) &&
  6154. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6155. {
  6156. checkTempStopTransaction(gun_index);
  6157. }
  6158. #endif
  6159. }
  6160. }
  6161. }
  6162. else
  6163. {
  6164. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6165. {
  6166. tempIndex = 2;
  6167. }
  6168. else
  6169. {
  6170. tempIndex = gun_index;
  6171. }
  6172. for (int index = 0; index < AC_QUANTITY; index++)
  6173. {
  6174. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6175. {
  6176. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  6177. {
  6178. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  6179. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  6180. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6181. if((SystemInitial == 0) &&
  6182. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6183. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  6184. {
  6185. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6186. }
  6187. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6188. {
  6189. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6190. if((access(filenmae,F_OK))!=-1)
  6191. {
  6192. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6193. sprintf(str,"rm -f %s",filenmae);
  6194. system(str);
  6195. }
  6196. }
  6197. }
  6198. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6199. #if 1 // for TempStopTransaction
  6200. if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6201. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6202. {
  6203. checkTempStopTransaction(gun_index);
  6204. }
  6205. #endif
  6206. }
  6207. }// END
  6208. }
  6209. if(isWebsocketSendable && (server_sign == TRUE) && (getDiffSecNow(clientTime.StatusNotification[gun_index]) >= 5) &&
  6210. ((cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) || (cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq == ON) ||
  6211. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "TRUE") == 0) &&
  6212. (getDiffSecNow(clientTime.StatusNotification[gun_index]) >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].value)))))
  6213. {
  6214. if(SystemInitial > 0)
  6215. SystemInitial -= 1;
  6216. sendStatusNotificationRequest(gun_index);
  6217. refreshStartTimer(&clientTime.StatusNotification[gun_index]);
  6218. }
  6219. //==============================================
  6220. // CSU Trigger Smart Charging Profile
  6221. //==============================================
  6222. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  6223. {
  6224. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index], 0, TRUE);
  6225. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  6226. }
  6227. //==============================================
  6228. // CSU transaction event
  6229. //==============================================
  6230. if(ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == ON)
  6231. {
  6232. sendTransactionEventRequest(gun_index);
  6233. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  6234. //storeTempStopTransaction(gun_index);
  6235. //memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  6236. }
  6237. //==============================================
  6238. // Meter report
  6239. //==============================================
  6240. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  6241. {
  6242. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  6243. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  6244. }
  6245. if(isWebsocketSendable && (cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON))
  6246. {
  6247. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  6248. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  6249. }
  6250. // Sample period MeterValue
  6251. if(getDiffSecNow(clientTime.MeterValues[gun_index]) >= ((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)>3)?(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1):3))
  6252. {
  6253. //check Transaction active
  6254. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6255. {
  6256. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6257. {
  6258. tempIndex = ((gun_index==2) ? 1: 0);
  6259. }
  6260. else
  6261. {
  6262. tempIndex = gun_index;
  6263. }
  6264. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6265. {
  6266. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6267. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6268. {
  6269. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6270. {
  6271. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6272. }
  6273. }
  6274. }// End for CHAdeMO
  6275. }
  6276. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6277. {
  6278. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6279. {
  6280. tempIndex = ((gun_index==2) ? 1: 0);
  6281. }
  6282. else
  6283. {
  6284. tempIndex = gun_index;
  6285. }
  6286. for (int index = 0; index < CCS_QUANTITY; index++)
  6287. {
  6288. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6289. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6290. {
  6291. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6292. {
  6293. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6294. }
  6295. }
  6296. } // End for CCS
  6297. }
  6298. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6299. {
  6300. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6301. {
  6302. tempIndex = ((gun_index==2) ? 1: 0);
  6303. }
  6304. else
  6305. {
  6306. tempIndex = gun_index;
  6307. }
  6308. for (int index = 0; index < GB_QUANTITY; index++)
  6309. {
  6310. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6311. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6312. {
  6313. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6314. {
  6315. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6316. }
  6317. }
  6318. }// End for GB
  6319. }
  6320. else if(gunType[gun_index] == GUN_TYPE_DO)
  6321. {
  6322. tempIndex = gun_index;
  6323. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6324. {
  6325. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6326. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6327. {
  6328. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  6329. {
  6330. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6331. }
  6332. }
  6333. }
  6334. }
  6335. else
  6336. {
  6337. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6338. {
  6339. tempIndex = 2;
  6340. }
  6341. else
  6342. {
  6343. tempIndex = gun_index;
  6344. }
  6345. for (int index = 0; index < AC_QUANTITY; index++)
  6346. {
  6347. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6348. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6349. {
  6350. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6351. {
  6352. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6353. }
  6354. }
  6355. }//End for AC
  6356. }
  6357. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  6358. {
  6359. if(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0)
  6360. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  6361. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  6362. }
  6363. refreshStartTimer(&clientTime.MeterValues[gun_index]);
  6364. }
  6365. //==============================================
  6366. // Check Connector reserved
  6367. //==============================================
  6368. //===============================
  6369. // Check if Reserve is expired
  6370. //===============================
  6371. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0))
  6372. {
  6373. if(isOvertNow(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime))
  6374. {
  6375. DEBUG_INFO("reserve expired.\n");
  6376. ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId = ShmOCPP20Data->ReserveNow[gun_index].id;
  6377. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Expired]);
  6378. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = ON;
  6379. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  6380. }
  6381. }//END OF Check if Reserve is expired
  6382. //==========================================
  6383. // csu trigger FirmwareStatusNotificationReq
  6384. //==========================================
  6385. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  6386. {
  6387. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  6388. }
  6389. //==========================================
  6390. // csu cleared charging limit request
  6391. //==========================================
  6392. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq == ON))
  6393. {
  6394. sendClearedChargingLimitRequest(gun_index);
  6395. }
  6396. //==========================================
  6397. // csu trigger CancelReservationConf
  6398. //==========================================
  6399. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  6400. {
  6401. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  6402. }
  6403. //==========================================
  6404. // csu notify EV charging need request
  6405. //==========================================
  6406. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq == ON))
  6407. {
  6408. sendNotifyEVChargingNeedsRequest(gun_index);
  6409. }
  6410. //==========================================
  6411. // csu trigger ChangeAvailabilityConf
  6412. //==========================================
  6413. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  6414. {
  6415. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  6416. }
  6417. //==========================================
  6418. // csu trigger UnlockConnectorConf
  6419. //==========================================
  6420. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  6421. {
  6422. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  6423. }
  6424. //==========================================
  6425. // csu trigger ReserveNowConf
  6426. //==========================================
  6427. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  6428. {
  6429. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  6430. }
  6431. //==========================================
  6432. // csu trigger ReserveNowConf
  6433. //==========================================
  6434. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq == ON))
  6435. {
  6436. sendReservationStatusUpdateRequest(gun_index);
  6437. }
  6438. //==========================================
  6439. // csu trigger LogStatusNotificationReq
  6440. //==========================================
  6441. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq == ON))
  6442. {
  6443. sendLogStatusNotificationRequest((char *)ShmOCPP20Data->LogStatusNotification.status);
  6444. }
  6445. //==========================================
  6446. // csu trigger SignCertificateReq
  6447. //==========================================
  6448. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.SignCertificateReq == ON))
  6449. {
  6450. if((access("/Storage/OCPP/certCP.csr",F_OK) != -1) &&
  6451. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0) )
  6452. {
  6453. sendSignCertificateRequest(CertificateSignedStatusEnumType_ChargingStationCertificate);
  6454. }
  6455. else if((access("/Storage/OCPP/certV2G.csr",F_OK) != -1) &&
  6456. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0))
  6457. {
  6458. sendSignCertificateRequest(CertificateSignedStatusEnumType_V2GCertificate);
  6459. }
  6460. }
  6461. }
  6462. }
  6463. //==========================================
  6464. // send request routine
  6465. //==========================================
  6466. int sendAuthorizeRequest(int gun_index)
  6467. {
  6468. mtrace();
  6469. int result = FAIL;
  6470. char message[4096]={0};
  6471. char guid[37];
  6472. char tempdata[128]={0};
  6473. json_object *Authorize = json_object_new_object();
  6474. json_object *idToken = json_object_new_object();
  6475. DEBUG_INFO("sendAuthorizeRequest...\n");
  6476. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  6477. //Local Authorize
  6478. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  6479. {
  6480. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  6481. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  6482. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  6483. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  6484. result = PASS;
  6485. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6486. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6487. authorizeRetryTimes = 0;
  6488. return result;
  6489. }
  6490. 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)) ||
  6491. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  6492. {
  6493. // Query idtag from cache
  6494. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  6495. // Query idtag from list
  6496. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  6497. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  6498. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  6499. {
  6500. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  6501. {
  6502. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  6503. }
  6504. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  6505. {
  6506. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  6507. }
  6508. // Return authorize result if does not connect to server
  6509. if(!ShmOCPP20Data->OcppConnStatus)
  6510. {
  6511. DEBUG_INFO("Local Authorization Fail.\n");
  6512. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  6513. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6514. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  6515. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  6516. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6517. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6518. authorizeRetryTimes = 0;
  6519. return result;
  6520. }
  6521. }
  6522. else
  6523. {
  6524. DEBUG_INFO("Local Authorization get result.\n");
  6525. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  6526. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6527. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  6528. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  6529. else
  6530. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  6531. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  6532. result = PASS;
  6533. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6534. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6535. authorizeRetryTimes = 0;
  6536. return result;
  6537. }
  6538. }
  6539. //get data from shared memory
  6540. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6541. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  6542. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  6543. json_object_object_add(Authorize, "idToken", idToken);
  6544. random_uuid(guid);
  6545. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  6546. json_object_put(Authorize);
  6547. LWS_Send(message);
  6548. sprintf(tempdata, "Authorize,%d", gun_index);
  6549. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6550. {
  6551. result = PASS;
  6552. }
  6553. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6554. return result;
  6555. }
  6556. int sendBootNotificationRequest()
  6557. {
  6558. mtrace();
  6559. int result = FAIL;
  6560. char message[4096]={0};
  6561. char guid[37]={0};
  6562. char tempdata[128]={0};
  6563. json_object *BootNotification = json_object_new_object();
  6564. json_object *chargingStation = json_object_new_object();
  6565. json_object *modem = json_object_new_object();
  6566. DEBUG_INFO("sendBootNotificationRequest...\n");
  6567. // Fill BootNotification fields
  6568. DB_getBooType();
  6569. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  6570. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  6571. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  6572. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  6573. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  6574. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  6575. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  6576. {
  6577. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  6578. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  6579. json_object_object_add(chargingStation, "modem", modem);
  6580. }
  6581. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  6582. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  6583. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  6584. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  6585. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  6586. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  6587. random_uuid(guid);
  6588. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  6589. json_object_put(BootNotification);
  6590. LWS_Send(message);
  6591. sprintf(tempdata, "BootNotification,0");
  6592. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6593. {
  6594. result = PASS;
  6595. }
  6596. return result;
  6597. }
  6598. int sendClearedChargingLimitRequest(int gun_index)
  6599. {
  6600. mtrace();
  6601. int result = FAIL;
  6602. char message[4096]={0};
  6603. char guid[37]={0};
  6604. char tempdata[128]={0};
  6605. json_object *ClearedChargingLimit = json_object_new_object();
  6606. DEBUG_INFO("sendClearedChargingLimitRequest...\n");
  6607. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  6608. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  6609. random_uuid(guid);
  6610. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  6611. json_object_put(ClearedChargingLimit);
  6612. LWS_Send(message);
  6613. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  6614. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6615. {
  6616. result = PASS;
  6617. }
  6618. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  6619. return result;
  6620. }
  6621. int sendDataTransferRequest(int gun_index)
  6622. {
  6623. mtrace();
  6624. char message[1000]={0};
  6625. char guid[37]={0};
  6626. char tempdata[65]={0};
  6627. int result = FAIL;
  6628. DEBUG_INFO("sendDataTransferRequest...\n");
  6629. random_uuid(guid);
  6630. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  6631. MESSAGE_TYPE_CALL,
  6632. guid,
  6633. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  6634. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  6635. ShmOCPP20Data->DataTransfer[gun_index].data);
  6636. LWS_Send(message);
  6637. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  6638. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6639. {
  6640. result = PASS;
  6641. }
  6642. return result;
  6643. }
  6644. int sendFirmwareStatusNotificationRequest(char *status)
  6645. {
  6646. mtrace();
  6647. int result = FAIL;
  6648. char message[110]={0};
  6649. char guid[37]={0};
  6650. char tempdata[65]={0};
  6651. json_object *FirmwareStatusNotification = json_object_new_object();
  6652. DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
  6653. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  6654. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  6655. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  6656. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  6657. random_uuid(guid);
  6658. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6659. json_object_put(FirmwareStatusNotification);
  6660. LWS_SendNow(message);
  6661. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  6662. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6663. {
  6664. result = PASS;
  6665. }
  6666. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  6667. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  6668. //record status
  6669. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  6670. {
  6671. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  6672. }
  6673. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  6674. {
  6675. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  6676. }
  6677. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  6678. {
  6679. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  6680. }
  6681. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  6682. {
  6683. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  6684. }
  6685. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  6686. {
  6687. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  6688. }
  6689. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  6690. {
  6691. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  6692. }
  6693. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  6694. {
  6695. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  6696. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  6697. }
  6698. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  6699. {
  6700. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  6701. }
  6702. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  6703. {
  6704. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  6705. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  6706. }
  6707. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  6708. {
  6709. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  6710. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  6711. }
  6712. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  6713. {
  6714. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  6715. }
  6716. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  6717. {
  6718. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  6719. }
  6720. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  6721. {
  6722. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  6723. }
  6724. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  6725. {
  6726. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  6727. }
  6728. return result;
  6729. }
  6730. int sendGet15118EVCertificateRequest()
  6731. {
  6732. mtrace();
  6733. int result = FAIL;
  6734. char message[4096]={0};
  6735. char guid[37]={0};
  6736. char tempdata[128]={0};
  6737. json_object *Get15118EVCertificate = json_object_new_object();
  6738. DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
  6739. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  6740. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  6741. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  6742. random_uuid(guid);
  6743. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  6744. json_object_put(Get15118EVCertificate);
  6745. LWS_Send(message);
  6746. sprintf(tempdata, "Get15118EVCertificate,0");
  6747. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6748. {
  6749. result = PASS;
  6750. }
  6751. return result;
  6752. }
  6753. int sendGetCertificateStatusRequest()
  6754. {
  6755. mtrace();
  6756. int result = FAIL;
  6757. char message[4096]={0};
  6758. char guid[37]={0};
  6759. char tempdata[128]={0};
  6760. json_object *GetCertificateStatus = json_object_new_object();
  6761. json_object *ocspRequestData = json_object_new_object();
  6762. DEBUG_INFO("sendGetCertificateStatusRequest...\n");
  6763. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  6764. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  6765. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  6766. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  6767. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  6768. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  6769. random_uuid(guid);
  6770. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  6771. json_object_put(GetCertificateStatus);
  6772. LWS_Send(message);
  6773. sprintf(tempdata, "GetCertificateStatus,0");
  6774. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6775. {
  6776. result = PASS;
  6777. }
  6778. return result;
  6779. }
  6780. int sendHeartbeatRequest()
  6781. {
  6782. mtrace();
  6783. int result = FAIL;
  6784. char message[40096]={0};
  6785. char guid[37]={0};
  6786. char tempdata[128]={0};
  6787. DEBUG_INFO("sendHeartbeatRequest...\n");
  6788. random_uuid(guid);
  6789. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  6790. , MESSAGE_TYPE_CALL
  6791. , guid );
  6792. LWS_Send(message);
  6793. sprintf(tempdata, "Heartbeat,%d", 0);
  6794. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6795. {
  6796. result = PASS;
  6797. }
  6798. return result;
  6799. }
  6800. int sendLogStatusNotificationRequest(char *status)
  6801. {
  6802. mtrace();
  6803. int result = FAIL;
  6804. char message[4096]={0};
  6805. char guid[37]={0};
  6806. char tempdata[128]={0};
  6807. json_object *LogStatusNotification = json_object_new_object();
  6808. DEBUG_INFO("sendLogStatusNotificationRequest...\n");
  6809. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  6810. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  6811. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  6812. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  6813. random_uuid(guid);
  6814. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  6815. json_object_put(LogStatusNotification);
  6816. LWS_SendNow(message);
  6817. sprintf(tempdata, "LogStatusNotification,%d", 0);
  6818. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6819. {
  6820. result = PASS;
  6821. }
  6822. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  6823. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  6824. //record status
  6825. if(strcmp(status,"BadMessage")==0)
  6826. {
  6827. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  6828. }
  6829. else if(strcmp(status,"Idle")==0)
  6830. {
  6831. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  6832. }
  6833. else if(strcmp(status,"NotSupportedOperation")==0)
  6834. {
  6835. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  6836. }
  6837. else if(strcmp(status,"PermissionDenied")==0)
  6838. {
  6839. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  6840. }
  6841. else if(strcmp(status,"Uploaded")==0)
  6842. {
  6843. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  6844. }
  6845. else if(strcmp(status,"UploadFailure")==0)
  6846. {
  6847. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  6848. }
  6849. else if(strcmp(status,"Uploading")==0)
  6850. {
  6851. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  6852. }
  6853. return result;
  6854. }
  6855. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  6856. {
  6857. mtrace();
  6858. int result = FAIL;
  6859. char guid[37]={0};
  6860. char tempdata[65]={0};
  6861. int tempIndex = 0;
  6862. json_object *MeterValueReq = json_object_new_object();
  6863. json_object *meterValues = json_object_new_array();
  6864. json_object *sampledValues = json_object_new_array();
  6865. DEBUG_INFO("sendMeterValuesRequest...\n");
  6866. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  6867. memset(&ShmOCPP20Data->MeterValues[gun_index], 0, sizeof(struct MeterValues_20));
  6868. //set value
  6869. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  6870. //UTC Date time
  6871. struct timeval tmnow;
  6872. struct tm *tm;
  6873. char buf[28];//, usec_buf[6];
  6874. gettimeofday(&tmnow, NULL);
  6875. time_t t;
  6876. t = time(NULL);
  6877. /*UTC time and date*/
  6878. tm = gmtime(&t);
  6879. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6880. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  6881. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  6882. //idx_sample=0;
  6883. //********************************(1)Current.Import L1************************************************/
  6884. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  6885. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  6886. (dataType == ReadingContextEnumType_Trigger))
  6887. {
  6888. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6889. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6890. {
  6891. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6892. {
  6893. tempIndex = ((gun_index==2) ? 1: 0);
  6894. }
  6895. else
  6896. {
  6897. tempIndex = gun_index;
  6898. }
  6899. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6900. {
  6901. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6902. {
  6903. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent*100))/100.0;
  6904. }
  6905. }
  6906. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6907. }
  6908. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6909. {
  6910. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6911. {
  6912. tempIndex = ((gun_index==2) ? 1: 0);
  6913. }
  6914. else
  6915. {
  6916. tempIndex = gun_index;
  6917. }
  6918. for (int index = 0; index < CCS_QUANTITY; index++)
  6919. {
  6920. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6921. {
  6922. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent*100))/100.0;
  6923. }
  6924. }
  6925. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6926. }
  6927. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6928. {
  6929. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6930. {
  6931. tempIndex = ((gun_index==2) ? 1: 0);
  6932. }
  6933. else
  6934. {
  6935. tempIndex = gun_index;
  6936. }
  6937. for (int index = 0; index < GB_QUANTITY; index++)
  6938. {
  6939. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6940. {
  6941. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent*100))/100.0;
  6942. }
  6943. }
  6944. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6945. }
  6946. else if(gunType[gun_index] == GUN_TYPE_DO)
  6947. {
  6948. tempIndex = gun_index;
  6949. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6950. {
  6951. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6952. {
  6953. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*100))/100.0;
  6954. }
  6955. }
  6956. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6957. }
  6958. else
  6959. {
  6960. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6961. {
  6962. tempIndex = 2;
  6963. }
  6964. else
  6965. {
  6966. tempIndex = gun_index;
  6967. }
  6968. for (int index = 0; index < AC_QUANTITY; index++)
  6969. {
  6970. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6971. {
  6972. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent*100))/100.0;
  6973. }
  6974. }
  6975. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6976. }
  6977. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  6978. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  6979. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6980. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  6981. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  6982. }
  6983. //idx_sample=1;
  6984. //********************************(2)Energy.Active.Import.Register ************************************************/
  6985. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
  6986. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
  6987. (dataType == ReadingContextEnumType_Trigger))
  6988. {
  6989. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6990. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6991. {
  6992. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6993. {
  6994. tempIndex = ((gun_index==2) ? 1: 0);
  6995. }
  6996. else
  6997. {
  6998. tempIndex = gun_index;
  6999. }
  7000. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7001. {
  7002. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7003. {
  7004. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100))/100.0;
  7005. }
  7006. }
  7007. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7008. }
  7009. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7010. {
  7011. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7012. {
  7013. tempIndex = ((gun_index==2) ? 1: 0);
  7014. }
  7015. else
  7016. {
  7017. tempIndex = gun_index;
  7018. }
  7019. for (int index = 0; index < CCS_QUANTITY; index++)
  7020. {
  7021. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7022. {
  7023. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100))/100.0;
  7024. }
  7025. }
  7026. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7027. }
  7028. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7029. {
  7030. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7031. {
  7032. tempIndex = ((gun_index==2) ? 1: 0);
  7033. }
  7034. else
  7035. {
  7036. tempIndex = gun_index;
  7037. }
  7038. for (int index = 0; index < GB_QUANTITY; index++)
  7039. {
  7040. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7041. {
  7042. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100))/100.0;
  7043. }
  7044. }
  7045. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7046. }
  7047. else if(gunType[gun_index] == GUN_TYPE_DO)
  7048. {
  7049. tempIndex = gun_index;
  7050. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7051. {
  7052. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7053. {
  7054. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100))/100.0;
  7055. }
  7056. }
  7057. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7058. }
  7059. else
  7060. {
  7061. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7062. {
  7063. tempIndex = 2;
  7064. }
  7065. else
  7066. {
  7067. tempIndex = gun_index;
  7068. }
  7069. for (int index = 0; index < AC_QUANTITY; index++)
  7070. {
  7071. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7072. {
  7073. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100))/100.0;
  7074. }
  7075. }
  7076. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7077. }
  7078. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  7079. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  7080. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7081. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  7082. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  7083. }
  7084. //idx_sample=2;
  7085. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  7086. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
  7087. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
  7088. (dataType == ReadingContextEnumType_Trigger))
  7089. {
  7090. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7091. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7092. {
  7093. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7094. {
  7095. tempIndex = ((gun_index==2) ? 1: 0);
  7096. }
  7097. else
  7098. {
  7099. tempIndex = gun_index;
  7100. }
  7101. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7102. {
  7103. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7104. {
  7105. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy*100))/100.0;
  7106. }
  7107. } // END OF FOR CHAdeMO_QUANTITY
  7108. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7109. }
  7110. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7111. {
  7112. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7113. {
  7114. tempIndex = ((gun_index==2) ? 1: 0);
  7115. }
  7116. else
  7117. {
  7118. tempIndex = gun_index;
  7119. }
  7120. for (int index = 0; index < CCS_QUANTITY; index++)
  7121. {
  7122. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7123. {
  7124. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy*100))/100.0;
  7125. }
  7126. } // END OF CCS_QUANTITY
  7127. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7128. }
  7129. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7130. {
  7131. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7132. {
  7133. tempIndex = ((gun_index==2) ? 1: 0);
  7134. }
  7135. else
  7136. {
  7137. tempIndex = gun_index;
  7138. }
  7139. for (int index = 0; index < GB_QUANTITY; index++)
  7140. {
  7141. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7142. {
  7143. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy*100))/100.0;
  7144. }
  7145. } // END OF GB_QUANTITY
  7146. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7147. }
  7148. else if(gunType[gun_index] == GUN_TYPE_DO)
  7149. {
  7150. tempIndex = gun_index;
  7151. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7152. {
  7153. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7154. {
  7155. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100))/100.0;
  7156. }
  7157. }
  7158. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7159. }
  7160. else
  7161. {
  7162. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7163. {
  7164. tempIndex = 2;
  7165. }
  7166. else
  7167. {
  7168. tempIndex = gun_index;
  7169. }
  7170. for (int index = 0; index < AC_QUANTITY; index++)
  7171. {
  7172. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7173. {
  7174. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy*100))/100.0;
  7175. }
  7176. }
  7177. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7178. }
  7179. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  7180. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  7181. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7182. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  7183. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  7184. }
  7185. //idx_sample=3;
  7186. //********************************(4)Power.Active.Import************************************************/
  7187. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
  7188. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
  7189. (dataType == ReadingContextEnumType_Trigger))
  7190. {
  7191. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7192. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7193. {
  7194. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7195. {
  7196. tempIndex = ((gun_index==2) ? 1: 0);
  7197. }
  7198. else
  7199. {
  7200. tempIndex = gun_index;
  7201. }
  7202. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7203. {
  7204. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7205. {
  7206. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower*100))/100.0;
  7207. }
  7208. } // END OF FOR
  7209. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7210. }
  7211. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7212. {
  7213. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7214. {
  7215. tempIndex = ((gun_index==2) ? 1: 0);
  7216. }
  7217. else
  7218. {
  7219. tempIndex = gun_index;
  7220. }
  7221. for (int index = 0; index < CCS_QUANTITY; index++)
  7222. {
  7223. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7224. {
  7225. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower*100))/100.0;
  7226. }
  7227. }
  7228. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7229. }
  7230. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7231. {
  7232. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7233. {
  7234. tempIndex = ((gun_index==2) ? 1: 0);
  7235. }
  7236. else
  7237. {
  7238. tempIndex = gun_index;
  7239. }
  7240. for (int index = 0; index < GB_QUANTITY; index++)
  7241. {
  7242. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7243. {
  7244. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7245. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower*100))/100.0;
  7246. }
  7247. }
  7248. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7249. }
  7250. else if(gunType[gun_index] == GUN_TYPE_DO)
  7251. {
  7252. tempIndex = gun_index;
  7253. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7254. {
  7255. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7256. {
  7257. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7258. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower*100))/100.0;
  7259. }
  7260. }
  7261. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7262. }
  7263. else
  7264. {
  7265. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7266. {
  7267. tempIndex = 2;
  7268. }
  7269. else
  7270. {
  7271. tempIndex = gun_index;
  7272. }
  7273. for (int index = 0; index < AC_QUANTITY; index++)
  7274. {
  7275. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7276. {
  7277. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower*100))/100.0;
  7278. }
  7279. }
  7280. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7281. }
  7282. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  7283. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  7284. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7285. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  7286. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  7287. }
  7288. //idx_sample=4;
  7289. //***********************************************(5)VOLTAGE L1******************************************************/
  7290. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7291. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7292. (dataType == ReadingContextEnumType_Trigger))
  7293. {
  7294. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7295. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7296. {
  7297. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7298. {
  7299. tempIndex = ((gun_index==2) ? 1: 0);
  7300. }
  7301. else
  7302. {
  7303. tempIndex = gun_index;
  7304. }
  7305. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7306. {
  7307. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7308. {
  7309. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage*100))/100.0;
  7310. }
  7311. }
  7312. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7313. }
  7314. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7315. {
  7316. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7317. {
  7318. tempIndex = ((gun_index==2) ? 1: 0);
  7319. }
  7320. else
  7321. {
  7322. tempIndex = gun_index;
  7323. }
  7324. for (int index = 0; index < CCS_QUANTITY; index++)
  7325. {
  7326. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7327. {
  7328. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage*100))/100.0;
  7329. }
  7330. }
  7331. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7332. }
  7333. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7334. {
  7335. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7336. {
  7337. tempIndex = ((gun_index==2) ? 1: 0);
  7338. }
  7339. else
  7340. {
  7341. tempIndex = gun_index;
  7342. }
  7343. for (int index = 0; index < GB_QUANTITY; index++)
  7344. {
  7345. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7346. {
  7347. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage*100))/100.0;
  7348. }
  7349. }
  7350. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7351. }
  7352. else if(gunType[gun_index] == GUN_TYPE_DO)
  7353. {
  7354. tempIndex = gun_index;
  7355. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7356. {
  7357. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7358. {
  7359. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*100))/100.0;
  7360. }
  7361. }
  7362. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7363. }
  7364. else
  7365. {
  7366. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7367. {
  7368. tempIndex = 2;
  7369. }
  7370. else
  7371. {
  7372. tempIndex = gun_index;
  7373. }
  7374. for (int index = 0; index < AC_QUANTITY; index++)
  7375. {
  7376. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7377. {
  7378. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage*100))/100.0;
  7379. }
  7380. }
  7381. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7382. }
  7383. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  7384. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7385. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7386. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  7387. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  7388. }
  7389. //***********************************************(6)SOC******************************************************/
  7390. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
  7391. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
  7392. (dataType == ReadingContextEnumType_Trigger))
  7393. {
  7394. 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))
  7395. {
  7396. if((ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0') && (gunType[gun_index] != GUN_TYPE_DO))
  7397. {
  7398. tempIndex = ((gun_index==2) ? 1: 0);
  7399. }
  7400. else
  7401. {
  7402. tempIndex = gun_index;
  7403. }
  7404. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7405. {
  7406. //tempIndex = ((gun_index==2) ? 1: 0);
  7407. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7408. {
  7409. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7410. {
  7411. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  7412. }
  7413. }
  7414. }
  7415. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7416. {
  7417. //tempIndex = ((gun_index==2) ? 1: 0);
  7418. for (int index = 0; index < CCS_QUANTITY; index++)
  7419. {
  7420. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7421. {
  7422. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  7423. }
  7424. }
  7425. }
  7426. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7427. {
  7428. //tempIndex = ((gun_index==2) ? 1: 0);
  7429. for (int index = 0; index < GB_QUANTITY; index++)
  7430. {
  7431. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7432. {
  7433. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  7434. }
  7435. }
  7436. }
  7437. else if(gunType[gun_index] == GUN_TYPE_DO)
  7438. {
  7439. //tempIndex = ((gun_index==2) ? 1: 0);
  7440. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7441. {
  7442. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7443. {
  7444. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  7445. }
  7446. }
  7447. }
  7448. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  7449. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  7450. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7451. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  7452. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  7453. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  7454. }
  7455. }
  7456. //********************************(7)Current.Import L2************************************************/
  7457. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7458. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7459. (dataType == ReadingContextEnumType_Trigger))
  7460. {
  7461. // Only for AC 3 phase
  7462. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7463. {
  7464. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7465. {
  7466. tempIndex = 2;
  7467. }
  7468. else
  7469. {
  7470. tempIndex = gun_index;
  7471. }
  7472. for (int index = 0; index < AC_QUANTITY; index++)
  7473. {
  7474. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7475. {
  7476. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2*100))/100.0;
  7477. }
  7478. }
  7479. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  7480. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  7481. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7482. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7483. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  7484. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  7485. }
  7486. }
  7487. //********************************(8)Current.Import L3************************************************/
  7488. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7489. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7490. (dataType == ReadingContextEnumType_Trigger))
  7491. {
  7492. // Only for AC 3 phase
  7493. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7494. {
  7495. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7496. {
  7497. tempIndex = 2;
  7498. }
  7499. else
  7500. {
  7501. tempIndex = gun_index;
  7502. }
  7503. for (int index = 0; index < AC_QUANTITY; index++)
  7504. {
  7505. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7506. {
  7507. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3*100))/100.0;
  7508. }
  7509. }
  7510. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7511. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  7512. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7513. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7514. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  7515. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  7516. }
  7517. }
  7518. //***********************************************(9)VOLTAGE L2******************************************************/
  7519. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7520. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7521. (dataType == ReadingContextEnumType_Trigger))
  7522. {
  7523. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7524. {
  7525. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7526. {
  7527. tempIndex = 2;
  7528. }
  7529. else
  7530. {
  7531. tempIndex = gun_index;
  7532. }
  7533. for (int index = 0; index < AC_QUANTITY; index++)
  7534. {
  7535. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7536. {
  7537. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2*100))/100.0;
  7538. }
  7539. }
  7540. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  7541. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  7542. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7543. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7544. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  7545. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  7546. }
  7547. }
  7548. //***********************************************(10)VOLTAGE L3******************************************************/
  7549. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7550. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7551. (dataType == ReadingContextEnumType_Trigger))
  7552. {
  7553. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7554. {
  7555. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7556. {
  7557. tempIndex = 2;
  7558. }
  7559. else
  7560. {
  7561. tempIndex = gun_index;
  7562. }
  7563. for (int index = 0; index < AC_QUANTITY; index++)
  7564. {
  7565. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7566. {
  7567. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3*100))/100.0;
  7568. }
  7569. }
  7570. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7571. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  7572. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7573. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7574. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  7575. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  7576. }
  7577. }
  7578. //***********************************************(11)Current.Offered******************************************************/
  7579. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
  7580. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
  7581. (dataType == ReadingContextEnumType_Trigger))
  7582. {
  7583. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7584. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7585. {
  7586. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7587. {
  7588. tempIndex = ((gun_index==2) ? 1: 0);
  7589. }
  7590. else
  7591. {
  7592. tempIndex = gun_index;
  7593. }
  7594. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7595. {
  7596. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7597. {
  7598. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].AvailableChargingCurrent/10);
  7599. }
  7600. } // END OF FOR
  7601. }
  7602. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7603. {
  7604. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7605. {
  7606. tempIndex = ((gun_index==2) ? 1: 0);
  7607. }
  7608. else
  7609. {
  7610. tempIndex = gun_index;
  7611. }
  7612. for (int index = 0; index < CCS_QUANTITY; index++)
  7613. {
  7614. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7615. {
  7616. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].AvailableChargingCurrent/10);
  7617. }
  7618. }
  7619. }
  7620. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7621. {
  7622. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7623. {
  7624. tempIndex = ((gun_index==2) ? 1: 0);
  7625. }
  7626. else
  7627. {
  7628. tempIndex = gun_index;
  7629. }
  7630. for (int index = 0; index < GB_QUANTITY; index++)
  7631. {
  7632. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7633. {
  7634. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7635. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].AvailableChargingCurrent/10);;
  7636. }
  7637. }
  7638. }
  7639. else if(gunType[gun_index] == GUN_TYPE_DO)
  7640. {
  7641. tempIndex = gun_index;
  7642. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7643. {
  7644. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7645. {
  7646. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7647. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.AvailableChargingCurrent/10);;
  7648. }
  7649. }
  7650. }
  7651. else
  7652. {
  7653. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7654. {
  7655. tempIndex = 2;
  7656. }
  7657. else
  7658. {
  7659. tempIndex = gun_index;
  7660. }
  7661. for (int index = 0; index < AC_QUANTITY; index++)
  7662. {
  7663. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7664. {
  7665. uint16_t currentOffer;
  7666. if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
  7667. {
  7668. currentOffer = ShmSysConfigAndInfo->SysConfig.RatingCurrent;
  7669. }
  7670. else
  7671. {
  7672. currentOffer = ((ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent>ShmSysConfigAndInfo->SysConfig.RatingCurrent)?ShmSysConfigAndInfo->SysConfig.RatingCurrent:ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
  7673. }
  7674. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = currentOffer;
  7675. }
  7676. }
  7677. }
  7678. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].context, ReadingContextEnumTypeStr[dataType]);
  7679. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]);
  7680. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7681. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.uint , "A");
  7682. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.multiplier = 0;
  7683. }
  7684. //***********************************************(12)Power.Offered******************************************************/
  7685. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
  7686. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
  7687. (dataType == ReadingContextEnumType_Trigger))
  7688. {
  7689. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7690. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7691. {
  7692. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7693. {
  7694. tempIndex = ((gun_index==2) ? 1: 0);
  7695. }
  7696. else
  7697. {
  7698. tempIndex = gun_index;
  7699. }
  7700. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7701. {
  7702. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7703. {
  7704. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].AvailableChargingPower*100);
  7705. }
  7706. } // END OF FOR
  7707. }
  7708. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7709. {
  7710. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7711. {
  7712. tempIndex = ((gun_index==2) ? 1: 0);
  7713. }
  7714. else
  7715. {
  7716. tempIndex = gun_index;
  7717. }
  7718. for (int index = 0; index < CCS_QUANTITY; index++)
  7719. {
  7720. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7721. {
  7722. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].AvailableChargingPower*100);
  7723. }
  7724. }
  7725. }
  7726. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7727. {
  7728. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7729. {
  7730. tempIndex = ((gun_index==2) ? 1: 0);
  7731. }
  7732. else
  7733. {
  7734. tempIndex = gun_index;
  7735. }
  7736. for (int index = 0; index < GB_QUANTITY; index++)
  7737. {
  7738. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7739. {
  7740. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7741. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].AvailableChargingPower*100);
  7742. }
  7743. }
  7744. }
  7745. else if(gunType[gun_index] == GUN_TYPE_DO)
  7746. {
  7747. tempIndex = gun_index;
  7748. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7749. {
  7750. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7751. {
  7752. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7753. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.AvailableChargingPower*100);
  7754. }
  7755. }
  7756. }
  7757. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].context, ReadingContextEnumTypeStr[dataType]);
  7758. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]);
  7759. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7760. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.uint , "W");
  7761. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.multiplier = 0;
  7762. }
  7763. // Message create ====================================================================================================
  7764. random_uuid(guid);
  7765. for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
  7766. {
  7767. json_object *meterValue = json_object_new_object();
  7768. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7769. {
  7770. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7771. {
  7772. json_object *sampledValue = json_object_new_object();
  7773. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7774. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7775. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7776. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  7777. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7778. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  7779. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7780. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  7781. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7782. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  7783. {
  7784. json_object *unitOfMeasure = json_object_new_object();
  7785. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7786. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7787. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7788. }
  7789. json_object_array_add(sampledValues, sampledValue);
  7790. }
  7791. }
  7792. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  7793. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7794. json_object_array_add(meterValues, meterValue);
  7795. idxMeter++;
  7796. }
  7797. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  7798. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  7799. sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",%s]"
  7800. ,MESSAGE_TYPE_CALL
  7801. ,guid
  7802. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  7803. json_object_put(MeterValueReq);
  7804. if((dataType != ReadingContextEnumType_Trigger) &&
  7805. (dataType != ReadingContextEnumType_Sample_Clock))
  7806. {
  7807. // Transaction meter value send by TransactionEvent message
  7808. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  7809. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  7810. result = PASS;
  7811. }
  7812. else
  7813. {
  7814. // Put request guid to hash map
  7815. sprintf(tempdata, "MeterValues,%d", (gun_index));
  7816. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7817. {
  7818. result = PASS;
  7819. }
  7820. if((dataType != ReadingContextEnumType_Trigger) &&
  7821. (dataType != ReadingContextEnumType_Sample_Clock))
  7822. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  7823. else
  7824. {
  7825. if(FirstHeartBeat)
  7826. LWS_Send(queuedata +2);
  7827. }
  7828. }
  7829. return result;
  7830. }
  7831. int sendNotifyChargingLimitRequest(int gun_index)
  7832. {
  7833. mtrace();
  7834. int result = FAIL;
  7835. char message[4096]={0};
  7836. char guid[37]={0};
  7837. char tempdata[128]={0};
  7838. json_object *NotifyChargingLimit = json_object_new_object();
  7839. json_object *chargingLimit = json_object_new_object();
  7840. DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
  7841. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  7842. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  7843. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  7844. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  7845. random_uuid(guid);
  7846. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  7847. json_object_put(NotifyChargingLimit);
  7848. LWS_Send(message);
  7849. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  7850. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7851. {
  7852. result = PASS;
  7853. }
  7854. return result;
  7855. }
  7856. int sendNotifyCustomerInformationRequest()
  7857. {
  7858. mtrace();
  7859. int result = FAIL;
  7860. char message[4096]={0};
  7861. char guid[37]={0};
  7862. char tempdata[128]={0};
  7863. json_object *NotifyCustomerInformation = json_object_new_object();
  7864. DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
  7865. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  7866. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  7867. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  7868. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  7869. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  7870. random_uuid(guid);
  7871. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  7872. json_object_put(NotifyCustomerInformation);
  7873. LWS_Send(message);
  7874. sprintf(tempdata, "NotifyCustomerInformation,0");
  7875. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7876. {
  7877. result = PASS;
  7878. }
  7879. return result;
  7880. }
  7881. int sendNotifyDisplayMessagesRequest()
  7882. {
  7883. mtrace();
  7884. int result = FAIL;
  7885. char message[4096]={0};
  7886. char guid[37]={0};
  7887. char tempdata[128]={0};
  7888. json_object *NotifyDisplayMessages = json_object_new_object();
  7889. json_object *messageInfos = json_object_new_array();
  7890. DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
  7891. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  7892. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  7893. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  7894. {
  7895. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  7896. {
  7897. json_object *messageInfo = json_object_new_object();
  7898. json_object *message = json_object_new_object();
  7899. json_object *display = json_object_new_object();
  7900. json_object *evse = json_object_new_object();
  7901. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  7902. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  7903. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  7904. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  7905. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  7906. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  7907. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  7908. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  7909. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  7910. json_object_object_add(messageInfo, "message", message);
  7911. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  7912. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  7913. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  7914. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  7915. json_object_object_add(display, "evse",evse);
  7916. json_object_object_add(messageInfo, "evse", display);
  7917. json_object_array_add(messageInfos, messageInfo);
  7918. }
  7919. }
  7920. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  7921. random_uuid(guid);
  7922. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7923. json_object_put(NotifyDisplayMessages);
  7924. LWS_Send(message);
  7925. sprintf(tempdata, "NotifyDisplayMessages,0");
  7926. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7927. {
  7928. result = PASS;
  7929. }
  7930. return result;
  7931. }
  7932. int sendNotifyEVChargingNeedsRequest(int gun_index)
  7933. {
  7934. mtrace();
  7935. int result = FAIL;
  7936. char message[4096]={0};
  7937. char guid[37]={0};
  7938. char tempdata[128]={0};
  7939. json_object *NotifyEVChargingNeeds = json_object_new_object();
  7940. json_object *chargingNeeds = json_object_new_object();
  7941. json_object *acChargingParameters = json_object_new_object();
  7942. json_object *dcChargingParameters = json_object_new_object();
  7943. DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
  7944. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  7945. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  7946. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  7947. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  7948. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  7949. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  7950. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  7951. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  7952. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  7953. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  7954. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  7955. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  7956. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  7957. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  7958. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  7959. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  7960. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  7961. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  7962. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  7963. random_uuid(guid);
  7964. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  7965. json_object_put(NotifyEVChargingNeeds);
  7966. LWS_Send(message);
  7967. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  7968. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7969. {
  7970. result = PASS;
  7971. }
  7972. return result;
  7973. }
  7974. int sendNotifyEVChargingScheduleRequest(int gun_index)
  7975. {
  7976. mtrace();
  7977. int result = FAIL;
  7978. char message[4096]={0};
  7979. char guid[37]={0};
  7980. char tempdata[128]={0};
  7981. json_object *NotifyEVChargingSchedule = json_object_new_object();
  7982. json_object *chargingSchedule = json_object_new_object();
  7983. json_object *periods = json_object_new_array();
  7984. DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
  7985. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  7986. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  7987. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  7988. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  7989. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  7990. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  7991. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  7992. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7993. {
  7994. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7995. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7996. {
  7997. json_object *Period = json_object_new_object();
  7998. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7999. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  8000. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  8001. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  8002. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  8003. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  8004. json_object_array_add(periods, Period);
  8005. }
  8006. }
  8007. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  8008. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  8009. random_uuid(guid);
  8010. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  8011. json_object_put(NotifyEVChargingSchedule);
  8012. LWS_Send(message);
  8013. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  8014. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8015. {
  8016. result = PASS;
  8017. }
  8018. return result;
  8019. }
  8020. int sendNotifyEventRequest()
  8021. {
  8022. mtrace();
  8023. int result = FAIL;
  8024. char message[4096]={0};
  8025. char guid[37]={0};
  8026. char tempdata[128]={0};
  8027. json_object *NotifyEvent = json_object_new_object();
  8028. json_object *eventDatas = json_object_new_array();
  8029. DEBUG_INFO("sendNotifyEventRequest...\n");
  8030. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  8031. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  8032. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  8033. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  8034. {
  8035. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  8036. {
  8037. json_object *eventData = json_object_new_object();
  8038. json_object *component = json_object_new_object();
  8039. json_object *evse = json_object_new_object();
  8040. json_object *variable = json_object_new_object();
  8041. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  8042. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  8043. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  8044. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  8045. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  8046. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  8047. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  8048. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  8049. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  8050. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  8051. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  8052. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  8053. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  8054. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  8055. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  8056. json_object_object_add(component, "evse",evse);
  8057. json_object_object_add(eventData, "component", component);
  8058. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  8059. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  8060. json_object_object_add(eventData, "variable", variable);
  8061. json_object_array_add(eventDatas, eventData);
  8062. }
  8063. }
  8064. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  8065. random_uuid(guid);
  8066. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  8067. json_object_put(NotifyEvent);
  8068. LWS_Send(message);
  8069. sprintf(tempdata, "NotifyEvent,0");
  8070. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8071. {
  8072. result = PASS;
  8073. }
  8074. return result;
  8075. }
  8076. int sendNotifyMonitoringReportRequest()
  8077. {
  8078. mtrace();
  8079. int result = FAIL;
  8080. char message[4096]={0};
  8081. char guid[37]={0};
  8082. char tempdata[128]={0};
  8083. json_object *NotifyMonitoringReport = json_object_new_object();
  8084. json_object *monitors = json_object_new_array();
  8085. DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
  8086. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  8087. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  8088. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  8089. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  8090. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  8091. {
  8092. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  8093. {
  8094. json_object *monitor = json_object_new_object();
  8095. json_object *component = json_object_new_object();
  8096. json_object *evse = json_object_new_object();
  8097. json_object *variable = json_object_new_object();
  8098. json_object *variableMonitorings = json_object_new_array();
  8099. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  8100. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  8101. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  8102. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  8103. json_object_object_add(component, "evse",evse);
  8104. json_object_object_add(monitor, "component", component);
  8105. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  8106. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  8107. json_object_object_add(monitor, "variable", variable);
  8108. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  8109. {
  8110. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  8111. {
  8112. json_object *variableMonitoring = json_object_new_object();
  8113. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  8114. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  8115. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  8116. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  8117. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  8118. json_object_array_add(variableMonitorings, variableMonitoring);
  8119. }
  8120. }
  8121. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  8122. json_object_array_add(monitors, monitor);
  8123. }
  8124. }
  8125. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  8126. random_uuid(guid);
  8127. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  8128. json_object_put(NotifyMonitoringReport);
  8129. LWS_Send(message);
  8130. sprintf(tempdata, "NotifyMonitoringReport,0");
  8131. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8132. {
  8133. result = PASS;
  8134. }
  8135. return result;
  8136. }
  8137. int sendNotifyReportRequest()
  8138. {
  8139. mtrace();
  8140. int result = FAIL;
  8141. char message[4096]={0};
  8142. char guid[37]={0};
  8143. char tempdata[128]={0};
  8144. json_object *NotifyReport = json_object_new_object();
  8145. json_object *reportDatas = json_object_new_array();
  8146. DEBUG_INFO("sendNotifyReportRequest...\n");
  8147. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  8148. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  8149. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  8150. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  8151. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  8152. {
  8153. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  8154. {
  8155. json_object *reportData = json_object_new_object();
  8156. json_object *component = json_object_new_object();
  8157. json_object *evse = json_object_new_object();
  8158. json_object *variable = json_object_new_object();
  8159. json_object *variableAttributes = json_object_new_array();
  8160. json_object *variableCharacteristics = json_object_new_object();
  8161. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  8162. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  8163. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  8164. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  8165. json_object_object_add(component, "evse",evse);
  8166. json_object_object_add(reportData, "component", component);
  8167. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  8168. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  8169. json_object_object_add(reportData, "variable",variable);
  8170. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  8171. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  8172. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  8173. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  8174. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  8175. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  8176. {
  8177. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  8178. {
  8179. json_object *variableAttribute = json_object_new_object();
  8180. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  8181. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  8182. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  8183. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  8184. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  8185. json_object_array_add(variableAttributes, variableAttribute);
  8186. }
  8187. }
  8188. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  8189. json_object_array_add(reportDatas, reportData);
  8190. }
  8191. }
  8192. json_object_object_add(NotifyReport, "reportData", reportDatas);
  8193. random_uuid(guid);
  8194. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  8195. json_object_put(NotifyReport);
  8196. LWS_SendNow(message);
  8197. sprintf(tempdata, "NotifyReport,0");
  8198. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8199. {
  8200. result = PASS;
  8201. }
  8202. return result;
  8203. }
  8204. int sendPublishFirmwareStatusNotificationRequest()
  8205. {
  8206. mtrace();
  8207. int result = FAIL;
  8208. char message[4096]={0};
  8209. char guid[37]={0};
  8210. char tempdata[128]={0};
  8211. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  8212. json_object *locations = json_object_new_array();
  8213. DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
  8214. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  8215. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  8216. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  8217. {
  8218. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  8219. }
  8220. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  8221. random_uuid(guid);
  8222. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  8223. json_object_put(PublishFirmwareStatusNotification);
  8224. LWS_Send(message);
  8225. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  8226. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8227. {
  8228. result = PASS;
  8229. }
  8230. return result;
  8231. }
  8232. int sendReportChargingProfilesRequest(int gun_index)
  8233. {
  8234. mtrace();
  8235. int result = FAIL;
  8236. char message[4096]={0};
  8237. char guid[37]={0};
  8238. char tempdata[128]={0};
  8239. json_object *ReportChargingProfiles = json_object_new_object();
  8240. json_object *chargingProfiles = json_object_new_array();
  8241. DEBUG_INFO("sendReportChargingProfilesRequest...\n");
  8242. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  8243. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  8244. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  8245. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  8246. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  8247. {
  8248. json_object *chargingProfile = json_object_new_object();
  8249. json_object *chargingSchedules = json_object_new_array();
  8250. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  8251. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  8252. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  8253. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  8254. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  8255. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  8256. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  8257. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  8258. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  8259. {
  8260. json_object *chargingSchedule = json_object_new_object();
  8261. json_object *chargingSchedulePeriods = json_object_new_array();
  8262. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  8263. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  8264. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  8265. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  8266. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  8267. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  8268. {
  8269. json_object *chargingSchedulePeriod = json_object_new_object();
  8270. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  8271. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  8272. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  8273. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  8274. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  8275. }
  8276. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  8277. json_object_array_add(chargingSchedules, chargingSchedule);
  8278. }
  8279. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  8280. json_object_array_add(chargingProfiles, chargingProfile);
  8281. }
  8282. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  8283. random_uuid(guid);
  8284. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  8285. json_object_put(ReportChargingProfiles);
  8286. LWS_Send(message);
  8287. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  8288. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8289. {
  8290. result = PASS;
  8291. }
  8292. return result;
  8293. }
  8294. int sendReservationStatusUpdateRequest(int gun_index)
  8295. {
  8296. mtrace();
  8297. int result = FAIL;
  8298. char message[4096]={0};
  8299. char guid[37]={0};
  8300. char tempdata[128]={0};
  8301. json_object *ReservationStatusUpdate = json_object_new_object();
  8302. DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
  8303. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  8304. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  8305. random_uuid(guid);
  8306. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  8307. json_object_put(ReservationStatusUpdate);
  8308. LWS_Send(message);
  8309. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  8310. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8311. {
  8312. result = PASS;
  8313. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  8314. }
  8315. return result;
  8316. }
  8317. int sendSecurityEventNotificationRequest()
  8318. {
  8319. mtrace();
  8320. int result = FAIL;
  8321. char message[4096]={0};
  8322. char guid[37]={0};
  8323. char tempdata[128]={0};
  8324. json_object *SecurityEventNotification = json_object_new_object();
  8325. DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
  8326. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  8327. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  8328. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techInfo));
  8329. random_uuid(guid);
  8330. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  8331. json_object_put(SecurityEventNotification);
  8332. LWS_Send(message);
  8333. sprintf(tempdata, "SecurityEventNotification,0");
  8334. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8335. {
  8336. result = PASS;
  8337. }
  8338. return result;
  8339. }
  8340. int sendSignCertificateRequest(CertificateSigningUseEnumType certType)
  8341. {
  8342. mtrace();
  8343. int result = FAIL;
  8344. char message[4096]={0};
  8345. char guid[37]={0};
  8346. char tempdata[128]={0};
  8347. json_object *SignCertificate = json_object_new_object();
  8348. DEBUG_INFO("sendSignCertificateRequest...\n");
  8349. // Read csr file content
  8350. memset(ShmOCPP20Data->SignCertificate.csr, 0x00, ARRAY_SIZE(ShmOCPP20Data->SignCertificate.csr));
  8351. FILE *fp=fopen(((certType == CertificateSignedStatusEnumType_V2GCertificate)?"/Storage/OCPP/certV2G.csr":"/Storage/OCPP/certCP.csr"),"r");
  8352. char *line = NULL;
  8353. size_t len = 0;
  8354. while(getline(&line, &len, fp) != -1)
  8355. {
  8356. if((strstr(line, "BEGIN CERTIFICATE REQUEST") == NULL) && (strstr(line, "END CERTIFICATE REQUEST") == NULL))
  8357. {
  8358. memcpy(&ShmOCPP20Data->SignCertificate.csr[strlen((char*)ShmOCPP20Data->SignCertificate.csr)], line, (strlen(line)-1));
  8359. }
  8360. }
  8361. fclose(fp);
  8362. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  8363. sprintf((char*)ShmOCPP20Data->SignCertificate.certificateType, CertificateSigningUseEnumTypeStr[certType]);
  8364. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  8365. random_uuid(guid);
  8366. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  8367. json_object_put(SignCertificate);
  8368. LWS_Send(message);
  8369. sprintf(tempdata, "SignCertificate,0");
  8370. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8371. {
  8372. result = PASS;
  8373. }
  8374. return result;
  8375. }
  8376. int sendStatusNotificationRequest(int gun_index)
  8377. {
  8378. mtrace();
  8379. int result = FAIL;
  8380. char message[600]={0};
  8381. char guid[37];
  8382. int currentStatus = 0;
  8383. struct timeval tmnow;
  8384. struct tm *tm;
  8385. char buf[28];//, usec_buf[6];
  8386. char tempdata[65]={0};
  8387. int tempIndex = 0;
  8388. uint8_t isStateChanged = TRUE;
  8389. DEBUG_INFO("sendStatusNotificationRequest...\n");
  8390. gettimeofday(&tmnow, NULL);
  8391. time_t t;
  8392. t = time(NULL);
  8393. /*UTC time and date*/
  8394. tm = gmtime(&t);
  8395. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  8396. #if 0 // remove temporally
  8397. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  8398. strcat(buf,".");
  8399. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  8400. strcat(buf,usec_buf);
  8401. #endif
  8402. printf("%s",buf);
  8403. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  8404. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  8405. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  8406. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  8407. /*
  8408. enum _SYSTEM_STATUS
  8409. {
  8410. S_BOOTING = 0,
  8411. S_IDLE, = 1
  8412. S_AUTHORIZING, =2
  8413. S_REASSIGN_CHECK, =3
  8414. S_REASSIGN, =4
  8415. S_PRECHARGE, =5
  8416. S_PREPARING_FOR_EV, =6
  8417. S_PREPARING_FOR_EVSE, =7
  8418. S_CHARGING, =8
  8419. S_TERMINATING, =9
  8420. S_COMPLETE, =10
  8421. S_ALARM, =11
  8422. S_FAULT =12
  8423. }
  8424. */
  8425. //check Transaction active
  8426. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  8427. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  8428. {
  8429. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8430. {
  8431. tempIndex = ((gun_index==2) ? 1: 0);
  8432. }
  8433. else
  8434. {
  8435. tempIndex = gun_index;
  8436. }
  8437. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8438. {
  8439. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  8440. {
  8441. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  8442. {
  8443. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8444. {
  8445. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8446. }
  8447. else
  8448. {
  8449. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8450. }
  8451. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8452. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8453. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8454. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8455. }
  8456. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8457. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8458. ) //S_PRECHARGE
  8459. {
  8460. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8461. }
  8462. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8463. {
  8464. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8465. }
  8466. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8467. {
  8468. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8469. }
  8470. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8471. {
  8472. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8473. }
  8474. 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
  8475. {
  8476. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8477. }
  8478. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8479. {
  8480. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8481. }
  8482. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8483. {
  8484. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8485. }
  8486. } //end of the same index
  8487. }//end of for CHAdeMO_QUANTITY
  8488. }
  8489. else if(gunType[gun_index] == GUN_TYPE_CCS)
  8490. {
  8491. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8492. {
  8493. tempIndex = ((gun_index==2) ? 1: 0);
  8494. }
  8495. else
  8496. {
  8497. tempIndex = gun_index;
  8498. }
  8499. for (int index = 0; index < CCS_QUANTITY; index++)
  8500. {
  8501. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  8502. {
  8503. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8504. {
  8505. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  8506. {
  8507. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8508. }
  8509. else
  8510. {
  8511. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8512. }
  8513. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8514. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8515. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8516. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8517. }
  8518. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8519. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8520. ) //S_PRECHARGE
  8521. {
  8522. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8523. }
  8524. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8525. {
  8526. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8527. }
  8528. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8529. {
  8530. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8531. }
  8532. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  8533. {
  8534. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8535. }
  8536. 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
  8537. {
  8538. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  8539. }
  8540. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  8541. {
  8542. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8543. }
  8544. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8545. {
  8546. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8547. }
  8548. } //end of the same index
  8549. } // end of for CCS_QUANTITY
  8550. }
  8551. else if(gunType[gun_index] == GUN_TYPE_GBT)
  8552. {
  8553. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8554. {
  8555. tempIndex = ((gun_index==2) ? 1: 0);
  8556. }
  8557. else
  8558. {
  8559. tempIndex = gun_index;
  8560. }
  8561. for (int index = 0; index < GB_QUANTITY; index++)
  8562. {
  8563. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  8564. {
  8565. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8566. {
  8567. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8568. {
  8569. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8570. }
  8571. else
  8572. {
  8573. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8574. }
  8575. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8576. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8577. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8578. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8579. }
  8580. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8581. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8582. ) //S_PRECHARGE
  8583. {
  8584. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8585. }
  8586. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8587. {
  8588. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8589. }
  8590. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8591. {
  8592. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8593. }
  8594. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8595. {
  8596. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8597. }
  8598. 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
  8599. {
  8600. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8601. }
  8602. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  8603. {
  8604. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8605. }
  8606. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8607. {
  8608. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8609. }
  8610. } //end of the same index
  8611. } // end of for GB_QUANTITY
  8612. }
  8613. else if(gunType[gun_index] == GUN_TYPE_DO)
  8614. {
  8615. tempIndex = gun_index;
  8616. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8617. {
  8618. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  8619. {
  8620. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8621. {
  8622. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8623. {
  8624. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8625. }
  8626. else
  8627. {
  8628. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8629. }
  8630. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8631. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8632. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8633. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8634. }
  8635. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8636. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8637. ) //S_PRECHARGE
  8638. {
  8639. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8640. }
  8641. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8642. {
  8643. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8644. }
  8645. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8646. {
  8647. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8648. }
  8649. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8650. {
  8651. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8652. }
  8653. 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
  8654. {
  8655. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8656. }
  8657. 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
  8658. {
  8659. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8660. }
  8661. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8662. {
  8663. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8664. }
  8665. } //end of the same index
  8666. }
  8667. }
  8668. else
  8669. {
  8670. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8671. {
  8672. tempIndex = 2;
  8673. }
  8674. else
  8675. {
  8676. tempIndex = gun_index;
  8677. }
  8678. for (int index = 0; index < AC_QUANTITY; index++)
  8679. {
  8680. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  8681. {
  8682. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  8683. {
  8684. 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))
  8685. {
  8686. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8687. }
  8688. else
  8689. {
  8690. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8691. }
  8692. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8693. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8694. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8695. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8696. }
  8697. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  8698. {
  8699. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8700. }
  8701. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  8702. {
  8703. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8704. }
  8705. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  8706. {
  8707. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8708. }
  8709. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8710. {
  8711. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8712. }
  8713. 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
  8714. {
  8715. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8716. }
  8717. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8718. {
  8719. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8720. }
  8721. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8722. {
  8723. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8724. }
  8725. }//end of the same index
  8726. }//end of for AC_QUANTITY
  8727. }
  8728. //it's option
  8729. if((strstr((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]) != NULL) &&
  8730. !cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq &&
  8731. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "TRUE") != 0))
  8732. {
  8733. isStateChanged = FALSE;
  8734. }
  8735. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  8736. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  8737. random_uuid(guid);
  8738. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  8739. , MESSAGE_TYPE_CALL
  8740. , guid
  8741. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  8742. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  8743. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  8744. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  8745. if((server_sign == TRUE) && isStateChanged)
  8746. {
  8747. LWS_Send(message);
  8748. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  8749. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8750. {
  8751. result = PASS;
  8752. }
  8753. }
  8754. else
  8755. {
  8756. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  8757. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  8758. result = PASS;
  8759. }
  8760. return result;
  8761. }
  8762. int sendTransactionEventRequest(int gun_index)
  8763. {
  8764. mtrace();
  8765. int result = FAIL;
  8766. char message[1024*20]={0};
  8767. char guid[37]={0};
  8768. char tempdata[128]={0};
  8769. uint8_t tempIndex;
  8770. json_object *TransactionEvent = json_object_new_object();
  8771. json_object *transactionInfo = json_object_new_object();
  8772. json_object *idToken = json_object_new_object();
  8773. json_object *evse = json_object_new_object();
  8774. json_object *meterValues = json_object_new_array();
  8775. char TempStopTransaction[256];
  8776. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  8777. DEBUG_INFO("sendTransactionEventRequest...\n");
  8778. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  8779. {
  8780. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8781. {
  8782. tempIndex = ((gun_index==2) ? 1: 0);
  8783. }
  8784. else
  8785. {
  8786. tempIndex = gun_index;
  8787. }
  8788. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8789. {
  8790. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  8791. {
  8792. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8793. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8794. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8795. else
  8796. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8797. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8798. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8799. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8800. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  8801. {
  8802. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8803. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8804. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8805. {
  8806. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8807. }
  8808. else
  8809. {
  8810. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8811. }
  8812. }
  8813. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8814. {
  8815. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8816. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8817. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8818. }
  8819. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8820. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8821. ) //S_PRECHARGE
  8822. {
  8823. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8824. {
  8825. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8826. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  8827. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartIdType]);
  8828. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8829. }
  8830. else
  8831. {
  8832. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8833. }
  8834. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8835. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8836. }
  8837. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8838. {
  8839. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8840. {
  8841. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8842. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  8843. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartIdType]);
  8844. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8845. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8846. }
  8847. else
  8848. {
  8849. storeTempStopTransaction(gun_index);
  8850. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8851. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8852. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  8853. }
  8854. }
  8855. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8856. {
  8857. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8858. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8859. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8860. if((access(TempStopTransaction,F_OK))!=-1)
  8861. {
  8862. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8863. }
  8864. }
  8865. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8866. {
  8867. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8868. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8869. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8870. }
  8871. 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
  8872. {
  8873. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8874. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8875. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8876. }
  8877. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8878. {
  8879. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8880. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8881. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8882. }
  8883. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8884. {
  8885. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8886. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8887. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8888. }
  8889. } //end of the same index
  8890. }//end of for CHAdeMO_QUANTITY
  8891. }
  8892. else if(gunType[gun_index] == GUN_TYPE_CCS)
  8893. {
  8894. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8895. {
  8896. tempIndex = ((gun_index==2) ? 1: 0);
  8897. }
  8898. else
  8899. {
  8900. tempIndex = gun_index;
  8901. }
  8902. for (int index = 0; index < CCS_QUANTITY; index++)
  8903. {
  8904. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  8905. {
  8906. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8907. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8908. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8909. else
  8910. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8911. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8912. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8913. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8914. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8915. {
  8916. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8917. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8918. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  8919. {
  8920. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8921. }
  8922. else
  8923. {
  8924. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8925. }
  8926. }
  8927. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8928. {
  8929. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8930. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8931. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8932. }
  8933. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8934. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8935. ) //S_PRECHARGE
  8936. {
  8937. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8938. {
  8939. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8940. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  8941. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartIdType]);
  8942. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8943. }
  8944. else
  8945. {
  8946. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8947. }
  8948. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8949. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8950. }
  8951. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8952. {
  8953. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8954. {
  8955. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8956. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  8957. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartIdType]);
  8958. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8959. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8960. }
  8961. else
  8962. {
  8963. storeTempStopTransaction(gun_index);
  8964. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8965. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8966. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  8967. }
  8968. }
  8969. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8970. {
  8971. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8972. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8973. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8974. if((access(TempStopTransaction,F_OK))!=-1)
  8975. {
  8976. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8977. }
  8978. }
  8979. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8980. {
  8981. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8982. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8983. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8984. }
  8985. 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
  8986. {
  8987. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8988. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8989. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8990. }
  8991. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8992. {
  8993. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8994. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8995. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8996. }
  8997. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8998. {
  8999. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9000. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9001. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9002. }
  9003. } //end of the same index
  9004. } // end of for CCS_QUANTITY
  9005. }
  9006. else if(gunType[gun_index] == GUN_TYPE_GBT)
  9007. {
  9008. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9009. {
  9010. tempIndex = ((gun_index==2) ? 1: 0);
  9011. }
  9012. else
  9013. {
  9014. tempIndex = gun_index;
  9015. }
  9016. for (int index = 0; index < GB_QUANTITY; index++)
  9017. {
  9018. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  9019. {
  9020. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9021. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9022. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9023. else
  9024. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9025. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9026. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9027. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9028. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9029. {
  9030. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9031. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9032. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  9033. {
  9034. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9035. }
  9036. else
  9037. {
  9038. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9039. }
  9040. }
  9041. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9042. {
  9043. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9044. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9045. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9046. }
  9047. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9048. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9049. ) //S_PRECHARGE
  9050. {
  9051. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9052. {
  9053. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9054. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  9055. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartIdType]);
  9056. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9057. }
  9058. else
  9059. {
  9060. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9061. }
  9062. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9063. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9064. }
  9065. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9066. {
  9067. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9068. {
  9069. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9070. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  9071. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartIdType]);
  9072. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9073. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9074. }
  9075. else
  9076. {
  9077. storeTempStopTransaction(gun_index);
  9078. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9079. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9080. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9081. }
  9082. }
  9083. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9084. {
  9085. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9086. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9087. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9088. if((access(TempStopTransaction,F_OK))!=-1)
  9089. {
  9090. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9091. }
  9092. }
  9093. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9094. {
  9095. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9096. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9097. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9098. }
  9099. 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
  9100. {
  9101. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9102. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9103. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9104. }
  9105. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9106. {
  9107. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9108. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9109. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9110. }
  9111. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9112. {
  9113. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9114. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9115. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9116. }
  9117. } //end of the same index
  9118. } // end of for GB_QUANTITY
  9119. }
  9120. else if(gunType[gun_index] == GUN_TYPE_DO)
  9121. {
  9122. tempIndex = gun_index;
  9123. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9124. {
  9125. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  9126. {
  9127. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9128. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9129. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9130. else
  9131. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9132. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9133. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9134. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9135. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9136. {
  9137. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9138. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9139. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  9140. {
  9141. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9142. }
  9143. else
  9144. {
  9145. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9146. }
  9147. }
  9148. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9149. {
  9150. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9151. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9152. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9153. }
  9154. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9155. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9156. ) //S_PRECHARGE
  9157. {
  9158. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9159. {
  9160. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9161. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  9162. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartIdType]);
  9163. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9164. }
  9165. else
  9166. {
  9167. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9168. }
  9169. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9170. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9171. }
  9172. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9173. {
  9174. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9175. {
  9176. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9177. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  9178. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartIdType]);
  9179. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9180. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9181. }
  9182. else
  9183. {
  9184. storeTempStopTransaction(gun_index);
  9185. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9186. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9187. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9188. }
  9189. }
  9190. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9191. {
  9192. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9193. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9194. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9195. if((access(TempStopTransaction,F_OK))!=-1)
  9196. {
  9197. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9198. }
  9199. }
  9200. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9201. {
  9202. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9203. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9204. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9205. }
  9206. 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
  9207. {
  9208. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9209. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9210. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9211. }
  9212. 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
  9213. {
  9214. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9215. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9216. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9217. }
  9218. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9219. {
  9220. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9221. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9222. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9223. }
  9224. } //end of the same index
  9225. }
  9226. }
  9227. else
  9228. {
  9229. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  9230. {
  9231. tempIndex = 2;
  9232. }
  9233. else
  9234. {
  9235. tempIndex = gun_index;
  9236. }
  9237. for (int index = 0; index < AC_QUANTITY; index++)
  9238. {
  9239. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  9240. {
  9241. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9242. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9243. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9244. else
  9245. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9246. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9247. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9248. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9249. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  9250. {
  9251. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9252. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9253. 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))
  9254. {
  9255. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9256. }
  9257. else
  9258. {
  9259. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9260. }
  9261. }
  9262. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9263. {
  9264. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9265. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9266. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9267. }
  9268. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9269. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9270. ) //S_PRECHARGE
  9271. {
  9272. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9273. {
  9274. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9275. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  9276. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartIdType]);
  9277. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9278. }
  9279. else
  9280. {
  9281. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9282. }
  9283. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9284. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9285. }
  9286. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9287. {
  9288. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9289. {
  9290. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9291. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  9292. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartIdType]);
  9293. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9294. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9295. }
  9296. else
  9297. {
  9298. storeTempStopTransaction(gun_index);
  9299. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9300. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9301. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9302. }
  9303. }
  9304. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9305. {
  9306. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9307. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9308. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9309. if((access(TempStopTransaction,F_OK))!=-1)
  9310. {
  9311. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9312. }
  9313. }
  9314. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9315. {
  9316. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9317. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9318. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9319. }
  9320. 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
  9321. {
  9322. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9323. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9324. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9325. }
  9326. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9327. {
  9328. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9329. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9330. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9331. }
  9332. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9333. {
  9334. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9335. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9336. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9337. }
  9338. }//end of the same index
  9339. }//end of for AC_QUANTITY
  9340. }
  9341. // Message
  9342. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  9343. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  9344. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  9345. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  9346. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  9347. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  9348. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  9349. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  9350. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  9351. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  9352. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  9353. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  9354. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  9355. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  9356. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  9357. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0) && (strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL))
  9358. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  9359. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  9360. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  9361. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  9362. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  9363. {
  9364. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  9365. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  9366. json_object_object_add(TransactionEvent, "idToken", idToken);
  9367. }
  9368. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  9369. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  9370. json_object_object_add(TransactionEvent, "evse", evse);
  9371. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  9372. {
  9373. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  9374. {
  9375. json_object *meterValue = json_object_new_object();
  9376. json_object *sampledValues = json_object_new_array();
  9377. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  9378. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  9379. {
  9380. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  9381. ((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)))
  9382. {
  9383. 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)) ||
  9384. (strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) == NULL))
  9385. {
  9386. json_object *sampledValue = json_object_new_object();
  9387. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  9388. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  9389. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  9390. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  9391. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  9392. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  9393. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  9394. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  9395. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  9396. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  9397. {
  9398. json_object *unitOfMeasure = json_object_new_object();
  9399. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  9400. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  9401. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  9402. }
  9403. json_object_array_add(sampledValues, sampledValue);
  9404. }
  9405. }
  9406. }
  9407. json_object_object_add(meterValue, "sampledValue", sampledValues);
  9408. json_object_array_add(meterValues, meterValue);
  9409. }
  9410. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  9411. }
  9412. random_uuid(guid);
  9413. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  9414. json_object_put(TransactionEvent);
  9415. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  9416. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  9417. {
  9418. result = PASS;
  9419. }
  9420. queue_operation(QUEUE_OPERATION_ADD, guid, message);
  9421. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Started]) != NULL)
  9422. OCPP_insert_transaction_msg(YES, message);
  9423. else if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL)
  9424. {
  9425. OCPP_insert_transaction_msg(NO, message);
  9426. memset(&ShmOCPP20Data->SessionTarget[gun_index], 0x00, sizeof(struct StructSessionTarget));
  9427. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  9428. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  9429. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  9430. }
  9431. return result;
  9432. }
  9433. //==========================================
  9434. // send confirm routine
  9435. //==========================================
  9436. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  9437. {
  9438. mtrace();
  9439. int result = FAIL;
  9440. char message[4096]={0};
  9441. json_object *CancelReservation = json_object_new_object();
  9442. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  9443. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  9444. sprintf(message,"[%d,\"%s\",%s]"
  9445. ,MESSAGE_TYPE_CALLRESULT
  9446. ,uuid
  9447. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  9448. json_object_put(CancelReservation);
  9449. ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf = OFF;
  9450. LWS_Send(message);
  9451. result = TRUE;
  9452. return result;
  9453. }
  9454. int sendCertificateSignedConfirmation(char *uuid)
  9455. {
  9456. mtrace();
  9457. int result = FAIL;
  9458. char message[4096]={0};
  9459. json_object *CertificateSigned = json_object_new_object();
  9460. json_object *statusInfo = json_object_new_object();
  9461. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  9462. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  9463. if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode) > 0)
  9464. {
  9465. json_object_object_add(statusInfo, "reasonCode", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode));
  9466. if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo) > 0)
  9467. json_object_object_add(statusInfo, "statadditionalInfous", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo));
  9468. }
  9469. json_object_object_add(CertificateSigned, "statusInfo", statusInfo);
  9470. sprintf(message,"[%d,\"%s\",%s]"
  9471. ,MESSAGE_TYPE_CALLRESULT
  9472. ,uuid
  9473. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  9474. json_object_put(CertificateSigned);
  9475. LWS_Send(message);
  9476. result = TRUE;
  9477. return result;
  9478. }
  9479. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  9480. {
  9481. mtrace();
  9482. int result = FAIL;
  9483. char message[4096]={0};
  9484. json_object *ChangeAvailability = json_object_new_object();
  9485. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  9486. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  9487. sprintf(message,"[%d,\"%s\",%s]"
  9488. ,MESSAGE_TYPE_CALLRESULT
  9489. ,uuid
  9490. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  9491. json_object_put(ChangeAvailability);
  9492. LWS_Send(message);
  9493. result = TRUE;
  9494. return result;
  9495. }
  9496. int sendClearCacheConfirmation(char *uuid)
  9497. {
  9498. mtrace();
  9499. int result = FAIL;
  9500. char message[4096]={0};
  9501. json_object *ClearCache = json_object_new_object();
  9502. DEBUG_INFO("sendClearCacheConfirmation...\n");
  9503. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  9504. sprintf(message,"[%d,\"%s\",%s]"
  9505. ,MESSAGE_TYPE_CALLRESULT
  9506. ,uuid
  9507. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  9508. json_object_put(ClearCache);
  9509. LWS_Send(message);
  9510. result = TRUE;
  9511. return result;
  9512. }
  9513. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  9514. {
  9515. mtrace();
  9516. int result = FAIL;
  9517. char message[500]={0};
  9518. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  9519. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  9520. LWS_Send(message);
  9521. return result;
  9522. }
  9523. int sendClearDisplayMessageConfirmation(char *uuid)
  9524. {
  9525. mtrace();
  9526. int result = FAIL;
  9527. char message[4096]={0};
  9528. json_object *ClearDisplayMessage = json_object_new_object();
  9529. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  9530. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  9531. sprintf(message,"[%d,\"%s\",%s]"
  9532. ,MESSAGE_TYPE_CALLRESULT
  9533. ,uuid
  9534. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  9535. json_object_put(ClearDisplayMessage);
  9536. LWS_Send(message);
  9537. result = TRUE;
  9538. return result;
  9539. }
  9540. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  9541. {
  9542. mtrace();
  9543. int result = FAIL;
  9544. char message[4096]={0};
  9545. json_object *ClearVariableMonitoring = json_object_new_object();
  9546. json_object *clearMonitoringResults = json_object_new_array();
  9547. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  9548. for(int idx=0;idx<variableQuantity;idx++)
  9549. {
  9550. json_object *clearMonitoringResult = json_object_new_object();
  9551. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  9552. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  9553. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  9554. }
  9555. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  9556. sprintf(message,"[%d,\"%s\",%s]"
  9557. ,MESSAGE_TYPE_CALLRESULT
  9558. ,uuid
  9559. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  9560. json_object_put(ClearVariableMonitoring);
  9561. LWS_Send(message);
  9562. result = TRUE;
  9563. return result;
  9564. }
  9565. int sendCostUpdatedConfirmation(char *uuid)
  9566. {
  9567. mtrace();
  9568. int result = FAIL;
  9569. char message[4096]={0};
  9570. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  9571. sprintf(message,"[%d,\"%s\",{}]"
  9572. ,MESSAGE_TYPE_CALLRESULT
  9573. ,uuid);
  9574. LWS_Send(message);
  9575. result = TRUE;
  9576. return result;
  9577. }
  9578. int sendCustomerInformationConfirmation(char *uuid)
  9579. {
  9580. mtrace();
  9581. int result = FAIL;
  9582. char message[4096]={0};
  9583. json_object *CustomerInformation = json_object_new_object();
  9584. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  9585. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  9586. sprintf(message,"[%d,\"%s\",%s]"
  9587. ,MESSAGE_TYPE_CALLRESULT
  9588. ,uuid
  9589. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  9590. json_object_put(CustomerInformation);
  9591. LWS_Send(message);
  9592. result = TRUE;
  9593. return result;
  9594. }
  9595. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  9596. {
  9597. mtrace();
  9598. int result = FAIL;
  9599. char message[4096]={0};
  9600. json_object *DataTransfer = json_object_new_object();
  9601. DEBUG_INFO("sendDataTransferConfirmation...\n");
  9602. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  9603. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  9604. sprintf(message,"[%d,\"%s\",%s]"
  9605. ,MESSAGE_TYPE_CALLRESULT
  9606. ,uuid
  9607. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  9608. json_object_put(DataTransfer);
  9609. LWS_Send(message);
  9610. result = TRUE;
  9611. return result;
  9612. }
  9613. int sendDeleteCertificateConfirmation(char *uuid)
  9614. {
  9615. mtrace();
  9616. int result = FAIL;
  9617. char message[4096]={0};
  9618. json_object *DeleteCertificate = json_object_new_object();
  9619. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  9620. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  9621. sprintf(message,"[%d,\"%s\",%s]"
  9622. ,MESSAGE_TYPE_CALLRESULT
  9623. ,uuid
  9624. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  9625. json_object_put(DeleteCertificate);
  9626. LWS_Send(message);
  9627. result = TRUE;
  9628. return result;
  9629. }
  9630. int sendGetBaseReportConfirmation(char *uuid)
  9631. {
  9632. mtrace();
  9633. int result = FAIL;
  9634. char message[4096]={0};
  9635. json_object *GetBaseReport = json_object_new_object();
  9636. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  9637. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  9638. sprintf(message,"[%d,\"%s\",%s]"
  9639. ,MESSAGE_TYPE_CALLRESULT
  9640. ,uuid
  9641. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  9642. json_object_put(GetBaseReport);
  9643. LWS_Send(message);
  9644. result = TRUE;
  9645. return result;
  9646. }
  9647. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  9648. {
  9649. mtrace();
  9650. int result = FAIL;
  9651. char message[4096]={0};
  9652. json_object *GetChargingProfiles = json_object_new_object();
  9653. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  9654. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  9655. sprintf(message,"[%d,\"%s\",%s]"
  9656. ,MESSAGE_TYPE_CALLRESULT
  9657. ,uuid
  9658. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  9659. json_object_put(GetChargingProfiles);
  9660. LWS_Send(message);
  9661. result = TRUE;
  9662. return result;
  9663. }
  9664. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  9665. {
  9666. mtrace();
  9667. int result = FAIL;
  9668. char message[4096]={0};
  9669. int CompositeScheduleIndex = 0;
  9670. json_object *GetCompositeSchedule = json_object_new_object();
  9671. json_object *schedule = json_object_new_object();
  9672. json_object *chargingSchedule = json_object_new_object();
  9673. json_object *chargingSchedulePeriod = json_object_new_array();
  9674. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  9675. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  9676. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  9677. if(nPeriod == 0)
  9678. {
  9679. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  9680. {
  9681. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  9682. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  9683. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  9684. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  9685. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  9686. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  9687. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  9688. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  9689. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  9690. {
  9691. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  9692. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  9693. {
  9694. json_object *Period = json_object_new_object();
  9695. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  9696. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  9697. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  9698. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  9699. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  9700. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  9701. json_object_array_add(chargingSchedulePeriod, Period);
  9702. }
  9703. }
  9704. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  9705. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  9706. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  9707. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  9708. }
  9709. }
  9710. else
  9711. {
  9712. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  9713. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  9714. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  9715. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  9716. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  9717. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  9718. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  9719. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  9720. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  9721. {
  9722. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  9723. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  9724. {
  9725. json_object *Period = json_object_new_object();
  9726. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  9727. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  9728. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  9729. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  9730. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  9731. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  9732. json_object_array_add(chargingSchedulePeriod, Period);
  9733. }
  9734. }
  9735. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  9736. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  9737. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  9738. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  9739. }
  9740. sprintf(message,"[%d,\"%s\",%s]"
  9741. ,MESSAGE_TYPE_CALLRESULT
  9742. ,uuid
  9743. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  9744. json_object_put(GetCompositeSchedule);
  9745. LWS_Send(message);
  9746. result = TRUE;
  9747. return result;
  9748. }
  9749. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  9750. {
  9751. mtrace();
  9752. int result = FAIL;
  9753. char message[4096]={0};
  9754. json_object *GetGetDisplayMessages = json_object_new_object();
  9755. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  9756. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  9757. sprintf(message,"[%d,\"%s\",%s]"
  9758. ,MESSAGE_TYPE_CALLRESULT
  9759. ,uuid
  9760. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  9761. json_object_put(GetGetDisplayMessages);
  9762. LWS_Send(message);
  9763. result = TRUE;
  9764. return result;
  9765. }
  9766. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  9767. {
  9768. mtrace();
  9769. int result = FAIL;
  9770. char message[4096]={0};
  9771. json_object *GetInstalledCertificateIds = json_object_new_object();
  9772. json_object *certificateHashDataChains = json_object_new_array();
  9773. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  9774. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  9775. for(int idx=0;idx<certQuantity;idx++)
  9776. {
  9777. json_object *cert = json_object_new_object();
  9778. json_object *certificateHashData = json_object_new_object();
  9779. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  9780. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  9781. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  9782. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  9783. json_object_object_add(cert, "certificateHashData", certificateHashData);
  9784. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  9785. json_object_array_add(certificateHashDataChains, cert);
  9786. }
  9787. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  9788. sprintf(message,"[%d,\"%s\",%s]"
  9789. ,MESSAGE_TYPE_CALLRESULT
  9790. ,uuid
  9791. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  9792. json_object_put(GetInstalledCertificateIds);
  9793. LWS_Send(message);
  9794. result = TRUE;
  9795. return result;
  9796. }
  9797. int sendGetLocalListVersionConfirmation(char *uuid)
  9798. {
  9799. mtrace();
  9800. int result = FAIL;
  9801. char message[4096]={0};
  9802. json_object *GetLocalListVersion = json_object_new_object();
  9803. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  9804. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  9805. sprintf(message,"[%d,\"%s\",%s]"
  9806. ,MESSAGE_TYPE_CALLRESULT
  9807. ,uuid
  9808. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  9809. json_object_put(GetLocalListVersion);
  9810. LWS_Send(message);
  9811. result = TRUE;
  9812. return result;
  9813. }
  9814. int sendGetLogConfirmation(char *uuid)
  9815. {
  9816. mtrace();
  9817. int result = FAIL;
  9818. char message[4096]={0};
  9819. json_object *GetLog = json_object_new_object();
  9820. DEBUG_INFO("sendGetLogConfirmation...\n");
  9821. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  9822. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  9823. sprintf(message,"[%d,\"%s\",%s]"
  9824. ,MESSAGE_TYPE_CALLRESULT
  9825. ,uuid
  9826. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  9827. json_object_put(GetLog);
  9828. LWS_Send(message);
  9829. result = TRUE;
  9830. return result;
  9831. }
  9832. int sendGetMonitoringReportConfirmation(char *uuid)
  9833. {
  9834. mtrace();
  9835. int result = FAIL;
  9836. char message[4096]={0};
  9837. json_object *GetMonitoringReport = json_object_new_object();
  9838. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  9839. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  9840. sprintf(message,"[%d,\"%s\",%s]"
  9841. ,MESSAGE_TYPE_CALLRESULT
  9842. ,uuid
  9843. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  9844. json_object_put(GetMonitoringReport);
  9845. LWS_Send(message);
  9846. result = TRUE;
  9847. return result;
  9848. }
  9849. int sendGetReportConfirmation(char *uuid)
  9850. {
  9851. mtrace();
  9852. int result = FAIL;
  9853. char message[4096]={0};
  9854. json_object *GetReport = json_object_new_object();
  9855. DEBUG_INFO("sendGetReportConfirmation...\n");
  9856. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  9857. sprintf(message,"[%d,\"%s\",%s]"
  9858. ,MESSAGE_TYPE_CALLRESULT
  9859. ,uuid
  9860. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  9861. json_object_put(GetReport);
  9862. LWS_Send(message);
  9863. result = TRUE;
  9864. return result;
  9865. }
  9866. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  9867. {
  9868. mtrace();
  9869. int result = FAIL;
  9870. char message[4096]={0};
  9871. json_object *GetTransactionStatus = json_object_new_object();
  9872. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  9873. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  9874. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  9875. sprintf(message,"[%d,\"%s\",%s]"
  9876. ,MESSAGE_TYPE_CALLRESULT
  9877. ,uuid
  9878. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  9879. json_object_put(GetTransactionStatus);
  9880. LWS_Send(message);
  9881. result = TRUE;
  9882. return result;
  9883. }
  9884. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  9885. {
  9886. mtrace();
  9887. int result = FAIL;
  9888. char message[4096]={0};
  9889. json_object *GetVariables = json_object_new_object();
  9890. json_object *getVariableResults = json_object_new_array();
  9891. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  9892. for(int idx=0;idx<variableQuantity;idx++)
  9893. {
  9894. json_object *variableResult = json_object_new_object();
  9895. json_object *component = json_object_new_object();
  9896. json_object *variable = json_object_new_object();
  9897. json_object *evse = json_object_new_object();
  9898. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  9899. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  9900. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  9901. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  9902. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  9903. json_object_object_add(component, "evse", evse);
  9904. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  9905. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  9906. json_object_object_add(variableResult, "component", component);
  9907. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  9908. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  9909. json_object_object_add(variableResult, "variable", variable);
  9910. json_object_array_add(getVariableResults, variableResult);
  9911. }
  9912. json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
  9913. sprintf(message,"[%d,\"%s\",%s]"
  9914. ,MESSAGE_TYPE_CALLRESULT
  9915. ,uuid
  9916. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  9917. json_object_put(GetVariables);
  9918. LWS_Send(message);
  9919. result = TRUE;
  9920. return result;
  9921. }
  9922. int sendInstallCertificateConfirmation(char *uuid)
  9923. {
  9924. mtrace();
  9925. int result = FAIL;
  9926. char message[4096]={0};
  9927. json_object *InstallCertificate = json_object_new_object();
  9928. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  9929. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  9930. sprintf(message,"[%d,\"%s\",%s]"
  9931. ,MESSAGE_TYPE_CALLRESULT
  9932. ,uuid
  9933. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  9934. json_object_put(InstallCertificate);
  9935. LWS_Send(message);
  9936. result = TRUE;
  9937. return result;
  9938. }
  9939. int sendPublishFirmwareConfirmation(char *uuid)
  9940. {
  9941. mtrace();
  9942. int result = FAIL;
  9943. char message[4096]={0};
  9944. json_object *PublishFirmware = json_object_new_object();
  9945. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  9946. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  9947. sprintf(message,"[%d,\"%s\",%s]"
  9948. ,MESSAGE_TYPE_CALLRESULT
  9949. ,uuid
  9950. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  9951. json_object_put(PublishFirmware);
  9952. LWS_Send(message);
  9953. result = TRUE;
  9954. return result;
  9955. }
  9956. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  9957. {
  9958. mtrace();
  9959. int result = FAIL;
  9960. char message[4096]={0};
  9961. json_object *RemoteStartTransaction = json_object_new_object();
  9962. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  9963. if((strstr((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]) != NULL) &&
  9964. (strlen((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId) > 0))
  9965. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  9966. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  9967. sprintf(message,"[%d,\"%s\",%s]"
  9968. ,MESSAGE_TYPE_CALLRESULT
  9969. ,uuid
  9970. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  9971. json_object_put(RemoteStartTransaction);
  9972. LWS_Send(message);
  9973. result = TRUE;
  9974. return result;
  9975. }
  9976. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  9977. {
  9978. mtrace();
  9979. int result = FAIL;
  9980. char message[4096]={0};
  9981. json_object *RemoteStopTransaction = json_object_new_object();
  9982. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  9983. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  9984. sprintf(message,"[%d,\"%s\",%s]"
  9985. ,MESSAGE_TYPE_CALLRESULT
  9986. ,uuid
  9987. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  9988. json_object_put(RemoteStopTransaction);
  9989. LWS_Send(message);
  9990. result = TRUE;
  9991. return result;
  9992. }
  9993. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  9994. {
  9995. mtrace();
  9996. int result = FAIL;
  9997. char message[4096]={0};
  9998. json_object *ReserveNow = json_object_new_object();
  9999. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  10000. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  10001. sprintf(message,"[%d,\"%s\",%s]"
  10002. ,MESSAGE_TYPE_CALLRESULT
  10003. ,uuid
  10004. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  10005. json_object_put(ReserveNow);
  10006. LWS_Send(message);
  10007. result = TRUE;
  10008. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  10009. return result;
  10010. }
  10011. int sendResetConfirmation(char *uuid)
  10012. {
  10013. mtrace();
  10014. int result = FAIL;
  10015. char message[4096]={0};
  10016. json_object *Reset = json_object_new_object();
  10017. DEBUG_INFO("sendResetConfirmation...\n");
  10018. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  10019. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  10020. sprintf(message,"[%d,\"%s\",%s]"
  10021. ,MESSAGE_TYPE_CALLRESULT
  10022. ,uuid
  10023. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  10024. json_object_put(Reset);
  10025. LWS_Send(message);
  10026. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  10027. {
  10028. DB_updateBootType(BootReasonEnumType_RemoteReset);
  10029. }
  10030. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  10031. {
  10032. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  10033. }
  10034. result = TRUE;
  10035. return result;
  10036. }
  10037. int sendSendLocalListConfirmation(char *uuid)
  10038. {
  10039. mtrace();
  10040. int result = FAIL;
  10041. char message[4096]={0};
  10042. json_object *SendLocalList = json_object_new_object();
  10043. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  10044. sprintf(message,"[%d,\"%s\",%s]"
  10045. ,MESSAGE_TYPE_CALLRESULT
  10046. ,uuid
  10047. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  10048. json_object_put(SendLocalList);
  10049. LWS_Send(message);
  10050. result = TRUE;
  10051. return result;
  10052. }
  10053. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  10054. {
  10055. mtrace();
  10056. int result = FAIL;
  10057. char message[4096]={0};
  10058. json_object *SetChargingProfile = json_object_new_object();
  10059. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  10060. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  10061. sprintf(message,"[%d,\"%s\",%s]"
  10062. ,MESSAGE_TYPE_CALLRESULT
  10063. ,uuid
  10064. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  10065. json_object_put(SetChargingProfile);
  10066. LWS_Send(message);
  10067. result = TRUE;
  10068. return result;
  10069. }
  10070. int sendSetDisplayMessagesConfirmation(char *uuid)
  10071. {
  10072. mtrace();
  10073. int result = FAIL;
  10074. char message[4096]={0};
  10075. json_object *SetDisplayMessage = json_object_new_object();
  10076. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  10077. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  10078. sprintf(message,"[%d,\"%s\",%s]"
  10079. ,MESSAGE_TYPE_CALLRESULT
  10080. ,uuid
  10081. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  10082. json_object_put(SetDisplayMessage);
  10083. LWS_Send(message);
  10084. result = TRUE;
  10085. return result;
  10086. }
  10087. int sendSetMonitoringBaseConfirmation(char *uuid)
  10088. {
  10089. mtrace();
  10090. int result = FAIL;
  10091. char message[4096]={0};
  10092. json_object *SetMonitoringBase = json_object_new_object();
  10093. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  10094. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  10095. sprintf(message,"[%d,\"%s\",%s]"
  10096. ,MESSAGE_TYPE_CALLRESULT
  10097. ,uuid
  10098. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  10099. json_object_put(SetMonitoringBase);
  10100. LWS_Send(message);
  10101. result = TRUE;
  10102. return result;
  10103. }
  10104. int sendSetMonitoringLevelConfirmation(char *uuid)
  10105. {
  10106. mtrace();
  10107. int result = FAIL;
  10108. char message[4096]={0};
  10109. json_object *SetMonitoringLevel = json_object_new_object();
  10110. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  10111. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  10112. sprintf(message,"[%d,\"%s\",%s]"
  10113. ,MESSAGE_TYPE_CALLRESULT
  10114. ,uuid
  10115. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  10116. json_object_put(SetMonitoringLevel);
  10117. LWS_Send(message);
  10118. result = TRUE;
  10119. return result;
  10120. }
  10121. int sendSetNetworkProfileConfirmation(char *uuid)
  10122. {
  10123. mtrace();
  10124. int result = FAIL;
  10125. char message[4096]={0};
  10126. json_object *SetNetworkProfile = json_object_new_object();
  10127. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  10128. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  10129. sprintf(message,"[%d,\"%s\",%s]"
  10130. ,MESSAGE_TYPE_CALLRESULT
  10131. ,uuid
  10132. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  10133. json_object_put(SetNetworkProfile);
  10134. LWS_Send(message);
  10135. result = TRUE;
  10136. return result;
  10137. }
  10138. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  10139. {
  10140. mtrace();
  10141. int result = FAIL;
  10142. char message[4096]={0};
  10143. json_object *SetVariableMonitoring = json_object_new_object();
  10144. json_object *setMonitoringResults = json_object_new_array();
  10145. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  10146. for(int idx=0;idx<variableQuantity;idx++)
  10147. {
  10148. json_object *variableMonitorResult = json_object_new_object();
  10149. json_object *component = json_object_new_object();
  10150. json_object *variable = json_object_new_object();
  10151. json_object *evse = json_object_new_object();
  10152. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  10153. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  10154. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  10155. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  10156. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  10157. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  10158. json_object_object_add(component, "component", evse);
  10159. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  10160. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  10161. json_object_object_add(variableMonitorResult, "component", component);
  10162. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  10163. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  10164. json_object_object_add(variableMonitorResult, "variable", variable);
  10165. json_object_array_add(setMonitoringResults, variableMonitorResult);
  10166. }
  10167. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  10168. sprintf(message,"[%d,\"%s\",%s]"
  10169. ,MESSAGE_TYPE_CALLRESULT
  10170. ,uuid
  10171. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  10172. json_object_put(SetVariableMonitoring);
  10173. LWS_Send(message);
  10174. result = TRUE;
  10175. return result;
  10176. }
  10177. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  10178. {
  10179. mtrace();
  10180. int result = FAIL;
  10181. char message[4096]={0};
  10182. json_object *SetVariable = json_object_new_object();
  10183. json_object *setVariableResults = json_object_new_array();
  10184. DEBUG_INFO("sendSetVariableConfirmation...\n");
  10185. for(int idx=0;idx<variableQuantity;idx++)
  10186. {
  10187. json_object *variableResult = json_object_new_object();
  10188. json_object *component = json_object_new_object();
  10189. json_object *variable = json_object_new_object();
  10190. json_object *evse = json_object_new_object();
  10191. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  10192. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  10193. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  10194. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  10195. json_object_object_add(component, "evse", evse);
  10196. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  10197. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  10198. json_object_object_add(variableResult, "component", component);
  10199. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  10200. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  10201. json_object_object_add(variableResult, "variable", variable);
  10202. json_object_array_add(setVariableResults, variableResult);
  10203. }
  10204. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  10205. sprintf(message,"[%d,\"%s\",%s]"
  10206. ,MESSAGE_TYPE_CALLRESULT
  10207. ,uuid
  10208. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  10209. json_object_put(SetVariable);
  10210. LWS_Send(message);
  10211. result = TRUE;
  10212. return result;
  10213. }
  10214. int sendTriggerMessageConfirmation(char *uuid)
  10215. {
  10216. mtrace();
  10217. int result = FAIL;
  10218. char message[4096]={0};
  10219. json_object *TriggerMessage = json_object_new_object();
  10220. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  10221. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  10222. sprintf(message,"[%d,\"%s\",%s]",
  10223. MESSAGE_TYPE_CALLRESULT,
  10224. uuid,
  10225. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  10226. json_object_put(TriggerMessage);
  10227. LWS_Send(message);
  10228. result = TRUE;
  10229. return result;
  10230. }
  10231. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  10232. {
  10233. mtrace();
  10234. int result = FAIL;
  10235. char message[4096]={0};
  10236. json_object *UnlockConnector = json_object_new_object();
  10237. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  10238. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  10239. sprintf(message,"[%d,\"%s\",%s]",
  10240. MESSAGE_TYPE_CALLRESULT,
  10241. uuid,
  10242. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  10243. json_object_put(UnlockConnector);
  10244. LWS_Send(message);
  10245. result = TRUE;
  10246. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  10247. return result;
  10248. }
  10249. int sendUnpublishFirmwareConfirmation(char *uuid)
  10250. {
  10251. mtrace();
  10252. int result = FAIL;
  10253. char message[4096]={0};
  10254. json_object *UnpublishFirmware = json_object_new_object();
  10255. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  10256. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  10257. sprintf(message,"[%d,\"%s\",%s]"
  10258. ,MESSAGE_TYPE_CALLRESULT
  10259. ,uuid
  10260. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  10261. json_object_put(UnpublishFirmware);
  10262. LWS_Send(message);
  10263. result = TRUE;
  10264. return result;
  10265. }
  10266. int sendUpdateFirmwareConfirmation(char *uuid)
  10267. {
  10268. mtrace();
  10269. int result = FAIL;
  10270. char message[4096]={0};
  10271. json_object *UpdateFirmware = json_object_new_object();
  10272. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  10273. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  10274. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  10275. sprintf(message,"[%d,\"%s\",%s]"
  10276. ,MESSAGE_TYPE_CALLRESULT
  10277. ,uuid
  10278. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  10279. json_object_put(UpdateFirmware);
  10280. LWS_Send(message);
  10281. result = TRUE;
  10282. return result;
  10283. }
  10284. int sendUnknownConfirmation(char *uuid)
  10285. {
  10286. mtrace();
  10287. int result = FAIL;
  10288. char message[256]={0};
  10289. //[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
  10290. DEBUG_INFO("sendUnknownConfirmation...\n");
  10291. sprintf(message,"[%d,\"%s\",\"NotImplemented\",\"Requested Action is not known by receiver\",{}]", MESSAGE_TYPE_CALLERROR, uuid);
  10292. LWS_Send(message);
  10293. result = TRUE;
  10294. return result;
  10295. }
  10296. //==========================================
  10297. // send CallError routine
  10298. //==========================================
  10299. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  10300. {
  10301. mtrace();
  10302. char message[220]={0};
  10303. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  10304. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  10305. LWS_Send(message);
  10306. }
  10307. //==========================================
  10308. // Handle server request routine Start
  10309. //==========================================
  10310. int handleCancelReservationRequest(char *uuid, char *payload)
  10311. {
  10312. mtrace();
  10313. int result = FAIL;
  10314. int gunNO = 0;
  10315. int reservationIdInt = -1;
  10316. DEBUG_INFO("handleCancelReservationRequest...\n");
  10317. json_object *CancelReservation;
  10318. CancelReservation = json_tokener_parse(payload);
  10319. if(!is_error(CancelReservation))
  10320. {
  10321. // Required data
  10322. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  10323. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  10324. }
  10325. json_object_put(CancelReservation);
  10326. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  10327. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  10328. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  10329. if(reservationIdInt != -1)
  10330. {
  10331. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10332. //check Transaction active
  10333. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  10334. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10335. {
  10336. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  10337. {
  10338. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10339. if(gunType[2] == GUN_TYPE_CHAdeMO)
  10340. {
  10341. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  10342. }
  10343. else
  10344. {
  10345. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  10346. }
  10347. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10348. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10349. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10350. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10351. goto end;
  10352. }
  10353. }
  10354. for (int index = 0; index < CCS_QUANTITY; index++)
  10355. {
  10356. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  10357. {
  10358. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10359. if(gunType[2] == GUN_TYPE_CCS)
  10360. {
  10361. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  10362. }
  10363. else
  10364. {
  10365. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  10366. }
  10367. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10368. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10369. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10370. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10371. goto end;
  10372. }
  10373. }
  10374. for (int index = 0; index < GB_QUANTITY; index++)
  10375. {
  10376. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  10377. {
  10378. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10379. if(gunType[2] == GUN_TYPE_GBT)
  10380. {
  10381. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  10382. }
  10383. else
  10384. {
  10385. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  10386. }
  10387. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10388. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10389. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10390. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10391. goto end;
  10392. }
  10393. }
  10394. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10395. {
  10396. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId == reservationIdInt)
  10397. {
  10398. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10399. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  10400. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10401. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10402. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10403. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10404. goto end;
  10405. }
  10406. }
  10407. for (int index = 0; index < AC_QUANTITY; index++)
  10408. {
  10409. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  10410. {
  10411. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10412. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  10413. {
  10414. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  10415. }
  10416. else
  10417. {
  10418. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  10419. }
  10420. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10421. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10422. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10423. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10424. goto end;
  10425. }
  10426. }
  10427. }
  10428. //The reservationId does NOT match the reservationId
  10429. sendCancelReservationConfirmation(uuid, gunNO);
  10430. end:
  10431. // Fill in ocpp packet uuid
  10432. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  10433. return result;
  10434. }
  10435. int handleCertificateSignedRequest(char *uuid, char *payload)
  10436. {
  10437. mtrace();
  10438. int result = FAIL;
  10439. json_object *CertificateSigned;
  10440. DEBUG_INFO("handleCertificateSignedRequest...\n");
  10441. CertificateSigned = json_tokener_parse(payload);
  10442. if(!is_error(CertificateSigned))
  10443. {
  10444. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  10445. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  10446. // Required data
  10447. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateChain, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateChain")));
  10448. // Optional data
  10449. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  10450. {
  10451. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  10452. if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]) == 0)
  10453. {
  10454. FILE *fp = fopen("/Storage/OCPP/certCP.crt", "w");
  10455. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10456. fclose(fp);
  10457. }
  10458. else if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0)
  10459. {
  10460. FILE *fp = fopen("/Storage/OCPP/certV2G.crt", "w");
  10461. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10462. fclose(fp);
  10463. }
  10464. }
  10465. else
  10466. {
  10467. FILE *fp = fopen("/Storage/OCPP/certCP.crt", "w");
  10468. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10469. fclose(fp);
  10470. fp = fopen("/Storage/OCPP/certV2G.crt", "w");
  10471. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10472. fclose(fp);
  10473. }
  10474. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10475. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  10476. }
  10477. else
  10478. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  10479. json_object_put(CertificateSigned);
  10480. sendCertificateSignedConfirmation(uuid);
  10481. return result;
  10482. }
  10483. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  10484. {
  10485. mtrace();
  10486. int result = FAIL;
  10487. int evseId = 0, gunIndex = 0;
  10488. char operationalStatus[16]={0};
  10489. char comfirmstr[20];
  10490. int specificId = FALSE;
  10491. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  10492. json_object *ChangeAvailability;
  10493. ChangeAvailability = json_tokener_parse(payload);
  10494. if(!is_error(ChangeAvailability))
  10495. {
  10496. // Required data
  10497. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  10498. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  10499. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  10500. {
  10501. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  10502. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  10503. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  10504. }
  10505. }
  10506. json_object_put(ChangeAvailability);
  10507. if((evseId != 0) && (evseId <= gunTotalNumber))
  10508. {
  10509. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  10510. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  10511. }
  10512. else if(evseId == 0)
  10513. {
  10514. for(int i=0; i < gunTotalNumber; i++)
  10515. {
  10516. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  10517. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  10518. }
  10519. }
  10520. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  10521. {
  10522. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  10523. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  10524. }
  10525. else if(gunIndex == 0)
  10526. {
  10527. for(int i=0; i < gunTotalNumber; i++)
  10528. {
  10529. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  10530. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  10531. }
  10532. }
  10533. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  10534. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10535. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  10536. {
  10537. specificId = TRUE;
  10538. }
  10539. if(specificId == FALSE)
  10540. goto end;
  10541. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  10542. {
  10543. //----------------------gunIndex is 0 ------------------------------------------------//
  10544. if(gunIndex == 0)
  10545. {
  10546. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10547. {
  10548. for(int i=0; i < gunTotalNumber; i++)
  10549. {
  10550. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10551. {
  10552. if ((gunType[i] == GUN_TYPE_CHAdeMO)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  10553. {
  10554. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10555. {
  10556. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10557. goto end;
  10558. }
  10559. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10560. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10561. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10562. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10563. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10564. {
  10565. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10566. goto end;
  10567. }
  10568. }
  10569. }//END FOR CHAdeMO_QUANTITY
  10570. for (int index = 0; index < CCS_QUANTITY; index++)
  10571. {
  10572. if ((gunType[i] == GUN_TYPE_CCS)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  10573. {
  10574. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  10575. {
  10576. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10577. goto end;
  10578. }
  10579. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10580. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10581. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10582. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10583. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10584. {
  10585. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10586. goto end;
  10587. }
  10588. }
  10589. }//END FOR CCS_QUANTITY
  10590. for (int index = 0; index < GB_QUANTITY; index++)
  10591. {
  10592. if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  10593. {
  10594. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10595. {
  10596. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10597. goto end;
  10598. }
  10599. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10600. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10601. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10602. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10603. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10604. {
  10605. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10606. goto end;
  10607. }
  10608. }
  10609. }// END FOR GB_QUANTITY
  10610. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10611. {
  10612. if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i))
  10613. {
  10614. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10615. {
  10616. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10617. goto end;
  10618. }
  10619. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  10620. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  10621. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  10622. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  10623. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10624. {
  10625. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10626. goto end;
  10627. }
  10628. }
  10629. }// END FOR DO_QUANTITY
  10630. for (int index = 0; index < AC_QUANTITY; index++)
  10631. {
  10632. if ((gunType[i] == GUN_TYPE_AC)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  10633. {
  10634. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10635. {
  10636. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10637. goto end;
  10638. }
  10639. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10640. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10641. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10642. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10643. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10644. {
  10645. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10646. goto end;
  10647. }
  10648. }
  10649. }//END FOR AC_QUANTITY
  10650. }// END FOR gunTotalNumber
  10651. }
  10652. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  10653. {
  10654. for(int i=0; i < gunTotalNumber; i++)
  10655. {
  10656. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10657. {
  10658. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10659. goto end;
  10660. }
  10661. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10662. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  10663. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  10664. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  10665. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10666. {
  10667. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10668. goto end;
  10669. }
  10670. }
  10671. }
  10672. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10673. goto end;
  10674. }
  10675. //----------------------gunIndex is not 0 ------------------------------------------------//
  10676. //check Transaction active
  10677. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10678. {
  10679. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO))
  10680. {
  10681. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  10682. {
  10683. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10684. goto end;
  10685. }
  10686. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10687. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10688. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10689. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10690. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10691. {
  10692. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10693. goto end;
  10694. }
  10695. else
  10696. {
  10697. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  10698. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10699. goto end;
  10700. }
  10701. }
  10702. }//END FOR CHAdeMO_QUANTITY
  10703. for (int index = 0; index < CCS_QUANTITY; index++)
  10704. {
  10705. if ((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS))
  10706. {
  10707. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  10708. {
  10709. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10710. goto end;
  10711. }
  10712. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10713. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10714. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10715. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10716. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10717. {
  10718. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10719. goto end;
  10720. }
  10721. else
  10722. {
  10723. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  10724. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10725. goto end;
  10726. }
  10727. }
  10728. }//END FOR CCS_QUANTITY
  10729. for (int index = 0; index < GB_QUANTITY; index++)
  10730. {
  10731. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))
  10732. {
  10733. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  10734. {
  10735. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10736. goto end;
  10737. }
  10738. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10739. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10740. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10741. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10742. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10743. {
  10744. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10745. goto end;
  10746. }
  10747. else
  10748. {
  10749. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  10750. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10751. goto end;
  10752. }
  10753. }
  10754. }// END FOR GB_QUANTITY
  10755. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10756. {
  10757. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))
  10758. {
  10759. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  10760. {
  10761. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10762. goto end;
  10763. }
  10764. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  10765. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  10766. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  10767. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  10768. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10769. {
  10770. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10771. goto end;
  10772. }
  10773. else
  10774. {
  10775. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  10776. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10777. goto end;
  10778. }
  10779. }
  10780. }// END FOR DO_QUANTITY
  10781. for (int index = 0; index < AC_QUANTITY; index++)
  10782. {
  10783. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC))
  10784. {
  10785. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  10786. {
  10787. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10788. goto end;
  10789. }
  10790. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10791. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10792. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10793. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10794. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10795. {
  10796. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10797. goto end;
  10798. }
  10799. else
  10800. {
  10801. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  10802. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10803. goto end;
  10804. }
  10805. }
  10806. }//END FOR AC_QUANTITY
  10807. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  10808. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  10809. {
  10810. //----------------------gunIndex is 0 ------------------------------------------------//
  10811. if(gunIndex == 0)
  10812. {
  10813. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10814. {
  10815. for(int i=0; i < gunTotalNumber; i++)
  10816. {
  10817. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10818. {
  10819. 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
  10820. {
  10821. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10822. goto end;
  10823. }
  10824. }//END FOR CHAdeMO_QUANTITY
  10825. for (int index = 0; index < CCS_QUANTITY; index++)
  10826. {
  10827. 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
  10828. {
  10829. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10830. goto end;
  10831. }
  10832. }//END FOR CCS_QUANTITY
  10833. for (int index = 0; index < GB_QUANTITY; index++)
  10834. {
  10835. 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
  10836. {
  10837. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  10838. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10839. goto end;
  10840. }
  10841. }// END FOR GB_QUANTITY
  10842. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10843. {
  10844. 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
  10845. {
  10846. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  10847. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10848. goto end;
  10849. }
  10850. }// END FOR DO_QUANTITY
  10851. for (int index = 0; index < AC_QUANTITY; index++)
  10852. {
  10853. 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
  10854. {
  10855. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10856. goto end;
  10857. }
  10858. }//END FOR CHAdeMO_QUANTITY
  10859. }// END FOR gunTotalNumber
  10860. }
  10861. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  10862. {
  10863. for(int i=0; i < gunTotalNumber; i++)
  10864. {
  10865. for (int index = 0; index < AC_QUANTITY; index++)
  10866. {
  10867. 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
  10868. {
  10869. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10870. goto end;
  10871. }
  10872. }//END FOR CHAdeMO_QUANTITY
  10873. } // END FOR gunTotalNumber
  10874. }
  10875. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10876. goto end;
  10877. }
  10878. //----------------------gunIndex is not 0 ------------------------------------------------//
  10879. //check Transaction active
  10880. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10881. {
  10882. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10883. {
  10884. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10885. goto end;
  10886. }
  10887. }//END FOR CHAdeMO_QUANTITY
  10888. for (int index = 0; index < CCS_QUANTITY; index++)
  10889. {
  10890. if ((((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS)) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10891. {
  10892. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10893. goto end;
  10894. }
  10895. }//END FOR CCS_QUANTITY
  10896. for (int index = 0; index < GB_QUANTITY; index++)
  10897. {
  10898. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10899. {
  10900. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10901. goto end;
  10902. }
  10903. }// END FOR GB_QUANTITY
  10904. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10905. {
  10906. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10907. {
  10908. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10909. goto end;
  10910. }
  10911. }// END FOR DO_QUANTITY
  10912. for (int index = 0; index < AC_QUANTITY; index++)
  10913. {
  10914. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC)) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10915. {
  10916. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10917. goto end;
  10918. }
  10919. }//END FOR AC_QUANTITY
  10920. }//END FOR AvailabilityEnumTypeStr[Operative]
  10921. end:
  10922. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  10923. {
  10924. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  10925. }
  10926. else
  10927. {
  10928. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  10929. }
  10930. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  10931. {
  10932. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  10933. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  10934. }
  10935. else if(gunIndex == 0)
  10936. {
  10937. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  10938. {
  10939. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  10940. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  10941. }
  10942. }
  10943. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  10944. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10945. return result;
  10946. }
  10947. int handleClearCacheRequest(char *uuid, char *payload)
  10948. {
  10949. mtrace();
  10950. int result = FAIL;
  10951. char rmFileCmd[100]={0};
  10952. struct stat stats;
  10953. DEBUG_INFO("handleClearCacheRequest...\n");
  10954. stat("/Storage/OCPP", &stats);
  10955. // Check for directory existence
  10956. if (S_ISDIR(stats.st_mode) == 1)
  10957. {}
  10958. else
  10959. {
  10960. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  10961. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  10962. system(rmFileCmd);
  10963. }
  10964. if(DB_cleanLocalCache() != PASS)
  10965. {
  10966. DEBUG_INFO("open AuthorizationCache file failed\n");
  10967. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  10968. }
  10969. else
  10970. {
  10971. DEBUG_INFO("open AuthorizationCache file successful\n");
  10972. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  10973. }
  10974. sendClearCacheConfirmation(uuid);
  10975. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10976. return result;
  10977. }
  10978. int handleClearChargingProfileRequest(char *uuid, char *payload)
  10979. {
  10980. mtrace();
  10981. int result = FAIL;
  10982. int resultRename;
  10983. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  10984. char chargingProfilePurposeStr[26]={0};
  10985. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  10986. char tempchargingProfilePurposeStr[26]={0};
  10987. char sstr[160]={0};
  10988. char str[100]={0};
  10989. int c = 0;
  10990. char *loc;
  10991. char fname[200]={0};
  10992. char comfirmstr[20]={0};
  10993. char word[1600]={0};
  10994. int clearflag = FALSE;
  10995. int chargingProfileIdIsNULL = FALSE;
  10996. int connectorIsNULL = FALSE;
  10997. int chargingProfilePurposeIsNULL = FALSE;
  10998. int stackLevelIsNULL = FALSE;
  10999. //int GotoEnd = FALSE;
  11000. FILE *fptr1, *fptr2;
  11001. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  11002. int n_chargingProfile=0;
  11003. int isEmptyFile = FALSE;
  11004. char sLineWord[1600]={0};
  11005. char chargingProfiles[10][100]={0};
  11006. int ChargeProfileCount = 0;
  11007. int ch;
  11008. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  11009. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  11010. json_object *ClearChargingProfile;
  11011. ClearChargingProfile = json_tokener_parse(payload);
  11012. if(!is_error(ClearChargingProfile))
  11013. {
  11014. // Optional data
  11015. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  11016. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  11017. else
  11018. chargingProfileIdIsNULL = TRUE;
  11019. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  11020. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  11021. else
  11022. connectorIsNULL = TRUE;
  11023. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  11024. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  11025. else
  11026. chargingProfilePurposeIsNULL = TRUE;
  11027. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  11028. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  11029. else
  11030. stackLevelIsNULL = TRUE;
  11031. }
  11032. json_object_put(ClearChargingProfile);
  11033. if(connectorIsNULL == FALSE)
  11034. {
  11035. switch(connectorIdInt)
  11036. {
  11037. case 0:
  11038. if(chargingProfilePurposeIsNULL == TRUE)
  11039. {
  11040. int l = 0;
  11041. strcpy(fname, ChargePointMaxProfile_JSON);
  11042. if((access(fname,F_OK))!=-1)
  11043. {
  11044. strcpy(chargingProfiles[l], fname);
  11045. l = l + 1;
  11046. }
  11047. strcpy(fname, TxDefaultProfile_0_JSON);
  11048. if((access(fname,F_OK))!=-1)
  11049. {
  11050. strcpy(chargingProfiles[l], fname);
  11051. l = l + 1;
  11052. }
  11053. ChargeProfileCount = l;
  11054. }
  11055. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  11056. {
  11057. strcpy(fname, ChargePointMaxProfile_JSON);
  11058. if((access(fname,F_OK))!=-1)
  11059. {
  11060. strcpy(chargingProfiles[0], fname);
  11061. ChargeProfileCount = 1;
  11062. }
  11063. }
  11064. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  11065. {
  11066. strcpy(fname, TxDefaultProfile_0_JSON);
  11067. if((access(fname,F_OK))!=-1)
  11068. {
  11069. strcpy(chargingProfiles[0], fname);
  11070. ChargeProfileCount = 1;
  11071. }
  11072. }
  11073. break;
  11074. default:
  11075. if(chargingProfilePurposeIsNULL == TRUE)
  11076. {
  11077. int m = 0;
  11078. memset(fname, 0, ARRAY_SIZE(fname));
  11079. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", connectorIdInt);
  11080. if((access(fname,F_OK))!=-1)
  11081. {
  11082. strcpy(chargingProfiles[m], fname);
  11083. m = m + 1;
  11084. }
  11085. memset(fname, 0, ARRAY_SIZE(fname));
  11086. sprintf(fname, "/Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdInt);
  11087. if((access(fname,F_OK))!=-1)
  11088. {
  11089. strcpy(chargingProfiles[m], fname);
  11090. m = m + 1;
  11091. }
  11092. ChargeProfileCount = m;
  11093. }
  11094. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  11095. {
  11096. //strcpy(fname, TxDefaultProfile_1_JSON);
  11097. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", connectorIdInt);
  11098. if((access(fname,F_OK))!=-1)
  11099. {
  11100. strcpy(chargingProfiles[0], fname);
  11101. ChargeProfileCount = 1;
  11102. }
  11103. }
  11104. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  11105. {
  11106. sprintf(fname, "/Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdInt);
  11107. if((access(fname,F_OK))!=-1)
  11108. {
  11109. strcpy(chargingProfiles[0], fname);
  11110. ChargeProfileCount = 1;
  11111. }
  11112. }
  11113. //strcpy(fname, ChargePointMaxProfile_JSON );
  11114. break;
  11115. }
  11116. }
  11117. else // Check all Charging Profiles
  11118. {
  11119. int i = 0;
  11120. char fnametemp[200]={0};
  11121. ChargeProfileCount = 0;
  11122. //Check ChargePointMaxProfile.json exit
  11123. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  11124. {
  11125. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  11126. i = i + 1;
  11127. }
  11128. //Check TxDefaultProfile_%d.json
  11129. for(int j=1; j <= gunTotalNumber; j++)
  11130. {
  11131. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  11132. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", j);
  11133. if((access(fnametemp,F_OK))!=-1)
  11134. {
  11135. strcpy(chargingProfiles[i], fnametemp);
  11136. i = i + 1;
  11137. }
  11138. }
  11139. //Check TxProfile_%d.json
  11140. for(int j=1; j <= gunTotalNumber; j++)
  11141. {
  11142. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  11143. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d_OCPP20.json", j);
  11144. if((access(fnametemp,F_OK))!=-1)
  11145. {
  11146. strcpy(chargingProfiles[i], fnametemp);
  11147. i = i + 1;
  11148. }
  11149. }
  11150. ChargeProfileCount = i;
  11151. }// End connectorIsNULL is TRUE
  11152. if(ChargeProfileCount == 0)
  11153. {
  11154. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11155. goto end;
  11156. }
  11157. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  11158. {
  11159. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11160. goto end;
  11161. }
  11162. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  11163. {
  11164. memset(str, 0, ARRAY_SIZE(str));
  11165. // clear temp file
  11166. sprintf(str,"rm -f %s",temp);
  11167. system(str);
  11168. for(int k=0; k < ChargeProfileCount; k++)
  11169. {
  11170. memset(str, 0, ARRAY_SIZE(str));
  11171. //clear file in C
  11172. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11173. system(str);
  11174. }
  11175. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11176. goto end;
  11177. }
  11178. else if(connectorIsNULL == TRUE)
  11179. {
  11180. for(int k=0; k < ChargeProfileCount; k++)
  11181. {
  11182. fptr1 = fopen(chargingProfiles[k], "r");
  11183. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  11184. //Check Charging Profile Count
  11185. while(fscanf(fptr1, "%s", word) != EOF)
  11186. {
  11187. //DEBUG_INFO("word=%s\n",word);
  11188. if(strstr(word, "id")!= NULL)
  11189. {
  11190. //DEBUG_INFO("test id \n");
  11191. n_chargingProfile = n_chargingProfile + 1;
  11192. //DEBUG_INFO("id Found\n");
  11193. }
  11194. }
  11195. rewind(fptr1);
  11196. //search Charging Profile Element
  11197. //int i= 0;
  11198. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  11199. {
  11200. //------------------------tempconnectorIdInt------------------------//
  11201. loc = strstr(sLineWord, "connectorId");
  11202. c = 0;
  11203. memset(sstr ,0, sizeof(sstr) );
  11204. while (loc[strlen("connectorId")+2+c] != ',')
  11205. {
  11206. sstr[c] = loc[strlen("connectorId")+2+c];
  11207. c++;
  11208. }
  11209. sstr[c] = '\0';
  11210. tempconnectorIdInt = atoi(sstr);
  11211. printf("file's gun number is %d\n", tempconnectorIdInt);
  11212. //--------------------------id--------------------//
  11213. c = 0;
  11214. loc = strstr(sLineWord, "id");
  11215. memset(sstr ,0, ARRAY_SIZE(sstr));
  11216. while (loc[strlen("id")+2+c] != ',')
  11217. {
  11218. sstr[c] = loc[strlen("id")+2+c];
  11219. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11220. c++;
  11221. }
  11222. sstr[c] = '\0';
  11223. tempchargingProfileIdInt = atoi(sstr);
  11224. //stackLevel
  11225. c = 0;
  11226. loc = strstr(sLineWord, "stackLevel");
  11227. memset(sstr ,0, ARRAY_SIZE(sstr));
  11228. while (loc[strlen("stackLevel")+2+c] != ',')
  11229. {
  11230. sstr[c] = loc[strlen("stackLevel")+2+c];
  11231. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11232. c++;
  11233. }
  11234. sstr[c] = '\0';
  11235. tempstackLevelInt = atoi(sstr);
  11236. c = 0;
  11237. loc = strstr(sLineWord, "chargingProfilePurpose");
  11238. memset(sstr ,0, ARRAY_SIZE(sstr));
  11239. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  11240. {
  11241. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  11242. c++;
  11243. }
  11244. sstr[c] = '\0';
  11245. strcpy(tempchargingProfilePurposeStr, sstr);
  11246. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  11247. {
  11248. //------- not write to fptr2-------//
  11249. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11250. //clearflag = TRUE;
  11251. }
  11252. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  11253. {
  11254. //------- not write to fptr2-------//
  11255. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11256. }
  11257. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  11258. {
  11259. //------- not write to fptr2-------//
  11260. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11261. }
  11262. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  11263. {
  11264. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11265. }
  11266. else
  11267. {
  11268. fprintf(fptr2, sLineWord);//writing data into file
  11269. }
  11270. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11271. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  11272. if(clearflag == TRUE)
  11273. {
  11274. fclose(fptr1);
  11275. fclose(fptr2);
  11276. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11277. system(str);
  11278. // clear temp file
  11279. sprintf(str,"rm -f %s",temp);
  11280. system(str);
  11281. }
  11282. else
  11283. {
  11284. fclose(fptr1);
  11285. fclose(fptr2);
  11286. memset(str, 0, ARRAY_SIZE(str));
  11287. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11288. system(str);
  11289. resultRename = rename(temp, chargingProfiles[k]);
  11290. if(resultRename == 0)
  11291. {
  11292. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  11293. }
  11294. else
  11295. {
  11296. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  11297. }
  11298. if(comfirmstr[0]== 0)
  11299. {
  11300. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11301. }
  11302. //Check chargingProfile is empty file
  11303. /*------ Read the file ----------------*/
  11304. fptr1=fopen(chargingProfiles[k],"r");
  11305. ch=fgetc(fptr1);
  11306. rewind(fptr1);
  11307. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11308. if(ch!=EOF)
  11309. {
  11310. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  11311. {
  11312. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  11313. if(sLineWord[0]=='\0')
  11314. {
  11315. isEmptyFile = TRUE;
  11316. break;
  11317. }
  11318. else
  11319. {
  11320. isEmptyFile = FALSE;
  11321. break;
  11322. }
  11323. }
  11324. }
  11325. else
  11326. isEmptyFile = TRUE;
  11327. fclose(fptr1);
  11328. if(isEmptyFile == TRUE)
  11329. {
  11330. memset(str, 0, ARRAY_SIZE(str));
  11331. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11332. system(str);
  11333. }
  11334. }
  11335. }// End of while(int k=0; k < ChargePointCount; k++)
  11336. }
  11337. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  11338. {
  11339. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  11340. for(int k=0; k < ChargeProfileCount; k++)
  11341. {
  11342. fptr1 = fopen(chargingProfiles[k], "r");
  11343. fptr2 = fopen(temp, "w+");
  11344. //Check Charging Profile Count
  11345. while(fscanf(fptr1, "%s", word) != EOF)
  11346. {
  11347. //DEBUG_INFO("word=%s\n",word);
  11348. if(strstr(word, "id")!= NULL)
  11349. {
  11350. n_chargingProfile = n_chargingProfile + 1;
  11351. }
  11352. }
  11353. rewind(fptr1);
  11354. //search Charging Profile Element
  11355. //int i= 0;
  11356. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  11357. {
  11358. //*************************tempconnectorIdInt*********************************/
  11359. loc = strstr(sLineWord, "connectorId");
  11360. c = 0;
  11361. memset(sstr ,0, ARRAY_SIZE(sstr));
  11362. while (loc[strlen("connectorId")+2+c] != ',')
  11363. {
  11364. sstr[c] = loc[strlen("connectorId")+2+c];
  11365. c++;
  11366. }
  11367. sstr[c] = '\0';
  11368. tempconnectorIdInt = atoi(sstr);
  11369. //id
  11370. c = 0;
  11371. loc = strstr(sLineWord, "id");
  11372. memset(sstr ,0, ARRAY_SIZE(sstr));
  11373. while (loc[strlen("id")+2+c] != ',')
  11374. {
  11375. sstr[c] = loc[strlen("id")+2+c];
  11376. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11377. c++;
  11378. }
  11379. sstr[c] = '\0';
  11380. tempchargingProfileIdInt = atoi(sstr);
  11381. //stackLevel
  11382. c = 0;
  11383. loc = strstr(sLineWord, "stackLevel");
  11384. memset(sstr ,0, ARRAY_SIZE(sstr));
  11385. while (loc[strlen("stackLevel")+2+c] != ',')
  11386. {
  11387. sstr[c] = loc[strlen("stackLevel")+2+c];
  11388. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11389. c++;
  11390. }
  11391. sstr[c] = '\0';
  11392. tempstackLevelInt = atoi(sstr);
  11393. c = 0;
  11394. loc = strstr(sLineWord, "chargingProfilePurpose");
  11395. memset(sstr ,0, ARRAY_SIZE(sstr));
  11396. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  11397. {
  11398. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  11399. c++;
  11400. }
  11401. sstr[c] = '\0';
  11402. strcpy(tempchargingProfilePurposeStr, sstr);
  11403. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  11404. {
  11405. //------- not write to fptr2-------//
  11406. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11407. //clearflag = TRUE;
  11408. }
  11409. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  11410. {
  11411. //------- not write to fptr2-------//
  11412. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11413. }
  11414. else if(stackLevelIsNULL == TRUE)
  11415. {
  11416. //Clear Whole File
  11417. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11418. clearflag = TRUE;
  11419. break;
  11420. }
  11421. else
  11422. {
  11423. fprintf(fptr2, sLineWord);//writing data into file
  11424. }
  11425. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11426. }
  11427. if(clearflag == TRUE)
  11428. {
  11429. fclose(fptr1);
  11430. fclose(fptr2);
  11431. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11432. system(str);
  11433. // clear temp file
  11434. sprintf(str,"rm -f %s",temp);
  11435. system(str);
  11436. }
  11437. else
  11438. {
  11439. fclose(fptr1);
  11440. fclose(fptr2);
  11441. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11442. system(str);
  11443. resultRename = rename(temp, chargingProfiles[k]);
  11444. if(resultRename == 0)
  11445. {
  11446. DEBUG_INFO("File ChargingProfile renamed successfully");
  11447. }
  11448. else
  11449. {
  11450. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  11451. }
  11452. if(comfirmstr[0]== 0)
  11453. {
  11454. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11455. }
  11456. //Check chargingProfile is empty file
  11457. /*------ Read the file ----------------*/
  11458. fptr1=fopen(chargingProfiles[k],"r");
  11459. ch=fgetc(fptr1);
  11460. rewind(fptr1);
  11461. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11462. if(ch!=EOF)
  11463. {
  11464. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  11465. {
  11466. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  11467. if(sLineWord[0]=='\0')
  11468. {
  11469. isEmptyFile = TRUE;
  11470. break;
  11471. }
  11472. else
  11473. {
  11474. isEmptyFile = FALSE;
  11475. break;
  11476. }
  11477. }
  11478. }
  11479. else
  11480. isEmptyFile = TRUE;
  11481. fclose(fptr1);
  11482. if(isEmptyFile == TRUE)
  11483. {
  11484. memset(str, 0, ARRAY_SIZE(str));
  11485. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11486. system(str);
  11487. }
  11488. /*------- End of reading ---------------*/
  11489. }
  11490. } // while(int k=0; k < ChargeProfileCount; k++)
  11491. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  11492. end:
  11493. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  11494. {
  11495. if(connectorIdInt == 0)
  11496. {
  11497. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  11498. {
  11499. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  11500. }
  11501. }
  11502. else
  11503. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1], 0, TRUE);
  11504. }
  11505. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  11506. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11507. return result;
  11508. }
  11509. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  11510. {
  11511. mtrace();
  11512. int result = FAIL;
  11513. json_object *ClearDisplayMessage;
  11514. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  11515. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  11516. ClearDisplayMessage = json_tokener_parse(payload);
  11517. if(!is_error(ClearDisplayMessage))
  11518. {
  11519. // Required data
  11520. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  11521. {
  11522. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  11523. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  11524. }
  11525. }
  11526. json_object_put(ClearDisplayMessage);
  11527. sendCostUpdatedConfirmation(uuid);
  11528. return result;
  11529. }
  11530. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  11531. {
  11532. mtrace();
  11533. int result = FAIL;
  11534. json_object *ClearVariableMonitorin;
  11535. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  11536. ClearVariableMonitorin = json_tokener_parse(payload);
  11537. if(!is_error(ClearVariableMonitorin))
  11538. {
  11539. // Required data
  11540. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  11541. {
  11542. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  11543. {
  11544. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  11545. /*
  11546. * TODO:
  11547. * 1. Check response
  11548. */
  11549. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  11550. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  11551. }
  11552. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  11553. }
  11554. }
  11555. json_object_put(ClearVariableMonitorin);
  11556. return result;
  11557. }
  11558. int handleCostUpdatedRequest(char *uuid, char *payload)
  11559. {
  11560. mtrace();
  11561. int result = FAIL;
  11562. json_object *CostUpdate;
  11563. DEBUG_INFO("handleCostUpdatedRequest...\n");
  11564. CostUpdate = json_tokener_parse(payload);
  11565. if(!is_error(CostUpdate))
  11566. {
  11567. // Required data
  11568. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  11569. {
  11570. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  11571. }
  11572. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  11573. {
  11574. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  11575. }
  11576. }
  11577. json_object_put(CostUpdate);
  11578. sendCostUpdatedConfirmation(uuid);
  11579. return result;
  11580. }
  11581. int handleCustomerInformationRequest(char *uuid, char *payload)
  11582. {
  11583. mtrace();
  11584. int result = FAIL;
  11585. json_object *CustomerInformation;
  11586. DEBUG_INFO("handleCustomerInformationRequest...\n");
  11587. CustomerInformation = json_tokener_parse(payload);
  11588. if(!is_error(CustomerInformation))
  11589. {
  11590. // Required data
  11591. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  11592. {
  11593. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  11594. }
  11595. if(json_object_object_get(CustomerInformation, "report") != NULL)
  11596. {
  11597. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  11598. }
  11599. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  11600. {
  11601. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  11602. }
  11603. // Optional data
  11604. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  11605. {
  11606. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  11607. {
  11608. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  11609. }
  11610. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  11611. {
  11612. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  11613. }
  11614. }
  11615. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  11616. {
  11617. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  11618. {
  11619. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  11620. }
  11621. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  11622. {
  11623. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  11624. }
  11625. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  11626. {
  11627. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  11628. }
  11629. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  11630. {
  11631. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  11632. }
  11633. }
  11634. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  11635. }
  11636. else
  11637. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  11638. json_object_put(CustomerInformation);
  11639. sendCustomerInformationConfirmation(uuid);
  11640. return result;
  11641. }
  11642. void createFirmwareVersionByDataTransfer(void)
  11643. {
  11644. json_object *FirmwareDataTransfer = json_object_new_object();
  11645. // AC & DC model
  11646. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  11647. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  11648. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  11649. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  11650. // DC model
  11651. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  11652. {
  11653. if((gunType[1] != GUN_TYPE_UNKNOWN) ||
  11654. (gunType[2] != GUN_TYPE_UNKNOWN) ||
  11655. (gunType[3] != GUN_TYPE_UNKNOWN))
  11656. {
  11657. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  11658. }
  11659. if((ShmSysConfigAndInfo->SysConfig.ModelName[1]!='B') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='K') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O'))
  11660. {
  11661. // DS DM DW
  11662. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  11663. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  11664. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  11665. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  11666. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  11667. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  11668. }
  11669. else
  11670. {
  11671. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  11672. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  11673. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  11674. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  11675. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  11676. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  11677. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  11678. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  11679. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  11680. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  11681. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  11682. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  11683. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  11684. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  11685. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  11686. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  11687. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  11688. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  11689. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  11690. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  11691. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  11692. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  11693. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  11694. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  11695. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  11696. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  11697. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  11698. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  11699. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  11700. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  11701. json_object_object_add(FirmwareDataTransfer, "D11_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  11702. }
  11703. }
  11704. // 4G model
  11705. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  11706. {
  11707. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  11708. }
  11709. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
  11710. json_object_put(FirmwareDataTransfer);
  11711. }
  11712. int handleDataTransferRequest(char *uuid, char *payload)
  11713. {
  11714. mtrace();
  11715. int result = PASS;
  11716. DEBUG_INFO("handleDataTransferRequest...\n");
  11717. if((uuid != NULL) && (payload != NULL))
  11718. {
  11719. json_object *DataTransfer;
  11720. DataTransfer = json_tokener_parse(payload);
  11721. if(!is_error(DataTransfer))
  11722. {
  11723. // Required data
  11724. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  11725. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  11726. // Optional data
  11727. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  11728. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  11729. if(json_object_object_get(DataTransfer, "data") != NULL)
  11730. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  11731. result = PASS;
  11732. }
  11733. json_object_put(DataTransfer);
  11734. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  11735. {
  11736. // Send all moudle firmware version on EVSE
  11737. createFirmwareVersionByDataTransfer();
  11738. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11739. }
  11740. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  11741. {
  11742. system("/usr/bin/run_tmate_restart.sh &");
  11743. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11744. }
  11745. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_ChargingPreference") != NULL)
  11746. {
  11747. json_object *data;
  11748. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11749. if(!is_error(data))
  11750. {
  11751. if((json_object_object_get(data, "ConnectorId") != NULL) && (json_object_get_int(json_object_object_get(data, "ConnectorId")) > 0) && (json_object_get_int(json_object_object_get(data, "ConnectorId")) <= gunTotalNumber))
  11752. {
  11753. DEBUG_INFO("ChargeingPreference connector id: %d\n", json_object_get_int(json_object_object_get(data, "ConnectorId")));
  11754. memset(&ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))], 0x00, sizeof(struct StructSessionTarget));
  11755. if(json_object_object_get(data, "SOC") != NULL)
  11756. {
  11757. ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetSoc = json_object_get_int(json_object_object_get(data, "SOC"));
  11758. DEBUG_INFO("ChargeingPreference target soc: %d\n", json_object_get_int(json_object_object_get(data, "SOC")));
  11759. }
  11760. if(json_object_object_get(data, "Energy") != NULL)
  11761. {
  11762. ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetEnergy = json_object_get_int(json_object_object_get(data, "Energy"));
  11763. DEBUG_INFO("ChargeingPreference target energy: %d KWH\n", json_object_get_int(json_object_object_get(data, "Energy")));
  11764. }
  11765. if(json_object_object_get(data, "Duration") != NULL)
  11766. {
  11767. ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetDuration = json_object_get_int(json_object_object_get(data, "Duration"));
  11768. DEBUG_INFO("ChargeingPreference target duration: %d minutes\n", json_object_get_int(json_object_object_get(data, "Duration")));
  11769. }
  11770. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11771. }
  11772. else
  11773. {
  11774. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11775. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Connector id must > 0.");
  11776. }
  11777. }
  11778. else
  11779. {
  11780. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11781. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11782. }
  11783. json_object_put(data);
  11784. }
  11785. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  11786. {
  11787. json_object *data;
  11788. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11789. if(!is_error(data))
  11790. {
  11791. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  11792. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  11793. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  11794. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  11795. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  11796. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  11797. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  11798. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  11799. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  11800. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  11801. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11802. }
  11803. else
  11804. {
  11805. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11806. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11807. }
  11808. json_object_put(data);
  11809. }
  11810. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_ConfigQR") != NULL)
  11811. {
  11812. json_object *data;
  11813. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11814. if(!is_error(data))
  11815. {
  11816. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11817. if(json_object_object_get(data, "Content_Type") != NULL)
  11818. {
  11819. 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))
  11820. {
  11821. ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode = json_object_get_int(json_object_object_get(data, "Content_Type"));
  11822. if(json_object_object_get(data, "Customization_Conent") != NULL)
  11823. {
  11824. sprintf((char*)ShmSysConfigAndInfo->SysConfig.QRCodeContent, "%s", json_object_get_string(json_object_object_get(data, "Customization_Conent")));
  11825. }
  11826. }
  11827. else
  11828. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11829. }
  11830. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  11831. }
  11832. else
  11833. {
  11834. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11835. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11836. }
  11837. json_object_put(data);
  11838. }
  11839. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_DisplayLcdPage") != NULL)
  11840. {
  11841. json_object *data;
  11842. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11843. if(!is_error(data))
  11844. {
  11845. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11846. if(json_object_object_get(data, "ConnectorId") != NULL)
  11847. {
  11848. ShmSysConfigAndInfo->SysInfo.LcdOveride.connectorId = json_object_get_int(json_object_object_get(data, "ConnectorId"));
  11849. }
  11850. if(json_object_object_get(data, "Page_Index") != NULL)
  11851. {
  11852. ShmSysConfigAndInfo->SysInfo.LcdOveride.page_index = json_object_get_int(json_object_object_get(data, "Page_Index"));
  11853. }
  11854. if(json_object_object_get(data, "Duration") != NULL)
  11855. {
  11856. ShmSysConfigAndInfo->SysInfo.LcdOveride.duration = json_object_get_int(json_object_object_get(data, "Duration"));
  11857. }
  11858. ShmSysConfigAndInfo->SysInfo.LcdOveride.isOverideReq = ON;
  11859. }
  11860. else
  11861. {
  11862. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11863. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11864. }
  11865. json_object_put(data);
  11866. }
  11867. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_CpConfiguration") != NULL)
  11868. {
  11869. json_object *data;
  11870. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11871. if(!is_error(data))
  11872. {
  11873. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11874. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, " ");
  11875. if(json_object_object_get(data, "MaxChargingCurrent") != NULL)
  11876. {
  11877. if(json_object_get_int(json_object_object_get(data, "MaxChargingCurrent")) >= 0)
  11878. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent = json_object_get_int(json_object_object_get(data, "MaxChargingCurrent"));
  11879. else
  11880. {
  11881. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11882. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11883. }
  11884. }
  11885. if(json_object_object_get(data, "MaxChargingDuration") != NULL)
  11886. {
  11887. if(json_object_get_int(json_object_object_get(data, "MaxChargingDuration")) >= 0)
  11888. ShmSysConfigAndInfo->SysConfig.MaxChargingDuration = json_object_get_int(json_object_object_get(data, "MaxChargingDuration"));
  11889. else
  11890. {
  11891. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11892. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11893. }
  11894. }
  11895. if(json_object_object_get(data, "MaxChargingEnergy") != NULL)
  11896. {
  11897. if(json_object_get_int(json_object_object_get(data, "MaxChargingEnergy")) >= 0)
  11898. ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy = json_object_get_int(json_object_object_get(data, "MaxChargingEnergy"));
  11899. else
  11900. {
  11901. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11902. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11903. }
  11904. }
  11905. if(json_object_object_get(data, "MaxChargingPower") != NULL)
  11906. {
  11907. if(json_object_get_int(json_object_object_get(data, "MaxChargingPower")) >= 0)
  11908. ShmSysConfigAndInfo->SysConfig.MaxChargingPower = json_object_get_int(json_object_object_get(data, "MaxChargingPower"));
  11909. else
  11910. {
  11911. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11912. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11913. }
  11914. }
  11915. if(json_object_object_get(data, "OfflineMaxChargeEnergy") != NULL)
  11916. {
  11917. if(json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy")) >= 0)
  11918. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy"));
  11919. else
  11920. {
  11921. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11922. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11923. }
  11924. }
  11925. if(json_object_object_get(data, "OfflinePolicy") != NULL)
  11926. {
  11927. if((json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 0) ||
  11928. (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 2) ||
  11929. (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 3))
  11930. ShmSysConfigAndInfo->SysConfig.OfflinePolicy = json_object_get_int(json_object_object_get(data, "OfflinePolicy"));
  11931. else
  11932. {
  11933. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11934. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11935. }
  11936. }
  11937. if(json_object_object_get(data, "isAuthentication") != NULL)
  11938. {
  11939. switch(json_object_get_int(json_object_object_get(data, "isAuthentication")))
  11940. {
  11941. case 0:
  11942. case 1:
  11943. ShmSysConfigAndInfo->SysConfig.AuthorisationMode = json_object_get_int(json_object_object_get(data, "isAuthentication"))^1;
  11944. break;
  11945. default:
  11946. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11947. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11948. break;
  11949. }
  11950. }
  11951. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]) != NULL)
  11952. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  11953. }
  11954. else
  11955. {
  11956. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11957. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11958. }
  11959. json_object_put(data);
  11960. }
  11961. else
  11962. {
  11963. // Can not find valid message id
  11964. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  11965. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  11966. ,ShmOCPP20Data->DataTransfer[0].vendorId
  11967. ,ShmOCPP20Data->DataTransfer[0].messageId
  11968. ,ShmOCPP20Data->DataTransfer[0].data);
  11969. }
  11970. }
  11971. else
  11972. {
  11973. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  11974. result = FAIL;
  11975. }
  11976. sendDataTransferConfirmation(uuid, 0);
  11977. return result;
  11978. }
  11979. int handleDeleteCertificateRequest(char *uuid, char *payload)
  11980. {
  11981. mtrace();
  11982. int result = FAIL;
  11983. json_object *DeleteCertificate;
  11984. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  11985. DeleteCertificate = json_tokener_parse(payload);
  11986. if(!is_error(DeleteCertificate))
  11987. {
  11988. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  11989. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  11990. // Required data
  11991. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  11992. {
  11993. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  11994. {
  11995. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  11996. }
  11997. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  11998. {
  11999. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  12000. }
  12001. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  12002. {
  12003. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  12004. }
  12005. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  12006. {
  12007. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  12008. }
  12009. /*
  12010. * TODO:
  12011. * 1. Delete certification and response
  12012. */
  12013. if(strstr((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, HashAlgorithmEnumTypeStr[HashAlgorithmEnumType_SHA256]) != NULL)
  12014. {
  12015. }
  12016. else if(strstr((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, HashAlgorithmEnumTypeStr[HashAlgorithmEnumType_SHA384]) != NULL)
  12017. {
  12018. }
  12019. else
  12020. {
  12021. }
  12022. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  12023. }
  12024. }
  12025. else
  12026. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  12027. json_object_put(DeleteCertificate);
  12028. sendDeleteCertificateConfirmation(uuid);
  12029. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  12030. return result;
  12031. }
  12032. int handleGetBaseReportRequest(char *uuid, char *payload)
  12033. {
  12034. mtrace();
  12035. int result = FAIL;
  12036. json_object *GetBaseRepor;
  12037. DEBUG_INFO("handleGetBaseReportRequest...\n");
  12038. GetBaseRepor = json_tokener_parse(payload);
  12039. if(!is_error(GetBaseRepor))
  12040. {
  12041. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  12042. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  12043. // Required data
  12044. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  12045. {
  12046. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  12047. }
  12048. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  12049. {
  12050. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  12051. }
  12052. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_SummaryInventory]) == 0)
  12053. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  12054. else
  12055. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12056. }
  12057. else
  12058. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  12059. json_object_put(GetBaseRepor);
  12060. sendGetBaseReportConfirmation(uuid);
  12061. return result;
  12062. }
  12063. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  12064. {
  12065. mtrace();
  12066. int result = FAIL;
  12067. int gun_index = -1;
  12068. json_object *GetChargingProfiles;
  12069. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  12070. GetChargingProfiles = json_tokener_parse(payload);
  12071. if(!is_error(GetChargingProfiles))
  12072. {
  12073. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  12074. {
  12075. 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;
  12076. }
  12077. if(gun_index >-1)
  12078. {
  12079. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  12080. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  12081. // Required data
  12082. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  12083. {
  12084. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  12085. }
  12086. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  12087. {
  12088. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  12089. {
  12090. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  12091. }
  12092. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  12093. {
  12094. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  12095. }
  12096. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  12097. {
  12098. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  12099. {
  12100. 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)));
  12101. }
  12102. }
  12103. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  12104. {
  12105. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  12106. {
  12107. 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));
  12108. }
  12109. }
  12110. }
  12111. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  12112. }
  12113. else
  12114. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  12115. }
  12116. json_object_put(GetChargingProfiles);
  12117. sendGetChargingProfilesConfirmation(uuid, gun_index);
  12118. return result;
  12119. }
  12120. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  12121. {
  12122. mtrace();
  12123. int result = FAIL;
  12124. int connectorIdInt, durationInt;
  12125. char chargingRateUnitStr[4]={0};
  12126. char comfirmstr[20];
  12127. int confirmPeriods = 0;
  12128. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  12129. json_object *GetCompositeSchedule;
  12130. GetCompositeSchedule = json_tokener_parse(payload);
  12131. if(!is_error(GetCompositeSchedule))
  12132. {
  12133. // Required data
  12134. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  12135. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  12136. else
  12137. connectorIdInt = -1;
  12138. if(json_object_object_get(GetCompositeSchedule, "duration"))
  12139. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  12140. else
  12141. durationInt = 86400;
  12142. // Optional data
  12143. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  12144. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  12145. }
  12146. json_object_put(GetCompositeSchedule);
  12147. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  12148. if((connectorIdInt == 0) ||
  12149. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  12150. {
  12151. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  12152. struct ChargingProfileType tmpProfile[1];
  12153. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  12154. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  12155. if(strstr(chargingRateUnitStr, "W") != NULL)
  12156. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, FALSE);
  12157. else
  12158. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, TRUE);
  12159. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  12160. {
  12161. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  12162. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  12163. }
  12164. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  12165. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  12166. {
  12167. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  12168. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  12169. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  12170. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0) &&
  12171. (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))
  12172. {
  12173. confirmPeriods = idx;
  12174. break;
  12175. }
  12176. }
  12177. if((confirmPeriods == 0) && (tmpProfile[0].id > 0))
  12178. {
  12179. confirmPeriods += 1;
  12180. }
  12181. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12182. }
  12183. else
  12184. {
  12185. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  12186. }
  12187. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  12188. return result;
  12189. }
  12190. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  12191. {
  12192. mtrace();
  12193. int result = FAIL;
  12194. json_object *GetDisplayMessages;
  12195. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  12196. GetDisplayMessages = json_tokener_parse(payload);
  12197. if(!is_error(GetDisplayMessages))
  12198. {
  12199. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  12200. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  12201. // Required data
  12202. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  12203. {
  12204. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  12205. }
  12206. // Optional data
  12207. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  12208. {
  12209. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  12210. }
  12211. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  12212. {
  12213. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  12214. }
  12215. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  12216. {
  12217. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  12218. {
  12219. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  12220. }
  12221. strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  12222. ShmOCPP20Data->MsMsg.bits.GetDisplayMessagesReq = ON;
  12223. }
  12224. else
  12225. strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  12226. }
  12227. json_object_put(GetDisplayMessages);
  12228. return result;
  12229. }
  12230. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  12231. {
  12232. mtrace();
  12233. int result = FAIL;
  12234. json_object *GetInstalledCertificateIds;
  12235. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  12236. GetInstalledCertificateIds = json_tokener_parse(payload);
  12237. if(!is_error(GetInstalledCertificateIds))
  12238. {
  12239. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  12240. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  12241. // Optional data
  12242. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  12243. {
  12244. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  12245. {
  12246. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  12247. /*
  12248. * TODO:
  12249. * 1. Get installed certificate info for response
  12250. */
  12251. if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_V2GRootCertificate]) != NULL)
  12252. {
  12253. }
  12254. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_MORootCertificate]) != NULL)
  12255. {
  12256. }
  12257. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_CSMSRootCertificate]) != NULL)
  12258. {
  12259. }
  12260. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_V2GCertificateChain]) != NULL)
  12261. {
  12262. }
  12263. else
  12264. {
  12265. }
  12266. }
  12267. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  12268. }
  12269. else
  12270. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  12271. }
  12272. json_object_put(GetInstalledCertificateIds);
  12273. sendInstallCertificateConfirmation(uuid);
  12274. return result;
  12275. }
  12276. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  12277. {
  12278. mtrace();
  12279. int result = FAIL;
  12280. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  12281. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  12282. {
  12283. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  12284. localversion = -1;
  12285. }
  12286. else
  12287. {
  12288. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  12289. DB_getListVerion();
  12290. }
  12291. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  12292. sendGetLocalListVersionConfirmation(uuid);
  12293. return result;
  12294. }
  12295. static char fnamePlusPath[100]={0};
  12296. static char fnamePWithNoPath[60]={0};
  12297. void checkUploadLog(void)
  12298. {
  12299. FILE *fp;
  12300. /* Open the command for reading. */
  12301. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  12302. if (fp == NULL) {
  12303. printf("Failed to run command\n" );
  12304. exit(1);
  12305. }
  12306. int ftppathlen = 0;
  12307. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  12308. int i = 0;
  12309. /* Read the output a line at a time - output it. */
  12310. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  12311. if(i==0)
  12312. {
  12313. ftppathlen = strlen(fnamePlusPath);
  12314. printf("%s\n", fnamePlusPath);
  12315. fnamePlusPath[ftppathlen]='\0';
  12316. break;
  12317. }
  12318. i= i+1;
  12319. }
  12320. /* close */
  12321. pclose(fp);
  12322. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  12323. {
  12324. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  12325. {
  12326. fnamePlusPath[k]='\0';
  12327. }
  12328. }
  12329. i=1;
  12330. //char fname[60]={0};
  12331. while(i < ftppathlen)
  12332. {
  12333. int len=ftppathlen-i;
  12334. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  12335. {
  12336. printf("compare '/' all right\n");
  12337. break;
  12338. }
  12339. i=i+1;
  12340. }
  12341. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  12342. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  12343. fnamePWithNoPath[i+1] = '\0';
  12344. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  12345. {
  12346. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  12347. {
  12348. fnamePWithNoPath[j]='\0';
  12349. }
  12350. }
  12351. FILE* fp1 = fopen(fnamePlusPath, "r");
  12352. if (fp1)
  12353. {
  12354. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  12355. // file exists
  12356. fclose(fp1);
  12357. }
  12358. else
  12359. {
  12360. // file doesn't exist
  12361. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  12362. }
  12363. }
  12364. void* GetLogProcess(void* data)
  12365. {
  12366. pthread_detach(pthread_self());
  12367. mtrace();
  12368. int requestId, retriesInt=0, retryIntervalInt=0;
  12369. char logType[32], remoteLocation[1024]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  12370. 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};
  12371. int port=0;
  12372. int isSuccess = FALSE;
  12373. char ftpbuf[1024]={0};
  12374. char cmdBuf[2048];
  12375. struct tm *tmNow;
  12376. time_t CurrentTime;
  12377. struct tm tmStart;
  12378. struct tm tmStop;
  12379. CurrentTime = time(NULL);
  12380. tmNow=localtime(&CurrentTime);
  12381. uint16_t targetYear, targetMonth;
  12382. json_object *GetLog;
  12383. DEBUG_INFO("GetGetProcess...\n");
  12384. GetLog = json_tokener_parse(data);
  12385. if(!is_error(GetLog))
  12386. {
  12387. // Required data
  12388. if(json_object_object_get(GetLog, "requestId") != NULL)
  12389. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  12390. if(json_object_object_get(GetLog, "logType") != NULL)
  12391. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  12392. if(json_object_object_get(GetLog, "log") != NULL)
  12393. {
  12394. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  12395. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  12396. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  12397. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  12398. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  12399. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  12400. }
  12401. // Optional data
  12402. if(json_object_object_get(GetLog, "retries") != NULL)
  12403. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  12404. else
  12405. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  12406. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  12407. retryIntervalInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  12408. else
  12409. retryIntervalInt = 30;
  12410. }
  12411. json_object_put(GetLog);
  12412. ShmOCPP20Data->GetLog.requestId = requestId;
  12413. if(strstr(logType, LogEnumTypeStr[LogEnumType_SecurityLog]))
  12414. {
  12415. /*
  12416. * TODO:
  12417. * 1. Pack security log
  12418. */
  12419. }
  12420. else
  12421. {
  12422. // Pack log to compress file
  12423. 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) &&
  12424. (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))
  12425. {
  12426. // Pack system log
  12427. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  12428. sprintf(cmdBuf, "exec zip -9 --password %04d%02d%s /mnt/system.zip", tmNow->tm_year+1900, tmNow->tm_mon+1, ShmSysConfigAndInfo->SysConfig.SerialNumber);
  12429. targetYear = tmStart.tm_year;
  12430. targetMonth = tmStart.tm_mon;
  12431. do
  12432. {
  12433. sprintf(cmdBuf, "%s /Storage/SystemLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  12434. sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*SystemLog*", cmdBuf, targetYear, targetMonth);
  12435. if(targetMonth+1>=13)
  12436. {
  12437. targetYear += 1;
  12438. targetMonth = 1;
  12439. }
  12440. else
  12441. {
  12442. targetMonth += 1;
  12443. }
  12444. }while((targetYear < (tmNow->tm_year+1900)) ||
  12445. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  12446. sprintf(cmdBuf, "%s /Storage/CCS*.zip", cmdBuf);
  12447. system(cmdBuf);
  12448. // Pack charging & event log
  12449. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  12450. sprintf(cmdBuf, "exec zip -9 /mnt/charging_event.zip");
  12451. targetYear = tmStart.tm_year;
  12452. targetMonth = tmStart.tm_mon;
  12453. do
  12454. {
  12455. sprintf(cmdBuf, "%s /Storage/EventLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  12456. sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*OcppMessageLog*", cmdBuf, targetYear, targetMonth);
  12457. if(targetMonth+1>=13)
  12458. {
  12459. targetYear += 1;
  12460. targetMonth = 1;
  12461. }
  12462. else
  12463. {
  12464. targetMonth += 1;
  12465. }
  12466. }while((targetYear < (tmNow->tm_year+1900)) ||
  12467. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  12468. sprintf(cmdBuf, "%s /Storage/ChargeLog/*.db", cmdBuf);
  12469. sprintf(cmdBuf, "%s /Storage/EventLog/*.db", cmdBuf);
  12470. system(cmdBuf);
  12471. // Combine log file
  12472. system("exec zip -9 /mnt/log.zip /mnt/system.zip /mnt/charging_event.zip");
  12473. system("exec rm -f /mnt/system.zip /mnt/charging_event.zip");
  12474. }
  12475. else
  12476. {
  12477. system("exec /root/logPackTools 'log' 6");
  12478. }
  12479. }
  12480. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", ShmOCPP20Data->GetLog.Response_filename);
  12481. system(cmdBuf);
  12482. checkUploadLog();
  12483. //****************location*******************/
  12484. if(strcmp(remoteLocation,"")==0)
  12485. {
  12486. DEBUG_INFO("remoteLocation is <Empty>!\n");
  12487. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12488. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12489. goto end;
  12490. }
  12491. memset(protocol, 0, ARRAY_SIZE(protocol));
  12492. memset(user, 0, ARRAY_SIZE(user) );
  12493. memset(password, 0, ARRAY_SIZE(password));
  12494. memset(host, 0, ARRAY_SIZE(host));
  12495. memset(path, 0, ARRAY_SIZE(path));
  12496. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12497. memset(host1, 0, ARRAY_SIZE(host1));
  12498. memset(path1, 0, ARRAY_SIZE(path1));
  12499. /*location: ftp://user:password@host:port/path*/
  12500. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  12501. if((access(fnamePlusPath,F_OK))!=-1)
  12502. {
  12503. DEBUG_INFO("fnamePlusPath exist.\n");
  12504. }
  12505. else
  12506. {
  12507. DEBUG_INFO("fnamePlusPath not exist!\n");
  12508. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12509. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12510. goto end;
  12511. }
  12512. if(strchr(remoteLocation,'@')==NULL)
  12513. {
  12514. sscanf(remoteLocation,
  12515. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12516. protocol, host, &port, path);
  12517. strcpy(user,"anonymous");
  12518. strcpy(password,"");
  12519. }
  12520. else
  12521. {
  12522. //DEBUG_INFO("pch=%s\n", pch);
  12523. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12524. protocol, user, password, host, &port, path);
  12525. }
  12526. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0)&&(strcmp(protocol,"https")!=0))
  12527. {
  12528. DEBUG_INFO("protocol is not ftp/http ! \n");
  12529. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12530. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12531. goto end;
  12532. }
  12533. if(strncmp(remoteLocation,"http", 4) == 0)
  12534. {
  12535. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12536. sprintf(ftppath,"/%s", path);
  12537. do
  12538. {
  12539. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  12540. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12541. sleep(3);
  12542. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  12543. if(!isSuccess)
  12544. {
  12545. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  12546. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12547. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12548. sleep(retryIntervalInt);
  12549. }
  12550. else
  12551. {
  12552. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  12553. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  12554. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12555. }
  12556. retriesInt--;
  12557. }while((isSuccess == 0)&&(retriesInt >= 0));
  12558. }
  12559. else
  12560. {
  12561. sscanf(host,"%[^/]%s",host1, path1);
  12562. if(strlen(path) > 0)
  12563. sprintf(ftppath,"/%s", path);
  12564. else
  12565. sprintf(ftppath,"/%s", path1);
  12566. int ftppathlen=strlen(ftppath);
  12567. int i=1;
  12568. char filenametemp[50];
  12569. while(i < ftppathlen)
  12570. {
  12571. int len=ftppathlen-i;
  12572. if(ftppath[len]== 47) // '/' ascll code: 47
  12573. {
  12574. DEBUG_INFO("find '/' all right\n");
  12575. break;
  12576. }
  12577. i=i+1;
  12578. }
  12579. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12580. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  12581. filenametemp[i+1] = 0;
  12582. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12583. if(port == 0)
  12584. port = 21;
  12585. do
  12586. {
  12587. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  12588. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12589. sleep(3);
  12590. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  12591. if(!isSuccess)
  12592. {
  12593. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  12594. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12595. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12596. sleep(retryIntervalInt);
  12597. }
  12598. else
  12599. {
  12600. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  12601. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  12602. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12603. }
  12604. retriesInt--;
  12605. }while((!isSuccess)&&(retriesInt >= 0));
  12606. }
  12607. end:
  12608. system("rm -f /mnt/*");
  12609. sleep(5);
  12610. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  12611. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12612. interLock.isGetLogGoing = OFF;
  12613. pthread_exit(NULL);
  12614. }
  12615. int handleGetLogRequest(char *uuid, char *payload)
  12616. {
  12617. mtrace();
  12618. int result = FAIL;
  12619. char fName[258];
  12620. time_t CurrentTime;
  12621. struct tm *tm;
  12622. pthread_t th_Status;
  12623. CurrentTime = time(NULL);
  12624. tm = localtime(&CurrentTime);
  12625. 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);
  12626. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  12627. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  12628. sendGetLogConfirmation(uuid);
  12629. if(!interLock.isGetLogGoing)
  12630. {
  12631. interLock.isGetLogGoing = ON;
  12632. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  12633. sleep(1);
  12634. }
  12635. else
  12636. DEBUG_WARN("Other GetDiagnostic request on going.\n");
  12637. return result;
  12638. }
  12639. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  12640. {
  12641. mtrace();
  12642. int result = FAIL;
  12643. json_object *GetMonitoringReport;
  12644. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  12645. GetMonitoringReport = json_tokener_parse(payload);
  12646. if(!is_error(GetMonitoringReport))
  12647. {
  12648. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  12649. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  12650. // Required data
  12651. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  12652. {
  12653. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  12654. }
  12655. // Optional data
  12656. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  12657. {
  12658. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  12659. }
  12660. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  12661. {
  12662. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  12663. {
  12664. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  12665. {
  12666. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  12667. {
  12668. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  12669. {
  12670. 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")));
  12671. }
  12672. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  12673. {
  12674. 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")));
  12675. }
  12676. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  12677. {
  12678. 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)
  12679. {
  12680. 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"));
  12681. }
  12682. 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)
  12683. {
  12684. 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"));
  12685. }
  12686. }
  12687. }
  12688. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  12689. {
  12690. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  12691. {
  12692. 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")));
  12693. }
  12694. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  12695. {
  12696. 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")));
  12697. }
  12698. }
  12699. }
  12700. }
  12701. }
  12702. }
  12703. json_object_put(GetMonitoringReport);
  12704. /*
  12705. * TODO:
  12706. * 1. Response result
  12707. */
  12708. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12709. sendGetMonitoringReportConfirmation(uuid);
  12710. return result;
  12711. }
  12712. int handleGetReportRequest(char *uuid, char *payload)
  12713. {
  12714. mtrace();
  12715. int result = FAIL;
  12716. json_object *GetReport;
  12717. DEBUG_INFO("handleGetReportRequest...\n");
  12718. GetReport = json_tokener_parse(payload);
  12719. if(!is_error(GetReport))
  12720. {
  12721. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  12722. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  12723. // Required data
  12724. if(json_object_object_get(GetReport, "requestId") != NULL)
  12725. {
  12726. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  12727. }
  12728. // Optional data
  12729. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  12730. {
  12731. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  12732. }
  12733. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  12734. {
  12735. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  12736. {
  12737. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  12738. {
  12739. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  12740. {
  12741. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  12742. {
  12743. 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")));
  12744. }
  12745. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  12746. {
  12747. 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")));
  12748. }
  12749. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  12750. {
  12751. 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)
  12752. {
  12753. 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"), "evse"), "id"));
  12754. }
  12755. 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)
  12756. {
  12757. 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"), "evse"), "connectorId"));
  12758. }
  12759. }
  12760. }
  12761. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  12762. {
  12763. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  12764. {
  12765. 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")));
  12766. }
  12767. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  12768. {
  12769. 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")));
  12770. }
  12771. }
  12772. }
  12773. }
  12774. }
  12775. }
  12776. json_object_put(GetReport);
  12777. /*
  12778. * TODO:
  12779. * 1. Response result
  12780. */
  12781. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12782. sendGetReportConfirmation(uuid);
  12783. return result;
  12784. }
  12785. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  12786. {
  12787. mtrace();
  12788. int result = FAIL;
  12789. int8_t gun_index = -1;
  12790. json_object *GetTransactionStatus;
  12791. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  12792. GetTransactionStatus = json_tokener_parse(payload);
  12793. if(!is_error(GetTransactionStatus))
  12794. {
  12795. /*
  12796. * TODO:
  12797. * 1. Check transaction locate which connector
  12798. */
  12799. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  12800. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  12801. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  12802. {
  12803. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  12804. }
  12805. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  12806. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  12807. }
  12808. json_object_put(GetTransactionStatus);
  12809. sendGetTransactionStatusConfirmation(uuid, gun_index);
  12810. return result;
  12811. }
  12812. int handleGetVariablesRequest(char *uuid, char *payload)
  12813. {
  12814. mtrace();
  12815. int result = FAIL;
  12816. json_object *GetVariables;
  12817. DEBUG_INFO("handleGetVariablesRequest...\n");
  12818. GetVariables = json_tokener_parse(payload);
  12819. if(!is_error(GetVariables))
  12820. {
  12821. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  12822. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  12823. // Required data
  12824. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  12825. {
  12826. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  12827. {
  12828. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  12829. {
  12830. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  12831. {
  12832. 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")));
  12833. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  12834. }
  12835. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  12836. {
  12837. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  12838. {
  12839. 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")));
  12840. }
  12841. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  12842. {
  12843. 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")));
  12844. }
  12845. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  12846. {
  12847. 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)
  12848. {
  12849. 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"));
  12850. }
  12851. 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)
  12852. {
  12853. 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"));
  12854. }
  12855. }
  12856. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  12857. }
  12858. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  12859. {
  12860. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  12861. {
  12862. 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")));
  12863. }
  12864. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  12865. {
  12866. 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")));
  12867. }
  12868. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  12869. }
  12870. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  12871. {
  12872. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
  12873. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance) == 0) &&
  12874. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
  12875. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance) == 0))
  12876. {
  12877. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  12878. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, "ChargingStation") == 0) &&
  12879. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, "SystemUptimeSec") == 0))
  12880. {
  12881. struct sysinfo s_info;
  12882. int error = sysinfo(&s_info);
  12883. if(error != 0)
  12884. {
  12885. DEBUG_WARN("System uptime get error: %d\n", error);
  12886. }
  12887. else
  12888. {
  12889. sprintf((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, "%ld", s_info.uptime);
  12890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, "%ld", s_info.uptime);
  12891. }
  12892. }
  12893. else if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, "ChargingStation") == 0) &&
  12894. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, "FreeVend") == 0))
  12895. {
  12896. sprintf((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, "%s", (ShmSysConfigAndInfo->SysConfig.AuthorisationMode?"TRUE":"FALSE"));
  12897. }
  12898. else
  12899. {
  12900. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  12901. }
  12902. break;
  12903. }
  12904. else
  12905. {
  12906. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  12907. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  12908. }
  12909. }
  12910. }
  12911. }
  12912. }
  12913. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  12914. }
  12915. json_object_put(GetVariables);
  12916. return result;
  12917. }
  12918. int handleInstallCertificateRequest(char *uuid, char *payload)
  12919. {
  12920. mtrace();
  12921. int result = FAIL;
  12922. json_object *InstallCertificate;
  12923. DEBUG_INFO("handleInstallCertificateRequest...\n");
  12924. InstallCertificate = json_tokener_parse(payload);
  12925. if(!is_error(InstallCertificate))
  12926. {
  12927. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  12928. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  12929. // Required data
  12930. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  12931. {
  12932. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  12933. }
  12934. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  12935. {
  12936. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  12937. }
  12938. }
  12939. json_object_put(InstallCertificate);
  12940. /*
  12941. * TODO:
  12942. * 1. Install certification preocess and response
  12943. */
  12944. if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_V2GRootCertificate]))
  12945. {
  12946. }
  12947. else if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_MORootCertificate]))
  12948. {
  12949. }
  12950. else if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_CSMSRootCertificate]))
  12951. {
  12952. }
  12953. else
  12954. {
  12955. }
  12956. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12957. sendInstallCertificateConfirmation(uuid);
  12958. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  12959. return result;
  12960. }
  12961. int handlePublishFirmwareRequest(char *uuid, char *payload)
  12962. {
  12963. mtrace();
  12964. int result = FAIL;
  12965. json_object *PublishFirmware;
  12966. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  12967. PublishFirmware = json_tokener_parse(payload);
  12968. if(!is_error(PublishFirmware))
  12969. {
  12970. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  12971. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  12972. // Required data
  12973. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  12974. {
  12975. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  12976. }
  12977. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  12978. {
  12979. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  12980. }
  12981. // Optional data
  12982. if(json_object_object_get(PublishFirmware, "location") != NULL)
  12983. {
  12984. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  12985. }
  12986. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  12987. {
  12988. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  12989. }
  12990. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  12991. {
  12992. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  12993. }
  12994. }
  12995. json_object_put(PublishFirmware);
  12996. /*
  12997. * TODO:
  12998. * 1. Publish firmware preocess and response
  12999. */
  13000. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  13001. sendPublishFirmwareConfirmation(uuid);
  13002. return result;
  13003. }
  13004. int handleRequestStartTransactionRequest(char *uuid, char *payload)
  13005. {
  13006. mtrace();
  13007. int result = FAIL;
  13008. int8_t connectorIdx = -1;
  13009. uint8_t tempIndex;
  13010. uint8_t isOverConnectorMax = FALSE;
  13011. uint8_t isPeriodOverMax = FALSE;
  13012. uint8_t isTxProfile = TRUE;
  13013. uint8_t isAllowStart = TRUE;
  13014. uint8_t filename[128]={0};
  13015. char cmdBuf[128];
  13016. FILE *filePtr;
  13017. json_object *RemoteStartTransaction;
  13018. DEBUG_INFO("handleRequestStartTransactionRequest...\n");
  13019. RemoteStartTransaction = json_tokener_parse(payload);
  13020. if(!is_error(RemoteStartTransaction))
  13021. {
  13022. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  13023. {
  13024. if((0 < json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))) && (json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))<=gunTotalNumber))
  13025. {
  13026. connectorIdx = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  13027. }
  13028. else
  13029. {
  13030. isOverConnectorMax = TRUE;
  13031. DEBUG_WARN("Connector id shall not equal 0 and less than max connector id.\n");
  13032. }
  13033. }
  13034. else
  13035. {
  13036. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  13037. {
  13038. if(!cpinitateMsg.bits[idx].isOnCharging && (strstr((char*)ShmOCPP20Data->StatusNotification[idx].connectorStatus, ConnectorStatusEnumTypeStr[ConnectorStatusEnumType_Occupied]) != NULL))
  13039. {
  13040. connectorIdx = (idx+1);
  13041. DEBUG_INFO("Remote start without connectorId but detect connector-%02d connected ready to start.\n", connectorIdx);
  13042. break;
  13043. }
  13044. }
  13045. }
  13046. if(isOverConnectorMax == FALSE)
  13047. {
  13048. if(connectorIdx > 0)
  13049. {
  13050. DEBUG_INFO("Connector id: %d\n", connectorIdx);
  13051. memset(&ShmOCPP20Data->RequestStartTransaction[connectorIdx-1], 0, sizeof(struct RequestStartTransaction_20));
  13052. memcpy(&ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].guid));
  13053. // Required data
  13054. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  13055. {
  13056. ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  13057. }
  13058. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  13059. {
  13060. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  13061. {
  13062. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  13063. }
  13064. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  13065. {
  13066. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  13067. }
  13068. }
  13069. // Optional data
  13070. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  13071. {
  13072. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  13073. {
  13074. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  13075. }
  13076. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  13077. {
  13078. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  13079. }
  13080. }
  13081. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  13082. {
  13083. // Check periods is over max configuration
  13084. 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))
  13085. {
  13086. isPeriodOverMax = TRUE;
  13087. }
  13088. // Check profile purpose is TxProfile
  13089. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  13090. {
  13091. ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].chargingProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "id"));
  13092. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdx);
  13093. }
  13094. else
  13095. {
  13096. isTxProfile = FALSE;
  13097. }
  13098. }
  13099. //check Transaction active
  13100. if(gunType[connectorIdx-1] == GUN_TYPE_CHAdeMO)
  13101. {
  13102. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13103. {
  13104. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  13105. }
  13106. else
  13107. {
  13108. tempIndex = (connectorIdx-1);
  13109. }
  13110. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13111. {
  13112. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
  13113. {
  13114. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  13115. {
  13116. //Reserved
  13117. DEBUG_INFO("CHAdeMO connector already reserved and idTag match.\n");
  13118. }
  13119. 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[connectorIdx-1].idToken.idToken) != 0))
  13120. {
  13121. //Reserved
  13122. DEBUG_INFO("CHAdeMO connector already reserved and idTag does not match.\n");
  13123. isAllowStart = FALSE;
  13124. }
  13125. else
  13126. {
  13127. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13128. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) //S_PRECHARGE
  13129. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) //S_PREPARING_FOR_EV
  13130. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE )) // S_PREPARING_FOR_EVSE
  13131. {
  13132. DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n.");
  13133. isAllowStart = FALSE;
  13134. }
  13135. }//END FOR ELSE
  13136. }
  13137. }// END FOR CHAdeMO_QUANTITY
  13138. }
  13139. else if(gunType[connectorIdx-1] == GUN_TYPE_CCS)
  13140. {
  13141. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13142. {
  13143. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  13144. }
  13145. else
  13146. {
  13147. tempIndex = (connectorIdx-1);
  13148. }
  13149. for (int index = 0; index < CCS_QUANTITY; index++)
  13150. {
  13151. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  13152. {
  13153. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  13154. {
  13155. //Reserved
  13156. DEBUG_INFO("CCS connector already reserved and idTag match.\n");
  13157. }
  13158. 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[connectorIdx-1].idToken.idToken) != 0))
  13159. {
  13160. //Reserved
  13161. DEBUG_INFO("CCS connector already reserved and idTag does not match.\n");
  13162. isAllowStart = FALSE;
  13163. }
  13164. else
  13165. {
  13166. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13167. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13168. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13169. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13170. {
  13171. DEBUG_WARN("CCS connector not allow start cause busy.\n.");
  13172. isAllowStart = FALSE;
  13173. }
  13174. }// END FOR ELSE
  13175. }
  13176. }// END FOR CCS_QUANTITY
  13177. }
  13178. else if(gunType[connectorIdx-1] == GUN_TYPE_GBT)
  13179. {
  13180. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13181. {
  13182. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  13183. }
  13184. else
  13185. {
  13186. tempIndex = (connectorIdx-1);
  13187. }
  13188. for (int index = 0; index < GB_QUANTITY; index++)
  13189. {
  13190. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
  13191. {
  13192. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  13193. {
  13194. //Reserved
  13195. DEBUG_INFO("GBT connector already reserved and idTag match.\n");
  13196. }
  13197. 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[connectorIdx-1].idToken.idToken) != 0))
  13198. {
  13199. //Reserved
  13200. DEBUG_INFO("GBT connector already reserved and idTag does not match.\n");
  13201. isAllowStart = FALSE;
  13202. }
  13203. else
  13204. {
  13205. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13206. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13207. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13208. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13209. {
  13210. DEBUG_WARN("GBT connector not allow start cause busy.\n");
  13211. isAllowStart = FALSE;
  13212. }
  13213. }// END FOR ELSE
  13214. }
  13215. } // END FOR GB_QUANTITY
  13216. }
  13217. else if(gunType[connectorIdx-1] == GUN_TYPE_DO)
  13218. {
  13219. tempIndex = (connectorIdx-1);
  13220. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13221. {
  13222. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
  13223. {
  13224. 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[connectorIdx-1].idToken.idToken) == 0))
  13225. {
  13226. //Reserved
  13227. DEBUG_INFO("Dispenser connector already reserved and idTag match.\n");
  13228. }
  13229. 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[connectorIdx-1].idToken.idToken) != 0))
  13230. {
  13231. //Reserved
  13232. DEBUG_INFO("Dispenser connector already reserved and idTag does not match.\n");
  13233. isAllowStart = FALSE;
  13234. }
  13235. else
  13236. {
  13237. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13238. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13239. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13240. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13241. {
  13242. DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
  13243. isAllowStart = FALSE;
  13244. }
  13245. }// END FOR ELSE
  13246. }
  13247. } // END FOR GB_QUANTITY
  13248. }
  13249. else
  13250. {
  13251. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13252. {
  13253. tempIndex = 2;
  13254. }
  13255. else
  13256. {
  13257. tempIndex = (connectorIdx-1);
  13258. }
  13259. for (int index = 0; index < AC_QUANTITY; index++)
  13260. {
  13261. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
  13262. {
  13263. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  13264. {
  13265. //Reserved
  13266. DEBUG_INFO("AC connector already reserved and idTag match.\n");
  13267. }
  13268. 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[connectorIdx-1].idToken.idToken) != 0))
  13269. {
  13270. //Reserved
  13271. DEBUG_INFO("AC connector already reserved and idTag does not match.\n");
  13272. isAllowStart = FALSE;
  13273. }
  13274. else
  13275. {
  13276. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13277. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13278. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13279. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13280. {
  13281. DEBUG_WARN("AC connector not allow start cause busy.\n");
  13282. isAllowStart = FALSE;
  13283. }
  13284. }//END FOR ELSE
  13285. }
  13286. }// END FOR AC_QUANTITY
  13287. }
  13288. }
  13289. else
  13290. {
  13291. DEBUG_INFO("Connector id does not specific.\n");
  13292. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  13293. {
  13294. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  13295. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  13296. // Required data
  13297. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  13298. {
  13299. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  13300. }
  13301. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  13302. {
  13303. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  13304. {
  13305. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  13306. }
  13307. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  13308. {
  13309. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  13310. }
  13311. }
  13312. // Optional data
  13313. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  13314. {
  13315. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  13316. {
  13317. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  13318. }
  13319. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  13320. {
  13321. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  13322. }
  13323. }
  13324. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  13325. {
  13326. // Check periods is over max configuration
  13327. 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))
  13328. {
  13329. isPeriodOverMax = TRUE;
  13330. }
  13331. // Check profile purpose is TxProfile
  13332. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  13333. {
  13334. ShmOCPP20Data->RequestStartTransaction[gun_index].chargingProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "id"));
  13335. sprintf((char*)filename, "/Storage/OCPP/TxProfile_Tmp_OCPP20.json");
  13336. }
  13337. else
  13338. {
  13339. isTxProfile = FALSE;
  13340. }
  13341. }
  13342. }
  13343. }
  13344. }
  13345. // Profile replace or add info
  13346. if((isOverConnectorMax == FALSE) && !isPeriodOverMax && isTxProfile && isAllowStart)
  13347. {
  13348. if(connectorIdx != -1)
  13349. {
  13350. if(strlen((char*)filename) > 0)
  13351. {
  13352. // Save profile to file
  13353. sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdx);
  13354. system(cmdBuf);
  13355. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json.json", connectorIdx);
  13356. filePtr = fopen((char*)filename, "w");
  13357. fprintf(filePtr, "{\"evseId\":%d,\"chargingProfile\":%s}\n", connectorIdx, json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
  13358. fclose(filePtr);
  13359. }
  13360. ShmOCPP20Data->CsMsg.bits[connectorIdx-1].RequestStartTransactionReq = ON;
  13361. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  13362. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].Response_transactionId);
  13363. result = PASS;
  13364. }
  13365. else
  13366. {
  13367. uint8_t isHasIdleConnector = FALSE;
  13368. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  13369. {
  13370. if(!cpinitateMsg.bits[gun_index].isOnCharging)
  13371. {
  13372. isHasIdleConnector = TRUE;
  13373. break;
  13374. }
  13375. }
  13376. if(isHasIdleConnector == TRUE)
  13377. {
  13378. DEBUG_INFO("Start wait connector link to EV in %s seconds.\n", ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value);
  13379. if(strlen((char*)filename) > 0)
  13380. {
  13381. // Save profile to file
  13382. sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_Tmp_OCPP20.json");
  13383. system(cmdBuf);
  13384. sprintf((char*)filename, "/Storage/OCPP/TxProfile_Tmp_OCPP20.json.json");
  13385. filePtr = fopen((char*)filename, "w");
  13386. fprintf(filePtr, "{\"evseId\":0,\"chargingProfile\":%s}\n", json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
  13387. fclose(filePtr);
  13388. }
  13389. refreshStartTimer(&clientTime.RemoteStartWait);
  13390. ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = ON;
  13391. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  13392. {
  13393. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  13394. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId);
  13395. }
  13396. result = PASS;
  13397. }
  13398. else
  13399. {
  13400. DEBUG_INFO("There is not any connector is idle.\n");
  13401. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  13402. strcpy((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  13403. }
  13404. }
  13405. }
  13406. else
  13407. {
  13408. if(isOverConnectorMax != FALSE)
  13409. DEBUG_WARN("evseId id equal 0 or over maximun id.\n");
  13410. if(isPeriodOverMax)
  13411. DEBUG_WARN("Profile periods quantity is over spec.\n");
  13412. if(!isTxProfile)
  13413. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  13414. if(!isAllowStart)
  13415. DEBUG_WARN("Target connector does not allow start.\n");
  13416. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[((connectorIdx-1)<0?0:(connectorIdx-1))].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  13417. }
  13418. }
  13419. json_object_put(RemoteStartTransaction);
  13420. sendRemoteStartTransactionConfirmation(uuid, ((connectorIdx-1)<0?0:(connectorIdx-1)));
  13421. return result;
  13422. }
  13423. int handleRequestStopTransactionRequest(char *uuid, char *payload)
  13424. {
  13425. mtrace();
  13426. int result = FAIL;
  13427. int match = FALSE;
  13428. int GunNO = 0;
  13429. int tempIndex = 0;
  13430. char transactionIdStr[37];
  13431. int transactionIdIsNULL= TRUE;
  13432. json_object *RemoteStopTransaction;
  13433. DEBUG_INFO("handleRequestStopTransactionRequest...\n");
  13434. if(server_pending == TRUE)
  13435. {
  13436. return 0;
  13437. }
  13438. RemoteStopTransaction = json_tokener_parse(payload);
  13439. if(!is_error(RemoteStopTransaction))
  13440. {
  13441. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  13442. {
  13443. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  13444. transactionIdIsNULL = FALSE;
  13445. }
  13446. }
  13447. json_object_put(RemoteStopTransaction);
  13448. if(transactionIdIsNULL == FALSE)
  13449. {
  13450. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  13451. {
  13452. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  13453. {
  13454. //check Transaction active
  13455. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  13456. {
  13457. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13458. {
  13459. tempIndex = ((gun_index==2) ? 1: 0);
  13460. }
  13461. else
  13462. {
  13463. tempIndex = gun_index;
  13464. }
  13465. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13466. {
  13467. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  13468. {
  13469. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  13470. {
  13471. match = TRUE;
  13472. GunNO = gun_index;
  13473. }
  13474. }
  13475. }// END FOR CHAdeMO_QUANTITY
  13476. }
  13477. else if(gunType[gun_index] == GUN_TYPE_CCS)
  13478. {
  13479. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13480. {
  13481. tempIndex = ((gun_index==2) ? 1: 0);
  13482. }
  13483. else
  13484. {
  13485. tempIndex = gun_index;
  13486. }
  13487. for (int index = 0; index < CCS_QUANTITY; index++)
  13488. {
  13489. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  13490. {
  13491. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  13492. {
  13493. match = TRUE;
  13494. GunNO = gun_index;
  13495. }
  13496. }
  13497. }// END FOR CCS_QUANTITY
  13498. }
  13499. else if(gunType[gun_index] == GUN_TYPE_GBT)
  13500. {
  13501. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13502. {
  13503. tempIndex = ((gun_index==2) ? 1: 0);
  13504. }
  13505. else
  13506. {
  13507. tempIndex = gun_index;
  13508. }
  13509. for (int index = 0; index < GB_QUANTITY; index++)
  13510. {
  13511. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  13512. {
  13513. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  13514. {
  13515. match = TRUE;
  13516. GunNO = gun_index;
  13517. }
  13518. }
  13519. }// END FOR GB_QUANTITY
  13520. }
  13521. else if(gunType[gun_index] == GUN_TYPE_DO)
  13522. {
  13523. tempIndex = gun_index;
  13524. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13525. {
  13526. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  13527. {
  13528. 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
  13529. {
  13530. match = TRUE;
  13531. GunNO = gun_index;
  13532. }
  13533. }
  13534. }// END FOR GB_QUANTITY
  13535. }
  13536. else
  13537. {
  13538. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13539. {
  13540. tempIndex = 2;
  13541. }
  13542. else
  13543. {
  13544. tempIndex = gun_index;
  13545. }
  13546. for (int index = 0; index < AC_QUANTITY; index++)
  13547. {
  13548. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  13549. {
  13550. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  13551. {
  13552. match = TRUE;
  13553. GunNO = gun_index;
  13554. }
  13555. }
  13556. }// END FOR CHAdeMO_QUANTITY
  13557. } // END FOR AC ELSE
  13558. }// CHECK IF ResponseTransactionId == transactionIdInt
  13559. }//END FOR
  13560. if( match == TRUE)
  13561. {
  13562. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  13563. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  13564. }
  13565. else
  13566. {
  13567. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  13568. }
  13569. }
  13570. else
  13571. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  13572. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  13573. return result;
  13574. }
  13575. int handleReserveNowRequest(char *uuid, char *payload)
  13576. {
  13577. mtrace();
  13578. int result = FAIL;
  13579. int connectorIdInt=0, reservationIdInt=0;
  13580. int tempIndex = 0;
  13581. json_object *ReserveNow;
  13582. DEBUG_INFO("handleReserveNowRequest ...\n");
  13583. ReserveNow = json_tokener_parse(payload);
  13584. if(!is_error(ReserveNow))
  13585. {
  13586. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  13587. {
  13588. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  13589. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  13590. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  13591. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  13592. }
  13593. // Required data
  13594. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  13595. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  13596. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  13597. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  13598. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  13599. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  13600. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  13601. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  13602. // Optional data
  13603. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  13604. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  13605. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  13606. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  13607. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  13608. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  13609. result = PASS;
  13610. }
  13611. json_object_put(ReserveNow);
  13612. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13613. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  13614. {
  13615. //check Transaction active
  13616. if(gunType[connectorIdInt -1] == GUN_TYPE_CHAdeMO)
  13617. {
  13618. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13619. {
  13620. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  13621. }
  13622. else
  13623. {
  13624. tempIndex = connectorIdInt -1;
  13625. }
  13626. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13627. {
  13628. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  13629. {
  13630. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  13631. {
  13632. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  13633. {
  13634. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13635. {
  13636. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13637. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13638. }
  13639. 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'))
  13640. {
  13641. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13642. }
  13643. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  13644. {
  13645. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13646. }
  13647. else
  13648. {
  13649. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13650. }
  13651. }
  13652. 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
  13653. {
  13654. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13655. }
  13656. }
  13657. else
  13658. {
  13659. //replace reservation
  13660. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13661. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13662. }
  13663. }
  13664. } // END FOR CHAdeMO_QUANTITY
  13665. }
  13666. else if(gunType[connectorIdInt -1] == GUN_TYPE_CCS)
  13667. {
  13668. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13669. {
  13670. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  13671. }
  13672. else
  13673. {
  13674. tempIndex = connectorIdInt -1;
  13675. }
  13676. for (int index = 0; index < CCS_QUANTITY; index++)
  13677. {
  13678. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  13679. {
  13680. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  13681. {
  13682. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  13683. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  13684. {
  13685. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13686. {
  13687. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13688. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13689. }
  13690. 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'))
  13691. {
  13692. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13693. }
  13694. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  13695. {
  13696. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13697. }
  13698. else
  13699. {
  13700. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13701. }
  13702. }
  13703. 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
  13704. {
  13705. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13706. }
  13707. }
  13708. else
  13709. {
  13710. //replace reservation
  13711. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13712. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13713. }
  13714. }
  13715. } // END FOR CCS_QUANTITY
  13716. }
  13717. else if(gunType[connectorIdInt -1] == GUN_TYPE_GBT)
  13718. {
  13719. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13720. {
  13721. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  13722. }
  13723. else
  13724. {
  13725. tempIndex = connectorIdInt -1;
  13726. }
  13727. for (int index = 0; index < GB_QUANTITY; index++)
  13728. {
  13729. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  13730. {
  13731. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  13732. {
  13733. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  13734. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  13735. {
  13736. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13737. {
  13738. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13739. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13740. }
  13741. 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'))
  13742. {
  13743. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13744. }
  13745. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  13746. {
  13747. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13748. }
  13749. else
  13750. {
  13751. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13752. }
  13753. }
  13754. 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
  13755. {
  13756. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13757. }
  13758. }
  13759. else
  13760. {
  13761. //replace reservation
  13762. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13763. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13764. }
  13765. }
  13766. }// END FOR GB_QUANTITY
  13767. }
  13768. else if(gunType[connectorIdInt -1] == GUN_TYPE_DO)
  13769. {
  13770. tempIndex = connectorIdInt -1;
  13771. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13772. {
  13773. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  13774. {
  13775. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId)
  13776. {
  13777. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  13778. 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
  13779. {
  13780. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13781. {
  13782. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13783. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13784. }
  13785. 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'))
  13786. {
  13787. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13788. }
  13789. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  13790. {
  13791. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13792. }
  13793. else
  13794. {
  13795. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13796. }
  13797. }
  13798. 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
  13799. {
  13800. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13801. }
  13802. }
  13803. else
  13804. {
  13805. //replace reservation
  13806. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13807. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13808. }
  13809. }
  13810. }// END FOR DO_QUANTITY
  13811. }
  13812. else
  13813. {
  13814. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13815. {
  13816. tempIndex = 2;
  13817. }
  13818. else
  13819. {
  13820. tempIndex = (connectorIdInt -1);
  13821. }
  13822. for (int index = 0; index < AC_QUANTITY; index++)
  13823. {
  13824. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  13825. {
  13826. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  13827. {
  13828. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  13829. {
  13830. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13831. {
  13832. 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))
  13833. {
  13834. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13835. }
  13836. else
  13837. {
  13838. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13839. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13840. }
  13841. }
  13842. 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'))
  13843. {
  13844. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13845. }
  13846. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  13847. {
  13848. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13849. }
  13850. else
  13851. {
  13852. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13853. }
  13854. }
  13855. 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
  13856. {
  13857. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13858. }
  13859. }
  13860. else
  13861. {
  13862. //replace reservation
  13863. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13864. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13865. }
  13866. }
  13867. } // END FOR AC_QUANTITY
  13868. }
  13869. }
  13870. else if(connectorIdInt == 0)
  13871. {
  13872. //check Transaction active
  13873. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13874. {
  13875. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  13876. {
  13877. 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'))
  13878. {
  13879. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13880. goto end;
  13881. }
  13882. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  13883. {
  13884. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13885. goto end;
  13886. }
  13887. 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
  13888. {
  13889. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13890. goto end;
  13891. }
  13892. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13893. {
  13894. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13895. goto end;
  13896. }
  13897. }
  13898. }// END FOR CHAdeMO_QUANTITY
  13899. for (int index = 0; index < CCS_QUANTITY; index++)
  13900. {
  13901. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  13902. {
  13903. 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'))
  13904. {
  13905. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13906. goto end;
  13907. }
  13908. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  13909. {
  13910. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13911. goto end;
  13912. }
  13913. 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
  13914. {
  13915. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13916. goto end;
  13917. }
  13918. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13919. {
  13920. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13921. goto end;
  13922. }
  13923. }
  13924. } // END FOR CCS_QUANTITY
  13925. for (int index = 0; index < GB_QUANTITY; index++)
  13926. {
  13927. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  13928. {
  13929. 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'))
  13930. {
  13931. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13932. goto end;
  13933. }
  13934. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  13935. {
  13936. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13937. goto end;
  13938. }
  13939. 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
  13940. {
  13941. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13942. goto end;
  13943. }
  13944. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13945. {
  13946. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13947. goto end;
  13948. }
  13949. }
  13950. } // END FOR GB_QUANTITY
  13951. for (int index = 0; index < AC_QUANTITY; index++)
  13952. {
  13953. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  13954. {
  13955. 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'))
  13956. {
  13957. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13958. goto end;
  13959. }
  13960. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  13961. {
  13962. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13963. goto end;
  13964. }
  13965. 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
  13966. {
  13967. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13968. goto end;
  13969. }
  13970. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13971. {
  13972. 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))
  13973. {
  13974. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13975. goto end;
  13976. }
  13977. }
  13978. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13979. {
  13980. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13981. goto end;
  13982. }
  13983. }
  13984. }// END FOR AC_QUANTITY
  13985. //The connectorId is 0
  13986. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  13987. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13988. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  13989. result = TRUE;
  13990. return result;
  13991. }
  13992. else
  13993. {
  13994. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13995. }
  13996. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  13997. {
  13998. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  13999. result = TRUE;
  14000. return result;
  14001. }
  14002. end:
  14003. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  14004. return result;
  14005. }
  14006. int handleResetRequest(char *uuid, char *payload)
  14007. {
  14008. mtrace();
  14009. int result = FAIL;
  14010. json_object *Reset = json_object_new_object();
  14011. DEBUG_INFO("handleResetRequest...\n");
  14012. Reset = json_tokener_parse(payload);
  14013. if(!is_error(Reset))
  14014. {
  14015. // Required data
  14016. if(json_object_object_get(Reset, "type") != NULL)
  14017. {
  14018. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  14019. }
  14020. if(json_object_object_get(Reset, "evseId") != NULL)
  14021. {
  14022. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  14023. }
  14024. }
  14025. json_object_put(Reset);
  14026. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  14027. {
  14028. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  14029. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]);
  14030. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  14031. result = PASS;
  14032. }
  14033. else
  14034. {
  14035. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  14036. }
  14037. if(strlen((char*)ShmOCPP20Data->Reset.Response_status) > 0)
  14038. sendResetConfirmation(uuid);
  14039. return result;
  14040. }
  14041. int handleSendLocalListRequest(char *uuid, char *payload)
  14042. {
  14043. mtrace();
  14044. int result = FAIL;
  14045. char updateTypestr[15]={0};
  14046. int checkState_Faulted = FALSE;
  14047. json_object *SendLocalList;
  14048. DEBUG_INFO("handleSendLocalListRequest...\n");
  14049. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  14050. {
  14051. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14052. goto end;
  14053. }
  14054. SendLocalList = json_tokener_parse(payload);
  14055. if(!is_error(SendLocalList))
  14056. {
  14057. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  14058. // Required data
  14059. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  14060. {
  14061. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  14062. }
  14063. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  14064. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  14065. // Optional data
  14066. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  14067. {
  14068. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  14069. {
  14070. // Required data
  14071. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  14072. {
  14073. 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")));
  14074. 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")));
  14075. }
  14076. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  14077. {
  14078. 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")));
  14079. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  14080. 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")));
  14081. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  14082. 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"));
  14083. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  14084. {
  14085. 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")));
  14086. 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")));
  14087. }
  14088. }
  14089. }
  14090. }
  14091. }
  14092. json_object_put(SendLocalList);
  14093. //check Charge Point state
  14094. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14095. {
  14096. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14097. {
  14098. checkState_Faulted = TRUE; //OCPP Status: Faulted
  14099. }
  14100. }
  14101. for (int index = 0; index < CCS_QUANTITY; index++)
  14102. {
  14103. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14104. {
  14105. checkState_Faulted = TRUE; //OCPP Status
  14106. }
  14107. }
  14108. for (int index = 0; index < GB_QUANTITY; index++)
  14109. {
  14110. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14111. {
  14112. checkState_Faulted = TRUE; //OCPP Status: Faulted
  14113. }
  14114. }
  14115. for (int index = 0; index < AC_QUANTITY; index++)
  14116. {
  14117. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14118. {
  14119. checkState_Faulted = TRUE; //OCPP Status: Faulted
  14120. }
  14121. }
  14122. if(checkState_Faulted == TRUE)
  14123. {
  14124. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14125. goto end;
  14126. }
  14127. // Check update type
  14128. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  14129. {
  14130. //Local list full update
  14131. DEBUG_INFO("Local list full update.\n");
  14132. DB_getListVerion();
  14133. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  14134. {
  14135. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14136. goto end;
  14137. }
  14138. DB_cleanLocalList();
  14139. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  14140. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  14141. }
  14142. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  14143. {
  14144. //Local list different update
  14145. DEBUG_INFO("Local list different update.\n");
  14146. DB_getListVerion();
  14147. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  14148. {
  14149. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  14150. goto end;
  14151. }
  14152. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  14153. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  14154. }
  14155. else
  14156. {
  14157. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14158. goto end;
  14159. }
  14160. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  14161. end:
  14162. sendSendLocalListConfirmation(uuid);
  14163. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  14164. return result;
  14165. }
  14166. int handleSetChargingProfileRequest(char *uuid, char *payload)
  14167. {
  14168. mtrace();
  14169. int result = FAIL;
  14170. struct SetChargingProfile_20 SetProfileReq = {0};
  14171. uint8_t isLostConnectorId = FALSE;
  14172. uint8_t isPeriodOverMax = FALSE;
  14173. uint8_t isProfileOverMax = FALSE;
  14174. uint8_t isConnectorMismatch = FALSE;
  14175. uint8_t isTransactiodIdMismatch = FALSE;
  14176. uint8_t existProfileQuantity = 0;
  14177. uint8_t filename[128]={0};
  14178. uint8_t dataLine[4096]={0};
  14179. FILE *filePtr;
  14180. json_object *SetChargingProfile;
  14181. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  14182. SetChargingProfile = json_tokener_parse(payload);
  14183. if(!is_error(SetChargingProfile))
  14184. {
  14185. // Required data
  14186. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  14187. SetProfileReq.evseId = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  14188. else
  14189. isLostConnectorId = TRUE;
  14190. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id") != NULL)
  14191. SetProfileReq.chargingProfile.id = json_object_get_int((json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id")));
  14192. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  14193. {
  14194. sprintf((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")));
  14195. // Check periods is over max configuration
  14196. 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))
  14197. {
  14198. isPeriodOverMax = TRUE;
  14199. }
  14200. // Check periods is over max configuration
  14201. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  14202. {
  14203. if(SetProfileReq.evseId == 0)
  14204. {
  14205. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  14206. filePtr = fopen((char*)filename, "r");
  14207. if (!filePtr)
  14208. {
  14209. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  14210. filePtr = fopen((char*)filename, "w+");
  14211. }
  14212. else
  14213. {
  14214. //Check Charging Profile Count
  14215. while(fscanf(filePtr, "%s", dataLine) != EOF)
  14216. {
  14217. //DEBUG_INFO("word=%s\n",word);
  14218. if(strstr((char*)dataLine, "id")!= NULL)
  14219. {
  14220. existProfileQuantity += 1;
  14221. }
  14222. }
  14223. }
  14224. fclose(filePtr);
  14225. }
  14226. else
  14227. isConnectorMismatch = TRUE;
  14228. }
  14229. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  14230. {
  14231. if((0 < SetProfileReq.evseId) && (SetProfileReq.evseId > gunTotalNumber))
  14232. isConnectorMismatch = TRUE;
  14233. if(!isConnectorMismatch)
  14234. {
  14235. if(SetProfileReq.evseId == 0)
  14236. {
  14237. int tmpExistProfileQuantity;
  14238. for(int idxCon=1;idxCon<=gunTotalNumber;idxCon++)
  14239. {
  14240. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
  14241. filePtr = fopen((char*)filename, "r");
  14242. if (!filePtr)
  14243. {
  14244. DEBUG_INFO("%s not exist, create it.\n", filename);
  14245. filePtr = fopen((char*)filename, "w+");
  14246. }
  14247. else
  14248. {
  14249. //Check Charging Profile Count
  14250. while(fscanf(filePtr, "%s", dataLine) != EOF)
  14251. {
  14252. //DEBUG_INFO("word=%s\n",word);
  14253. if(strstr((char*)dataLine, "id")!= NULL)
  14254. {
  14255. tmpExistProfileQuantity += 1;
  14256. }
  14257. }
  14258. }
  14259. fclose(filePtr);
  14260. existProfileQuantity = (existProfileQuantity < tmpExistProfileQuantity) ? tmpExistProfileQuantity : existProfileQuantity;
  14261. }
  14262. }
  14263. else
  14264. {
  14265. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
  14266. filePtr = fopen((char*)filename, "r");
  14267. if (!filePtr)
  14268. {
  14269. DEBUG_INFO("%s not exist, create it.\n", filename);
  14270. filePtr = fopen((char*)filename, "w+");
  14271. }
  14272. else
  14273. {
  14274. //Check Charging Profile Count
  14275. while(fscanf(filePtr, "%s", dataLine) != EOF)
  14276. {
  14277. //DEBUG_INFO("word=%s\n",word);
  14278. if(strstr((char*)dataLine, "id")!= NULL)
  14279. {
  14280. existProfileQuantity += 1;
  14281. }
  14282. }
  14283. }
  14284. fclose(filePtr);
  14285. }
  14286. }
  14287. }
  14288. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  14289. {
  14290. if((SetProfileReq.evseId > 0) && (SetProfileReq.evseId <= gunTotalNumber))
  14291. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
  14292. else
  14293. isConnectorMismatch = TRUE;
  14294. if(!isConnectorMismatch)
  14295. {
  14296. filePtr = fopen((char*)filename, "r");
  14297. if (!filePtr)
  14298. {
  14299. DEBUG_INFO("%s not exist, create it.\n", filename);
  14300. filePtr = fopen((char*)filename, "w+");
  14301. }
  14302. else
  14303. {
  14304. //Check Charging Profile Count
  14305. while(fscanf(filePtr, "%s", dataLine) != EOF)
  14306. {
  14307. //DEBUG_INFO("word=%s\n",word);
  14308. if(strstr((char*)dataLine, "id")!= NULL)
  14309. {
  14310. existProfileQuantity += 1;
  14311. }
  14312. }
  14313. }
  14314. fclose(filePtr);
  14315. if(SetProfileReq.chargingProfile.transactionId != ShmOCPP20Data->TransactionEvent[SetProfileReq.evseId-1].transactionInfo.transactionId)
  14316. isTransactiodIdMismatch = TRUE;
  14317. }
  14318. }
  14319. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  14320. {
  14321. /*
  14322. * TODO:
  14323. *
  14324. */
  14325. }
  14326. else
  14327. {}
  14328. if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
  14329. isProfileOverMax = TRUE;
  14330. }
  14331. // Profile replace or add info
  14332. if(!isLostConnectorId && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTransactiodIdMismatch)
  14333. {
  14334. FILE *infile;
  14335. FILE *outfile;
  14336. char tmpProfileName[] = "/Storage/OCPP/SetChargingProfiletemp_OCPP20.json";
  14337. char rmFileCmd[128];
  14338. int tempchargingProfileIdInt;
  14339. int chkChar;
  14340. for(int idxCon=1; idxCon <= (SetProfileReq.evseId==0?gunTotalNumber:1); idxCon++)
  14341. {
  14342. if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) == 0)
  14343. {
  14344. sprintf((char*)filename, "%s", ChargePointMaxProfile_JSON);
  14345. }
  14346. else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0)
  14347. {
  14348. if(SetProfileReq.evseId==0)
  14349. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
  14350. else
  14351. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
  14352. }
  14353. else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) == 0)
  14354. {
  14355. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
  14356. }
  14357. else
  14358. {
  14359. /*
  14360. * TODO:
  14361. *
  14362. */
  14363. }
  14364. infile = fopen ((char*)filename, "r");
  14365. outfile = fopen ((char*)tmpProfileName, "w");
  14366. chkChar = fgetc(infile);
  14367. rewind(infile);
  14368. if(chkChar == EOF)
  14369. {
  14370. // Profile is empty
  14371. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  14372. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  14373. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  14374. fclose(infile);
  14375. fclose(outfile);
  14376. sprintf(rmFileCmd,"rm -f %s",filename);
  14377. system(rmFileCmd);
  14378. rename((char*)tmpProfileName, (char*)filename);
  14379. }
  14380. else
  14381. {
  14382. // Profile is not empty
  14383. int ChargingProfileAdded = FALSE;
  14384. while (fgets((char*)dataLine, ARRAY_SIZE(dataLine), infile) != NULL)
  14385. {
  14386. dataLine[strlen((char*)dataLine) - 1] = '\0'; // eat the newline fgets() stores
  14387. json_object *tmpChargingProfile;
  14388. tmpChargingProfile = json_tokener_parse((char*)dataLine);
  14389. if(!is_error(tmpChargingProfile))
  14390. {
  14391. if(json_object_object_get(tmpChargingProfile, "chargingProfile") != NULL)
  14392. {
  14393. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id") != NULL)
  14394. {
  14395. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id"));
  14396. DEBUG_INFO("tempchargingProfileIdInt: %d\n", tempchargingProfileIdInt);
  14397. DEBUG_INFO("SetProfileReq.chargingProfile.id: %d\n", SetProfileReq.chargingProfile.id);
  14398. }
  14399. }
  14400. }
  14401. json_object_put(tmpChargingProfile);
  14402. if((tempchargingProfileIdInt == SetProfileReq.chargingProfile.id))
  14403. {
  14404. if(ChargingProfileAdded == FALSE)
  14405. {
  14406. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  14407. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  14408. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  14409. ChargingProfileAdded = TRUE;
  14410. }
  14411. }
  14412. else
  14413. {
  14414. fprintf(outfile,"%s\n",dataLine);
  14415. if(ChargingProfileAdded == FALSE)
  14416. {
  14417. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  14418. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  14419. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  14420. ChargingProfileAdded = TRUE;
  14421. }
  14422. }
  14423. } // end of while loop
  14424. fclose(infile);
  14425. fclose(outfile);
  14426. sprintf(rmFileCmd,"rm -f %s",filename);
  14427. system(rmFileCmd);
  14428. rename((char*)tmpProfileName, (char*)filename);
  14429. }
  14430. }
  14431. sleep(1);
  14432. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  14433. result = PASS;
  14434. }
  14435. else
  14436. {
  14437. if(isLostConnectorId)
  14438. DEBUG_WARN("Connector id is wrong.\n");
  14439. if(isConnectorMismatch)
  14440. DEBUG_WARN("Connector id is mismatch.\n");
  14441. if(isPeriodOverMax)
  14442. DEBUG_WARN("Profile periods quantity is over spec.\n");
  14443. if(isProfileOverMax)
  14444. DEBUG_WARN("Profile quantity is over spec.\n");
  14445. if(isTransactiodIdMismatch)
  14446. DEBUG_WARN("Transaction id is mismatch.\n");
  14447. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  14448. }
  14449. }
  14450. json_object_put(SetChargingProfile);
  14451. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  14452. {
  14453. if(SetProfileReq.evseId == 0)
  14454. {
  14455. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  14456. {
  14457. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  14458. }
  14459. }
  14460. else
  14461. checkCompositeSchedule(SetProfileReq.evseId, 86400, &ShmOCPP20Data->SmartChargingProfile[SetProfileReq.evseId-1], 0, TRUE);
  14462. }
  14463. sendSetChargingProfileConfirmation(uuid, (SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1));
  14464. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  14465. return result;
  14466. }
  14467. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  14468. {
  14469. mtrace();
  14470. int result = FAIL;
  14471. json_object *SetDisplayMessage;
  14472. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  14473. SetDisplayMessage = json_tokener_parse(payload);
  14474. if(!is_error(SetDisplayMessage))
  14475. {
  14476. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  14477. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  14478. // Required data
  14479. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  14480. {
  14481. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  14482. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  14483. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  14484. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  14485. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  14486. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  14487. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  14488. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  14489. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  14490. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  14491. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  14492. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  14493. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  14494. {
  14495. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  14496. 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")));
  14497. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  14498. 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")));
  14499. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  14500. 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")));
  14501. }
  14502. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  14503. {
  14504. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  14505. 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")));
  14506. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  14507. 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")));
  14508. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  14509. {
  14510. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  14511. 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"));
  14512. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  14513. 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"));
  14514. }
  14515. }
  14516. }
  14517. }
  14518. json_object_put(SetDisplayMessage);
  14519. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  14520. sendSetDisplayMessagesConfirmation(uuid);
  14521. // Announce CSU there is display request come from server
  14522. ShmOCPP20Data->MsMsg.bits.SetDisplayMessageReq = ON;
  14523. return result;
  14524. }
  14525. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  14526. {
  14527. mtrace();
  14528. int result = FAIL;
  14529. json_object *SetMonitoringBase;
  14530. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  14531. SetMonitoringBase = json_tokener_parse(payload);
  14532. if(!is_error(SetMonitoringBase))
  14533. {
  14534. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  14535. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  14536. // Required data
  14537. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  14538. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  14539. }
  14540. json_object_put(SetMonitoringBase);
  14541. /*
  14542. * TODO:
  14543. * 1. Configure monitor base and response
  14544. */
  14545. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  14546. sendSetMonitoringBaseConfirmation(uuid);
  14547. return result;
  14548. }
  14549. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  14550. {
  14551. mtrace();
  14552. int result = FAIL;
  14553. json_object *SetMonitoringLevel;
  14554. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  14555. SetMonitoringLevel = json_tokener_parse(payload);
  14556. if(!is_error(SetMonitoringLevel))
  14557. {
  14558. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  14559. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  14560. // Required data
  14561. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  14562. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  14563. }
  14564. json_object_put(SetMonitoringLevel);
  14565. /*
  14566. * TODO:
  14567. * Configure monitor status and response
  14568. */
  14569. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  14570. sendSetMonitoringLevelConfirmation(uuid);
  14571. return result;
  14572. }
  14573. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  14574. {
  14575. mtrace();
  14576. int result = FAIL;
  14577. json_object *SetNetworkProfile;
  14578. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  14579. SetNetworkProfile = json_tokener_parse(payload);
  14580. if(!is_error(SetNetworkProfile))
  14581. {
  14582. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  14583. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  14584. // Required data
  14585. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  14586. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  14587. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  14588. {
  14589. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  14590. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  14591. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  14592. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  14593. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  14594. {
  14595. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  14596. memcpy((char*)ShmOCPP20Data->OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  14597. }
  14598. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  14599. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  14600. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  14601. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  14602. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  14603. {
  14604. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  14605. 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")));
  14606. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  14607. 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")));
  14608. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  14609. 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")));
  14610. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  14611. 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")));
  14612. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  14613. 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")));
  14614. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  14615. 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")));
  14616. }
  14617. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  14618. {
  14619. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  14620. {
  14621. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  14622. 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")));
  14623. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  14624. }
  14625. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  14626. {
  14627. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  14628. 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")));
  14629. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  14630. }
  14631. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  14632. {
  14633. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  14634. 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")));
  14635. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  14636. }
  14637. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  14638. 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"));
  14639. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  14640. 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")));
  14641. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  14642. 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"));
  14643. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  14644. 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")));
  14645. }
  14646. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  14647. }
  14648. }
  14649. json_object_put(SetNetworkProfile);
  14650. /*
  14651. * TODO:
  14652. * 1. Process network configuration and response
  14653. */
  14654. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  14655. {
  14656. }
  14657. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  14658. {
  14659. }
  14660. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  14661. {
  14662. }
  14663. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  14664. {
  14665. }
  14666. else
  14667. {
  14668. }
  14669. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  14670. {
  14671. }
  14672. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  14673. {
  14674. }
  14675. else
  14676. {
  14677. }
  14678. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  14679. {
  14680. }
  14681. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  14682. {
  14683. }
  14684. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  14685. {
  14686. }
  14687. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  14688. {
  14689. }
  14690. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  14691. {
  14692. }
  14693. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  14694. {
  14695. }
  14696. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  14697. {
  14698. }
  14699. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  14700. {
  14701. }
  14702. else
  14703. {
  14704. }
  14705. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  14706. {
  14707. }
  14708. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  14709. {
  14710. }
  14711. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  14712. {
  14713. }
  14714. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  14715. {
  14716. }
  14717. else
  14718. {
  14719. }
  14720. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  14721. {
  14722. }
  14723. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  14724. {
  14725. }
  14726. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  14727. {
  14728. }
  14729. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  14730. {
  14731. }
  14732. else
  14733. {
  14734. }
  14735. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  14736. sendSetNetworkProfileConfirmation(uuid);
  14737. return result;
  14738. }
  14739. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  14740. {
  14741. mtrace();
  14742. int result = FAIL;
  14743. json_object *SetVariableMonitoring;
  14744. uint8_t variableQuantity = 0;
  14745. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  14746. SetVariableMonitoring = json_tokener_parse(payload);
  14747. if(!is_error(SetVariableMonitoring))
  14748. {
  14749. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  14750. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  14751. // Required data
  14752. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  14753. {
  14754. variableQuantity++;
  14755. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  14756. {
  14757. 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"));
  14758. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  14759. }
  14760. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  14761. {
  14762. 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"));
  14763. }
  14764. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  14765. {
  14766. 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")));
  14767. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  14768. }
  14769. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  14770. {
  14771. 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"));
  14772. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  14773. }
  14774. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  14775. {
  14776. 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"));
  14777. }
  14778. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  14779. {
  14780. 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)
  14781. {
  14782. 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")));
  14783. }
  14784. 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)
  14785. {
  14786. 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")));
  14787. }
  14788. 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)
  14789. {
  14790. 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)
  14791. {
  14792. 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"));
  14793. }
  14794. 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)
  14795. {
  14796. 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"));
  14797. }
  14798. }
  14799. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  14800. }
  14801. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  14802. {
  14803. 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)
  14804. {
  14805. 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")));
  14806. }
  14807. 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)
  14808. {
  14809. 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")));
  14810. }
  14811. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  14812. }
  14813. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, SetMonitoringStatusEnumTypeStr[SetMonitoringStatusEnumType_Accepted]);
  14814. }
  14815. }
  14816. json_object_put(SetVariableMonitoring);
  14817. sendSetVariableMonitoringConfirmation(uuid, variableQuantity);
  14818. return result;
  14819. }
  14820. int handleSetVariablesRequest(char *uuid, char *payload)
  14821. {
  14822. mtrace();
  14823. int result = FAIL;
  14824. json_object *SetVariables;
  14825. DEBUG_INFO("handleSetVariablesRequest...\n");
  14826. SetVariables = json_tokener_parse(payload);
  14827. if(!is_error(SetVariables))
  14828. {
  14829. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  14830. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  14831. // Required data
  14832. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  14833. {
  14834. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  14835. {
  14836. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  14837. {
  14838. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  14839. {
  14840. 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")));
  14841. }
  14842. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  14843. {
  14844. 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")));
  14845. }
  14846. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  14847. {
  14848. 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)
  14849. {
  14850. 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"), "evse"), "id"));
  14851. }
  14852. 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)
  14853. {
  14854. 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"), "evse"), "connectorId"));
  14855. }
  14856. }
  14857. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  14858. }
  14859. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  14860. {
  14861. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  14862. {
  14863. 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")));
  14864. }
  14865. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  14866. {
  14867. 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")));
  14868. }
  14869. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  14870. }
  14871. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  14872. {
  14873. 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")));
  14874. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  14875. }
  14876. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  14877. {
  14878. 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")));
  14879. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  14880. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  14881. {
  14882. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  14883. (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) &&
  14884. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  14885. (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))
  14886. {
  14887. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  14888. {
  14889. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  14890. }
  14891. else
  14892. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  14893. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "WebSocketPingInterval") != NULL))
  14894. {
  14895. if((0 < atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value)) && (atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value) < 10) )
  14896. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  14897. }
  14898. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "HeartbeatInterval") != NULL))
  14899. {
  14900. if((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  14901. {
  14902. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  14903. }
  14904. else
  14905. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  14906. }
  14907. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "StatusNotificationPeriodically") != NULL))
  14908. {
  14909. char tmp[ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value)];
  14910. for(int idx=0;idx<ARRAY_SIZE(tmp);idx++)
  14911. tmp[idx] = tolower(ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value[idx]);
  14912. if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
  14913. {
  14914. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value,(strstr((char*)tmp, "true") != NULL)? "TRUE" : "FALSE");
  14915. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  14916. }
  14917. }
  14918. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "StatusNotificationInterval") != NULL))
  14919. {
  14920. if((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  14921. {
  14922. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  14923. }
  14924. else
  14925. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  14926. }
  14927. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SecurityCtrlr") != NULL) &&
  14928. ((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "SecurityProfile") != NULL) || (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "BasicAuthPassword") != NULL)))
  14929. {
  14930. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  14931. SetOcppConnStatus(FALSE);
  14932. }
  14933. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "AlignedDataCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "Interval") != NULL))
  14934. {
  14935. if((0 < atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value)) && (atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  14936. {
  14937. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  14938. }
  14939. }
  14940. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SampledDataCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "TxUpdatedInterval") != NULL))
  14941. {
  14942. if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  14943. {
  14944. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  14945. }
  14946. }
  14947. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "ChargingStation") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "FreeVend") != NULL))
  14948. {
  14949. char tmp[ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value)];
  14950. for(int idx=0;idx<ARRAY_SIZE(tmp);idx++)
  14951. tmp[idx] = tolower(ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value[idx]);
  14952. ShmSysConfigAndInfo->SysConfig.AuthorisationMode =((strstr((char*)tmp, "true") != NULL)? 1 : 0);
  14953. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  14954. }
  14955. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "ChargingStation") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "FreeVendIdtag") != NULL))
  14956. {
  14957. if(strlen((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) > 20)
  14958. {
  14959. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  14960. }
  14961. }
  14962. if((strstr((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]) != NULL) ||
  14963. (strstr((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]) != NULL))
  14964. {
  14965. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  14966. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  14967. }
  14968. }
  14969. }
  14970. }
  14971. }
  14972. }
  14973. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  14974. }
  14975. json_object_put(SetVariables);
  14976. return result;
  14977. }
  14978. int handleTriggerMessageRequest(char *uuid, char *payload)
  14979. {
  14980. mtrace();
  14981. int result = FAIL;
  14982. int connectorIdIsNULL = FALSE;
  14983. int connectorIdInt =0;
  14984. json_object *TriggerMessage;
  14985. DEBUG_INFO("handleTriggerMessageRequest\n");
  14986. TriggerMessage = json_tokener_parse(payload);
  14987. if(!is_error(TriggerMessage))
  14988. {
  14989. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  14990. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  14991. // Required data
  14992. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  14993. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  14994. // Optional data
  14995. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  14996. {
  14997. // Required data
  14998. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  14999. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  15000. // Optional data
  15001. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  15002. {
  15003. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  15004. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  15005. }
  15006. else
  15007. connectorIdIsNULL = TRUE;
  15008. }
  15009. else
  15010. connectorIdIsNULL = TRUE;
  15011. }
  15012. json_object_put(TriggerMessage);
  15013. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  15014. {
  15015. if((strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  15016. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  15017. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  15018. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  15019. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  15020. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  15021. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  15022. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  15023. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  15024. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  15025. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  15026. {
  15027. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  15028. sendTriggerMessageConfirmation(uuid);
  15029. return TRUE;
  15030. }
  15031. else
  15032. {
  15033. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  15034. sendTriggerMessageConfirmation(uuid);
  15035. }
  15036. }
  15037. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  15038. {
  15039. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  15040. sendTriggerMessageConfirmation(uuid);
  15041. return TRUE;
  15042. }
  15043. //==========================
  15044. // Trigger message
  15045. //==========================
  15046. if( strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  15047. {
  15048. if((strlen((char*)ShmOCPP20Data->FirmwareStatusNotification.status) == 0) ||
  15049. ((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing)))
  15050. {
  15051. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  15052. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  15053. }
  15054. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15055. }
  15056. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  15057. {
  15058. if(strlen((char*)ShmOCPP20Data->LogStatusNotification.status) == 0)
  15059. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Idle]);
  15060. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  15061. }
  15062. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  15063. {
  15064. if(DB_updateBootType(BootReasonEnumType_Triggered))
  15065. server_sign = FALSE;
  15066. }
  15067. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  15068. {
  15069. refreshStartTimer(&clientTime.Heartbeat);
  15070. clientTime.Heartbeat.tv_sec -= ShmOCPP20Data->BootNotification.Response_interval;
  15071. }
  15072. else if (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  15073. {
  15074. if(connectorIdIsNULL == FALSE)
  15075. {
  15076. if((connectorIdInt > 0) && ((connectorIdInt-1) < gunTotalNumber))
  15077. {
  15078. cpinitateMsg.bits[connectorIdInt-1].TriggerMeterValueReq = ON;
  15079. }
  15080. }
  15081. else
  15082. {
  15083. for(int idx=0;idx< gunTotalNumber;idx++)
  15084. {
  15085. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  15086. }
  15087. }
  15088. }
  15089. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  15090. {
  15091. if(connectorIdIsNULL == FALSE)
  15092. {
  15093. if((connectorIdInt > 0) && ((connectorIdInt-1) < gunTotalNumber))
  15094. {
  15095. cpinitateMsg.bits[connectorIdInt-1].TriggerStatusNotificationReq = ON;
  15096. //clientTime.StatusNotification[connectorIdInt-1] = time((time_t*)NULL);
  15097. }
  15098. }
  15099. else
  15100. {
  15101. for(int idx=0;idx< gunTotalNumber;idx++)
  15102. {
  15103. cpinitateMsg.bits[idx].TriggerStatusNotificationReq = ON;
  15104. //clientTime.StatusNotification[idx] = time((time_t*)NULL);
  15105. }
  15106. }
  15107. }
  15108. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0 )
  15109. {
  15110. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  15111. if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
  15112. {
  15113. 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\" &");
  15114. }
  15115. }
  15116. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) == 0 )
  15117. {
  15118. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  15119. if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
  15120. {
  15121. 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\" &");
  15122. }
  15123. }
  15124. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) == 0 )
  15125. {
  15126. if(connectorIdIsNULL == FALSE)
  15127. {
  15128. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  15129. {
  15130. ShmOCPP20Data->CpMsg.bits[connectorIdInt -1].TransactionEventReq = ON;
  15131. }
  15132. }
  15133. else
  15134. {
  15135. for(int idx=0;idx< gunTotalNumber;idx++)
  15136. ShmOCPP20Data->CpMsg.bits[idx].TransactionEventReq = ON;
  15137. }
  15138. }
  15139. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) == 0 )
  15140. {
  15141. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  15142. if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
  15143. {
  15144. 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\" &");
  15145. }
  15146. if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
  15147. {
  15148. 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\" &");
  15149. }
  15150. }
  15151. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) == 0 )
  15152. {
  15153. ShmOCPP20Data->MsMsg.bits.PublishFirmwareReq = ON;
  15154. }
  15155. return result;
  15156. }
  15157. int handleUnlockConnectorRequest(char *uuid, char *payload)
  15158. {
  15159. mtrace();
  15160. int result = FAIL;
  15161. int connectorIdInt =0;
  15162. int tempIndex = 0;
  15163. json_object *UnlockConnector;
  15164. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  15165. UnlockConnector = json_tokener_parse(payload);
  15166. if(!is_error(UnlockConnector))
  15167. {
  15168. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  15169. {
  15170. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  15171. }
  15172. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  15173. {
  15174. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  15175. }
  15176. }
  15177. json_object_put(UnlockConnector);
  15178. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  15179. if(gunTotalNumber == 0)
  15180. {
  15181. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  15182. goto end;
  15183. }
  15184. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  15185. {
  15186. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  15187. goto end;
  15188. }
  15189. else
  15190. {
  15191. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  15192. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  15193. //check Transaction active
  15194. if(gunType[connectorIdInt-1] == GUN_TYPE_CHAdeMO)
  15195. {
  15196. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15197. {
  15198. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  15199. }
  15200. else
  15201. {
  15202. tempIndex = connectorIdInt -1;
  15203. }
  15204. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  15205. {
  15206. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ))
  15207. {
  15208. //stop Transaction
  15209. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  15210. }
  15211. }
  15212. }
  15213. else if(gunType[connectorIdInt-1] == GUN_TYPE_CCS)
  15214. {
  15215. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15216. {
  15217. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  15218. }
  15219. else
  15220. {
  15221. tempIndex = connectorIdInt -1;
  15222. }
  15223. for (int index = 0; index < CCS_QUANTITY; index++)
  15224. {
  15225. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ))
  15226. {
  15227. //stop Transaction
  15228. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  15229. }
  15230. }
  15231. }
  15232. else if(gunType[connectorIdInt-1] == GUN_TYPE_GBT)
  15233. {
  15234. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15235. {
  15236. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  15237. }
  15238. else
  15239. {
  15240. tempIndex = connectorIdInt -1;
  15241. }
  15242. for (int index = 0; index < GB_QUANTITY; index++)
  15243. {
  15244. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ))
  15245. {
  15246. //stop Transaction
  15247. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  15248. }
  15249. }
  15250. }
  15251. else if(gunType[connectorIdInt-1] == GUN_TYPE_DO)
  15252. {
  15253. tempIndex = connectorIdInt -1;
  15254. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  15255. {
  15256. if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex ))
  15257. {
  15258. //stop Transaction
  15259. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  15260. }
  15261. }
  15262. }
  15263. else
  15264. {
  15265. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  15266. {
  15267. tempIndex = 2;
  15268. }
  15269. else
  15270. {
  15271. tempIndex = connectorIdInt-1;
  15272. }
  15273. for (int index = 0; index < AC_QUANTITY; index++)
  15274. {
  15275. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ))
  15276. {
  15277. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  15278. }
  15279. }
  15280. }
  15281. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  15282. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  15283. result = TRUE;
  15284. return result;
  15285. }
  15286. end:
  15287. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorConf = ON;
  15288. return result;
  15289. }
  15290. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  15291. {
  15292. mtrace();
  15293. int result = FAIL;
  15294. json_object *UnpublishFirmware;
  15295. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  15296. UnpublishFirmware = json_tokener_parse(payload);
  15297. if(!is_error(UnpublishFirmware))
  15298. {
  15299. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  15300. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  15301. // Required data
  15302. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  15303. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  15304. }
  15305. json_object_put(UnpublishFirmware);
  15306. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  15307. /*
  15308. * TODO:
  15309. * 1. Check unpublished status
  15310. */
  15311. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  15312. sendUnpublishFirmwareConfirmation(uuid);
  15313. return result;
  15314. }
  15315. static char UpdateFirmwarepayloadData[512]={0};
  15316. void *UpdateFirmwareProcess(void *data)
  15317. {
  15318. pthread_detach(pthread_self());
  15319. mtrace();
  15320. char protocol[10], user[64],password[64],host[128], path[512], ftppath[512],host1[128],path1[512];
  15321. int port=0;
  15322. int isSuccess = 0;
  15323. char ftpbuf[1024];
  15324. char temp[1024];
  15325. char * pch;
  15326. DEBUG_INFO("handleUpdateFirmwareRequest...\n");
  15327. json_object *UpdateFirmware;
  15328. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  15329. if(!is_error(UpdateFirmware))
  15330. {
  15331. // Required data
  15332. if(json_object_object_get(UpdateFirmware, "requestId"))
  15333. {
  15334. ShmOCPP20Data->UpdateFirmware.requestId = json_object_get_int(json_object_object_get(UpdateFirmware, "requestId"));
  15335. }
  15336. if(json_object_object_get(UpdateFirmware, "firmware"))
  15337. {
  15338. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location") != NULL)
  15339. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location")));
  15340. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate") != NULL)
  15341. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate")));
  15342. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime") != NULL)
  15343. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime")));
  15344. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate") != NULL)
  15345. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate")));
  15346. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature") != NULL)
  15347. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature")));
  15348. }
  15349. // Optional data
  15350. if(json_object_object_get(UpdateFirmware, "retries"))
  15351. {
  15352. ShmOCPP20Data->UpdateFirmware.retries = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  15353. }
  15354. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  15355. {
  15356. ShmOCPP20Data->UpdateFirmware.retryInterval = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  15357. }
  15358. }
  15359. json_object_put(UpdateFirmware);
  15360. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  15361. memset(path, 0, ARRAY_SIZE(path));
  15362. // Wait retrieveData
  15363. if(strlen((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime) > 10)
  15364. {
  15365. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15366. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled]);
  15367. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15368. do
  15369. {
  15370. sleep(1);
  15371. }while(!isOvertNow(ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime));
  15372. }
  15373. system("rm -f /mnt/*");
  15374. if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"http", 4) == 0)
  15375. {
  15376. sscanf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  15377. sprintf(ftppath,"/%s", path);
  15378. DEBUG_INFO("locationstr: %s\n", ShmOCPP20Data->UpdateFirmware.firmware.location);
  15379. DEBUG_INFO("protocol: %s\n",protocol);
  15380. DEBUG_INFO("host: %s\n",host);
  15381. DEBUG_INFO("path: %s\n",path);
  15382. DEBUG_INFO("ftppath: %s\n",ftppath);
  15383. int ftppathlen=strlen(ftppath);
  15384. int i=1;
  15385. char filenametemp[50];
  15386. while(i < ftppathlen)
  15387. {
  15388. int len=ftppathlen-i;
  15389. if(ftppath[len]== 47) // '/' ascll code: 47
  15390. {
  15391. DEBUG_INFO("compare '/' all right\n");
  15392. break;
  15393. }
  15394. i=i+1;
  15395. }
  15396. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  15397. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  15398. filenametemp[i+1] = 0;
  15399. do
  15400. {
  15401. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15402. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  15403. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15404. sleep(3);
  15405. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  15406. if(!isSuccess)
  15407. {
  15408. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15409. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  15410. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15411. if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
  15412. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15413. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  15414. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15415. }
  15416. else
  15417. {
  15418. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15419. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  15420. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15421. }
  15422. ShmOCPP20Data->UpdateFirmware.retries--;
  15423. }while((isSuccess == 0)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
  15424. }
  15425. else if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"ftp", 3) == 0)
  15426. {
  15427. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  15428. memset(temp, 0, ARRAY_SIZE(temp));
  15429. strcpy(ftpbuf, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  15430. int ftppathlen=strlen(ftpbuf);
  15431. int i=1;
  15432. char filenametemp[50];
  15433. while(i < ftppathlen)
  15434. {
  15435. int len=ftppathlen-i;
  15436. if(ftpbuf[len]== 47) // '/' ascll code: 47
  15437. {
  15438. DEBUG_INFO(" compare '/' all right\n");
  15439. break;
  15440. }
  15441. i=i+1;
  15442. }
  15443. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  15444. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  15445. filenametemp[i+1] = 0;
  15446. strncpy(temp, ftpbuf, ftppathlen-i+1);
  15447. pch=strchr(temp,'@');
  15448. if(pch==NULL)
  15449. {
  15450. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  15451. protocol, host, &port, path);
  15452. strcpy(user,"anonymous");
  15453. strcpy(password,"");
  15454. }
  15455. else
  15456. {
  15457. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  15458. protocol, user, password, host, &port, path);
  15459. }
  15460. sscanf(host,"%[^/]%s",host1, path1);
  15461. sprintf(ftppath,"%s", path1);
  15462. if(port == 0)
  15463. {
  15464. port = 21;
  15465. }
  15466. do
  15467. {
  15468. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15469. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  15470. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15471. sleep(3);
  15472. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  15473. if(!isSuccess)
  15474. {
  15475. //BulldogUtil.sleepMs(interval*1000);
  15476. DEBUG_INFO("Update firmware request and download file fail.\n");
  15477. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15478. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  15479. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15480. if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
  15481. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15482. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  15483. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15484. }
  15485. else
  15486. {
  15487. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15488. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  15489. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15490. }
  15491. ShmOCPP20Data->UpdateFirmware.retries--;
  15492. }while((!isSuccess)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
  15493. }
  15494. else
  15495. {
  15496. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15497. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  15498. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15499. sleep(1);
  15500. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  15501. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  15502. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15503. }
  15504. if(strstr((char*)ShmOCPP20Data->FirmwareStatusNotification.status, FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]) != NULL)ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  15505. interLock.isUpdateFirmwareGoing = OFF;
  15506. pthread_exit(NULL);
  15507. }
  15508. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  15509. {
  15510. mtrace();
  15511. int result = FAIL;
  15512. pthread_t t;
  15513. sendUpdateFirmwareConfirmation(uuid);
  15514. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  15515. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  15516. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  15517. if(!interLock.isUpdateFirmwareGoing)
  15518. {
  15519. interLock.isUpdateFirmwareGoing = ON;
  15520. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  15521. sleep(1);
  15522. }
  15523. else
  15524. DEBUG_WARN("Other UpdateFirmware request on going.\n");
  15525. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  15526. return result;
  15527. }
  15528. int handleUnknownRequest(char *uuid, char *payload)
  15529. {
  15530. mtrace();
  15531. int result = FAIL;
  15532. DEBUG_INFO("handleUnknownRequest...\n");
  15533. sendUnknownConfirmation(uuid);
  15534. result = PASS;
  15535. return result;
  15536. }
  15537. //==========================================
  15538. // Handle server response routine
  15539. //==========================================
  15540. void handleAuthorizeResponse(char *payload, int gun_index)
  15541. {
  15542. mtrace();
  15543. DEBUG_INFO("handleAuthorizeResponse...\n");
  15544. json_object *Authorize;
  15545. Authorize = json_tokener_parse(payload);
  15546. if(!is_error(Authorize))
  15547. {
  15548. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  15549. {
  15550. // Required data
  15551. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  15552. // Optional data
  15553. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  15554. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  15555. else
  15556. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  15557. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  15558. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  15559. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  15560. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  15561. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  15562. {
  15563. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  15564. {
  15565. 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));
  15566. }
  15567. }
  15568. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  15569. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  15570. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  15571. {
  15572. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  15573. 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")));
  15574. else
  15575. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  15576. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  15577. 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")));
  15578. }
  15579. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  15580. {
  15581. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  15582. 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")));
  15583. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  15584. 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")));
  15585. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  15586. 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")));
  15587. }
  15588. }
  15589. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  15590. {
  15591. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  15592. }
  15593. }
  15594. json_object_put(Authorize);
  15595. //Update idTag information to authorization cache if supported
  15596. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  15597. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  15598. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  15599. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  15600. {
  15601. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  15602. }
  15603. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  15604. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  15605. authorizeRetryTimes = 0;
  15606. }
  15607. void handleBootNotificationResponse(char *payload, int gun_index)
  15608. {
  15609. mtrace();
  15610. char statusStr[12]={0};
  15611. char currentTimeStr[30]={0};
  15612. int intervalInt = 0;
  15613. DEBUG_INFO("handleBootNotificationResponse...\n");
  15614. json_object *BootNotification;
  15615. BootNotification = json_tokener_parse(payload);
  15616. if(!is_error(BootNotification))
  15617. {
  15618. // Required data
  15619. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  15620. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  15621. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  15622. }
  15623. json_object_put(BootNotification);
  15624. DEBUG_INFO("statusStr: %s\n", statusStr);
  15625. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  15626. BootNotificationInterval = intervalInt;
  15627. //write back to ShmOCPP20Data->BootNotification
  15628. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  15629. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  15630. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  15631. {
  15632. if(intervalInt < (int)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.minLimit)
  15633. {
  15634. //Do nothing because the value is out of range.
  15635. }
  15636. else
  15637. {
  15638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value,"%d", HeartBeatWaitTime);
  15639. HeartBeatWaitTime = intervalInt;
  15640. DEBUG_INFO("BootNotificationResponse setting interval to %d...\n",intervalInt);
  15641. }
  15642. server_sign = TRUE;
  15643. server_pending =FALSE;
  15644. DB_updateBootType(BootReasonEnumType_PowerUp);
  15645. }
  15646. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  15647. {
  15648. server_pending = TRUE;
  15649. }
  15650. syncDateTimeRTC(ShmOCPP20Data->BootNotification.Response_currentTime);
  15651. srand(time(NULL));
  15652. refreshStartTimer(&clientTime.Heartbeat);
  15653. clientTime.Heartbeat.tv_sec -= (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  15654. SetOcppConnStatus(TRUE);
  15655. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  15656. }
  15657. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  15658. {
  15659. mtrace();
  15660. json_object *ClearedChargingLimit;
  15661. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  15662. ClearedChargingLimit = json_tokener_parse(payload);
  15663. if(!is_error(ClearedChargingLimit))
  15664. {
  15665. // Required data
  15666. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  15667. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  15668. }
  15669. json_object_put(ClearedChargingLimit);
  15670. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  15671. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitConf = ON;
  15672. }
  15673. void handleDataTransferResponse(char *payload, int gun_index)
  15674. {
  15675. mtrace();
  15676. json_object *DataTrans;
  15677. DEBUG_INFO("handleDataTransferResponse...\n");
  15678. DataTrans = json_tokener_parse(payload);
  15679. if(!is_error(DataTrans))
  15680. {
  15681. // Required data
  15682. if(json_object_object_get(DataTrans,"status") != NULL)
  15683. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  15684. // Optional data
  15685. if(json_object_object_get(DataTrans,"data") != NULL)
  15686. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  15687. }
  15688. json_object_put(DataTrans);
  15689. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  15690. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  15691. }
  15692. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  15693. {
  15694. mtrace();
  15695. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  15696. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  15697. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  15698. }
  15699. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  15700. {
  15701. mtrace();
  15702. json_object *Get15118EVCertificate;
  15703. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  15704. Get15118EVCertificate = json_tokener_parse(payload);
  15705. if(!is_error(Get15118EVCertificate))
  15706. {
  15707. // Required data
  15708. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  15709. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  15710. // Optional data
  15711. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  15712. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  15713. }
  15714. json_object_put(Get15118EVCertificate);
  15715. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  15716. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  15717. }
  15718. void handleGetCertificateStatusResponse(char *payload, int gun_index)
  15719. {
  15720. mtrace();
  15721. json_object *GetCertificateStatus;
  15722. DEBUG_INFO("handleGetCertificateStatusResponse...\n");
  15723. GetCertificateStatus = json_tokener_parse(payload);
  15724. if(!is_error(GetCertificateStatus))
  15725. {
  15726. // Required data
  15727. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  15728. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  15729. // Optional data
  15730. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  15731. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  15732. if(json_object_object_get(GetCertificateStatus,"statusInfo") != NULL)
  15733. {
  15734. if(json_object_object_get(json_object_object_get(GetCertificateStatus,"statusInfo"), "reasonCode") != NULL)
  15735. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(GetCertificateStatus,"ocspResult"), "reasonCode")));
  15736. if(json_object_object_get(json_object_object_get(GetCertificateStatus,"statusInfo"), "additionalInfo") != NULL)
  15737. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(GetCertificateStatus,"ocspResult"), "additionalInfo")));
  15738. }
  15739. }
  15740. json_object_put(GetCertificateStatus);
  15741. if(strstr((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, GetCertificateStatusEnumTypeStr[GetCertificateStatusEnumType_Accepted]) != NULL)
  15742. {
  15743. /*
  15744. * TODO:
  15745. * 1. If get certificate response accepted process something here
  15746. */
  15747. }
  15748. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  15749. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  15750. }
  15751. void handleHeartbeatResponse(char *payload, int gun_index)
  15752. {
  15753. mtrace();
  15754. DEBUG_INFO("handleHeartbeatResponse...\n");
  15755. json_object *Heartbeat;
  15756. Heartbeat = json_tokener_parse(payload);
  15757. if(!is_error(Heartbeat))
  15758. {
  15759. // Required data
  15760. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  15761. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  15762. }
  15763. json_object_put(Heartbeat);
  15764. if(FirstHeartBeat == OFF)
  15765. {
  15766. FirstHeartBeat = ON;
  15767. DEBUG_INFO("FirstHeartBeat \n");
  15768. }
  15769. HeartBeatWithNOResponse = 0;
  15770. refreshStartTimer(&clientTime.Heartbeat);
  15771. syncDateTimeRTC(ShmOCPP20Data->Heartbeat.Response_currentTime);
  15772. }
  15773. void handleLogStatusNotificationResponse(char *payload, int gun_index)
  15774. {
  15775. mtrace();
  15776. DEBUG_INFO("handleLogStatusNotificationResponse...\n");
  15777. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  15778. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  15779. }
  15780. void handleMeterValuesResponse(char *payload, int gun_index)
  15781. {
  15782. mtrace();
  15783. DEBUG_INFO("handleMeterValuesResponse...\n");
  15784. isQueueSendable = ON;
  15785. }
  15786. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  15787. {
  15788. mtrace();
  15789. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  15790. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  15791. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  15792. }
  15793. void handleNotifyCustomerInformationResponse(char *payload, int gun_index)
  15794. {
  15795. mtrace();
  15796. DEBUG_INFO("handleNotifyCustomerInformationResponse...\n");
  15797. }
  15798. void handleNotifyDisplayMessagesResponse(char *payload, int gun_index)
  15799. {
  15800. mtrace();
  15801. DEBUG_INFO("handleNotifyDisplayMessagesResponse...\n");
  15802. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  15803. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  15804. }
  15805. void handleNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  15806. {
  15807. mtrace();
  15808. json_object *NotifyEVChargingNeeds;
  15809. DEBUG_INFO("handleNotifyEVChargingNeedsResponse...\n");
  15810. NotifyEVChargingNeeds = json_tokener_parse(payload);
  15811. if(!is_error(NotifyEVChargingNeeds))
  15812. {
  15813. // Required data
  15814. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  15815. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  15816. }
  15817. json_object_put(NotifyEVChargingNeeds);
  15818. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  15819. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  15820. }
  15821. void handleNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  15822. {
  15823. mtrace();
  15824. json_object *NotifyEVChargingSchedule;
  15825. DEBUG_INFO("handleNotifyEVChargingScheduleResponse...\n");
  15826. NotifyEVChargingSchedule = json_tokener_parse(payload);
  15827. if(!is_error(NotifyEVChargingSchedule))
  15828. {
  15829. // Required data
  15830. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  15831. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  15832. }
  15833. json_object_put(NotifyEVChargingSchedule);
  15834. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  15835. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  15836. }
  15837. void handleNotifyEventResponse(char *payload, int gun_index)
  15838. {
  15839. mtrace();
  15840. DEBUG_INFO("handleNotifyEventResponse...\n");
  15841. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  15842. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  15843. }
  15844. void handleNotifyMonitoringReportResponse(char *payload, int gun_index)
  15845. {
  15846. mtrace();
  15847. DEBUG_INFO("handleNotifyMonitoringReportResponse...\n");
  15848. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  15849. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  15850. }
  15851. void handleNotifyReportResponse(char *payload, int gun_index)
  15852. {
  15853. mtrace();
  15854. DEBUG_INFO("handleNotifyReportResponse...\n");
  15855. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  15856. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  15857. }
  15858. void handlePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  15859. {
  15860. mtrace();
  15861. DEBUG_INFO("handlePublishFirmwareStatusNotificationResponse...\n");
  15862. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  15863. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  15864. }
  15865. void handleReportChargingProfilesResponse(char *payload, int gun_index)
  15866. {
  15867. mtrace();
  15868. DEBUG_INFO("handleReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  15869. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  15870. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  15871. }
  15872. void handleReservationStatusUpdateResponse(char *payload, int gun_index)
  15873. {
  15874. mtrace();
  15875. DEBUG_INFO("handleReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  15876. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  15877. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  15878. }
  15879. void handleSecurityEventNotificationResponse(char *payload, int gun_index)
  15880. {
  15881. mtrace();
  15882. DEBUG_INFO("handleSecurityEventNotificationResponse...\n");
  15883. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  15884. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  15885. }
  15886. void handleSignCertificateResponse(char *payload, int gun_index)
  15887. {
  15888. mtrace();
  15889. json_object *SignCertificate;
  15890. DEBUG_INFO("handleSignCertificateResponse...\n");
  15891. SignCertificate = json_tokener_parse(payload);
  15892. if(!is_error(SignCertificate))
  15893. {
  15894. // Required data
  15895. if(json_object_object_get(SignCertificate,"status") != NULL)
  15896. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  15897. // Optional data
  15898. if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode") != NULL)
  15899. {
  15900. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode")));
  15901. if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo") != NULL)
  15902. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo")));
  15903. }
  15904. }
  15905. json_object_put(SignCertificate);
  15906. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  15907. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  15908. }
  15909. void handleStatusNotificationResponse(char *payload, int gun_index)
  15910. {
  15911. mtrace();
  15912. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  15913. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  15914. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  15915. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  15916. }
  15917. void handleTransactionEventResponse(char *payload, int gun_index)
  15918. {
  15919. mtrace();
  15920. json_object *TransactionEven;
  15921. DEBUG_INFO("handleTransactionEventResponse...\n");
  15922. TransactionEven = json_tokener_parse(payload);
  15923. if(!is_error(TransactionEven))
  15924. {
  15925. // Required data
  15926. // Optional data
  15927. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  15928. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  15929. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  15930. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  15931. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  15932. {
  15933. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  15934. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  15935. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  15936. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  15937. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  15938. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  15939. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  15940. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  15941. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  15942. {
  15943. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  15944. 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")));
  15945. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  15946. 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")));
  15947. }
  15948. }
  15949. if(json_object_object_get(TransactionEven,"updatedPersonalMessage") != NULL)
  15950. {
  15951. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "format") != NULL)
  15952. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.format, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "format")));
  15953. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "language") != NULL)
  15954. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.language, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "language")));
  15955. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "content") != NULL)
  15956. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.content, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "content")));
  15957. }
  15958. }
  15959. json_object_put(TransactionEven);
  15960. isQueueSendable = ON;
  15961. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  15962. }
  15963. //==========================================
  15964. // Handle Error routine
  15965. //==========================================
  15966. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  15967. {
  15968. mtrace();
  15969. #ifdef SystemLogMessage
  15970. DEBUG_INFO("errorCode: %s\n", errorCode);
  15971. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  15972. DEBUG_INFO("errorDetails: %s\n", payload);
  15973. #endif
  15974. }
  15975. //===============================================
  15976. // Common routine
  15977. //===============================================
  15978. int initialConfigurationTable(void)
  15979. {
  15980. DEBUG_INFO("initialConfigurationTable...\n");
  15981. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  15982. DB_variableIsCreate();
  15983. DB_variableLoadFromDb();
  15984. if(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].value) != variableVersion)
  15985. {
  15986. DEBUG_WARN("EVSE variable version in local db older than firmware.\n");
  15987. DB_variableClear();
  15988. DB_variableIsCreate();
  15989. DB_variableLoadFromDb();
  15990. }
  15991. DB_getNetworkProfileFromDb();
  15992. return 0;
  15993. }
  15994. int TransactionMessageAttemptsGet(void)
  15995. {
  15996. return TransactionMessageAttemptsValue;
  15997. }
  15998. int FirstHeartBeatResponse(void)
  15999. {
  16000. return FirstHeartBeat;
  16001. }
  16002. int TransactionMessageRetryIntervalGet(void)
  16003. {
  16004. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  16005. }
  16006. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  16007. {
  16008. int result = TRUE;
  16009. char rmFileCmd[100]={0};
  16010. char FilePath[100]={0};
  16011. char ftpbuf[200];
  16012. int systemresult;
  16013. sprintf(FilePath,"/mnt/%s",filename);
  16014. system("ping 8.8.8.8 &");
  16015. if((access(FilePath,F_OK))!=-1)
  16016. {
  16017. DEBUG_INFO("filename=%s exist.\n",FilePath);
  16018. sprintf(rmFileCmd,"rm -f %s",FilePath);
  16019. system(rmFileCmd);
  16020. }
  16021. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  16022. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
  16023. DEBUG_INFO("Download command: %s\n",ftpbuf);
  16024. systemresult = system(ftpbuf);
  16025. if(systemresult != 0)
  16026. {
  16027. DEBUG_INFO("http DownLoad error!\n");
  16028. result = FALSE;
  16029. }
  16030. system("pkill ping");
  16031. return result;
  16032. }
  16033. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  16034. {
  16035. int result = TRUE;
  16036. char rmFileCmd[100]={0};
  16037. char FilePath[100]={0};
  16038. char ftpbuf[200];
  16039. int systemresult;
  16040. sprintf(FilePath,"/mnt/%s",filename);
  16041. system("ping 8.8.8.8 &");
  16042. if((access(FilePath,F_OK))!=-1)
  16043. {
  16044. DEBUG_INFO("filename=%s exist.\n",FilePath);
  16045. sprintf(rmFileCmd,"rm -f %s",FilePath);
  16046. system(rmFileCmd);
  16047. }
  16048. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  16049. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  16050. DEBUG_INFO("Download command: %s\n",ftpbuf);
  16051. systemresult = system(ftpbuf);
  16052. if(systemresult != 0)
  16053. {
  16054. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
  16055. DEBUG_INFO("Download command: %s\n",ftpbuf);
  16056. systemresult = system(ftpbuf);
  16057. if(systemresult != 0)
  16058. {
  16059. DEBUG_WARN("wget error!\n");
  16060. result = FALSE;
  16061. }
  16062. }
  16063. system("pkill ping");
  16064. return result;
  16065. }
  16066. int httpUploadFile(char *location, char *path, char *filename,char *url)
  16067. {
  16068. char rmFileCmd[100]={0};
  16069. char FilePath[100]={0};
  16070. char buf[512];
  16071. int systemresult = 0;
  16072. //DEBUG_INFO("filename=%s\n",filename);
  16073. //DEBUG_INFO("url=%s\n",url);
  16074. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  16075. if((access(FilePath,F_OK))!=-1)
  16076. {
  16077. DEBUG_INFO("filename=%s exist.\n",FilePath);
  16078. sprintf(rmFileCmd,"rm -f %s",FilePath);
  16079. system(rmFileCmd);
  16080. }
  16081. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  16082. if(fp == NULL)
  16083. {
  16084. DEBUG_INFO("log is NULL\n");
  16085. return FALSE;
  16086. }
  16087. else
  16088. {
  16089. fprintf(fp, "%s\n", url);
  16090. fprintf(fp, "%s\n", filename);
  16091. fclose(fp);
  16092. }
  16093. FILE *phpFP = popen("/bin/php-cgi /var/www/ocpp_upload.php", "r");
  16094. if(phpFP == NULL)
  16095. {
  16096. DEBUG_INFO("PHP upload fail.\n");
  16097. return FALSE;
  16098. }
  16099. else
  16100. {
  16101. while(fgets(buf, sizeof(buf), phpFP) != NULL)
  16102. {
  16103. if(strstr(buf, "result") != NULL)
  16104. {
  16105. sscanf(buf, "result: %d", &systemresult);
  16106. DEBUG_INFO("PHP HTTP upload result: %d\n", systemresult);
  16107. }
  16108. }
  16109. pclose(phpFP);
  16110. }
  16111. if(systemresult != 1)
  16112. {
  16113. DEBUG_INFO("HTTP upload error!\n");
  16114. return FALSE;
  16115. }
  16116. return TRUE;
  16117. }
  16118. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  16119. {
  16120. int result = FALSE;
  16121. char ftpbuf[200];
  16122. int systemresult;
  16123. /*
  16124. // Domaind name transfer to IP address
  16125. struct hostent* server;
  16126. char *IPbuffer;
  16127. server = gethostbyname(location);
  16128. IPbuffer = inet_ntoa(*((struct in_addr*)server->h_addr_list[0]));*/
  16129. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  16130. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s", user, password, location, port/*21*/, path, filename, fnamePlusPath);
  16131. DEBUG_INFO("ftp command: %s\n",ftpbuf);
  16132. systemresult = system(ftpbuf);
  16133. if(systemresult != 0)
  16134. {
  16135. DEBUG_INFO("ftpput error!\n");
  16136. }
  16137. else
  16138. {
  16139. result = TRUE;
  16140. DEBUG_INFO("ftpput OK!\n");
  16141. }
  16142. return result;
  16143. }
  16144. //=========================================
  16145. // Routine
  16146. //=========================================
  16147. int GetOcppServerURL()
  16148. {
  16149. int result = FALSE;
  16150. struct yuarel url;
  16151. char urlStr[512];
  16152. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  16153. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  16154. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  16155. if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  16156. {
  16157. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  16158. if(yuarel_parse(&url, urlStr) != -1)
  16159. {
  16160. sprintf(OcppProtocol, "%s", url.scheme);
  16161. sprintf(OcppHost, "%s", url.host);
  16162. if(url.path == NULL)
  16163. OcppTempPath[0] = '\0';
  16164. else
  16165. sprintf(OcppTempPath, "%s", url.path);
  16166. if(url.port == 0)
  16167. {
  16168. if(strcmp(OcppProtocol, "wss") == 0)
  16169. OcppPort = 443;
  16170. else
  16171. OcppPort = 80;
  16172. }
  16173. else
  16174. OcppPort = url.port;
  16175. result = TRUE;
  16176. }
  16177. }
  16178. else
  16179. {
  16180. strcpy(OcppHost,"");
  16181. }
  16182. return result;
  16183. }
  16184. int GetOcppPath()
  16185. {
  16186. int result = FALSE;
  16187. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  16188. {
  16189. if(OcppTempPath == NULL)
  16190. {
  16191. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  16192. }
  16193. else
  16194. {
  16195. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  16196. }
  16197. result = TRUE;
  16198. }
  16199. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  16200. {
  16201. if(OcppTempPath == NULL)
  16202. {
  16203. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  16204. }
  16205. else
  16206. {
  16207. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  16208. }
  16209. result = TRUE;
  16210. }
  16211. else
  16212. {
  16213. strcpy(OcppPath,"");
  16214. }
  16215. return result;
  16216. }
  16217. int GetOcppPort()
  16218. {
  16219. return OcppPort;
  16220. }
  16221. int GetOcppConnStatus(void)
  16222. {
  16223. return ShmOCPP20Data->OcppConnStatus;
  16224. }
  16225. void SetOcppConnStatus(uint8_t status)
  16226. {
  16227. ShmOCPP20Data->OcppConnStatus = status;
  16228. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  16229. }
  16230. int GetHeartBeatWithNOResponse(void)
  16231. {
  16232. return HeartBeatWithNOResponse;
  16233. }
  16234. void SetHeartBeatWithNOResponse(void)
  16235. {
  16236. HeartBeatWithNOResponse = 0;
  16237. }
  16238. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  16239. void storeTempStopTransaction(int gun_index)
  16240. {
  16241. char TempStopTransaction[256];
  16242. char message[1024*20]={0};
  16243. char guid[37]={0};
  16244. json_object *TransactionEvent = json_object_new_object();
  16245. json_object *transactionInfo = json_object_new_object();
  16246. json_object *idToken = json_object_new_object();
  16247. json_object *evse = json_object_new_object();
  16248. json_object *meterValues = json_object_new_array();
  16249. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  16250. DEBUG_INFO("storeTempStopTransaction...\n");
  16251. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  16252. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  16253. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  16254. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  16255. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  16256. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  16257. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  16258. // Message
  16259. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  16260. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  16261. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  16262. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo+1));
  16263. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  16264. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  16265. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  16266. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  16267. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  16268. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  16269. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  16270. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  16271. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  16272. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  16273. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  16274. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  16275. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  16276. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  16277. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  16278. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  16279. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  16280. {
  16281. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  16282. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  16283. json_object_object_add(TransactionEvent, "idToken", idToken);
  16284. }
  16285. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  16286. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  16287. json_object_object_add(TransactionEvent, "evse", evse);
  16288. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  16289. {
  16290. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  16291. {
  16292. json_object *meterValue = json_object_new_object();
  16293. json_object *sampledValues = json_object_new_array();
  16294. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  16295. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  16296. {
  16297. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  16298. ((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)))
  16299. {
  16300. if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, (char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) != NULL)
  16301. {
  16302. json_object *sampledValue = json_object_new_object();
  16303. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  16304. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  16305. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  16306. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  16307. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  16308. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  16309. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  16310. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  16311. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  16312. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  16313. {
  16314. json_object *unitOfMeasure = json_object_new_object();
  16315. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  16316. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  16317. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  16318. }
  16319. json_object_array_add(sampledValues, sampledValue);
  16320. }
  16321. }
  16322. }
  16323. json_object_object_add(meterValue, "sampledValue", sampledValues);
  16324. json_object_array_add(meterValues, meterValue);
  16325. }
  16326. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  16327. }
  16328. random_uuid(guid);
  16329. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL
  16330. , guid
  16331. , "TransactionEvent"
  16332. , json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  16333. json_object_put(TransactionEvent);
  16334. // open file for writing
  16335. FILE *outfile;
  16336. outfile = fopen (TempStopTransaction, "w+");
  16337. //DEBUG_INFO("data = %s\n", queuedata);
  16338. fputs(message, outfile);
  16339. fputs("\n", outfile);
  16340. fclose (outfile);
  16341. }
  16342. void checkTempStopTransaction(int gun_index)
  16343. {
  16344. FILE *fptr1;
  16345. char ch;
  16346. char str[QUEUE_MESSAGE_LENGTH]={0};
  16347. char guid[37]={0};
  16348. char tempdata[65]={0};
  16349. char TempStopTransaction[256];
  16350. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  16351. fptr1 = fopen(TempStopTransaction, "r");
  16352. if (!fptr1)
  16353. {
  16354. //DEBUG_INFO("TempStopTransaction20_%d not found or unable to open the input file!\n", (gun_index+1));
  16355. return ;
  16356. }
  16357. ch=fgetc(fptr1);
  16358. rewind(fptr1);
  16359. if(ch!=EOF)
  16360. {
  16361. // copy all contents to the temporary file except the specific line
  16362. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  16363. {
  16364. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  16365. if(str[0]=='\0')
  16366. {
  16367. break;
  16368. }
  16369. strncpy(guid, str+4, 36); //copy guid
  16370. sprintf(tempdata, "TransactionEvent,%d", (gun_index));
  16371. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  16372. {
  16373. //DEBUG_INFO("StopTransaction mapitem pass\n");
  16374. }
  16375. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  16376. memset(str,0,ARRAY_SIZE(str));
  16377. }
  16378. }
  16379. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  16380. fclose(fptr1);
  16381. remove(TempStopTransaction); // remove the original file
  16382. }
  16383. int GetWebSocketPingInterval(void)
  16384. {
  16385. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  16386. }
  16387. int GetServerSign(void)
  16388. {
  16389. return server_sign;
  16390. }
  16391. uint8_t GetOcppSecurityProfile()
  16392. {
  16393. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  16394. }
  16395. void GetOcppChargerBoxId(uint8_t *data)
  16396. {
  16397. sprintf((char*)data, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  16398. }
  16399. void GetOcppSecurityPassword(uint8_t *data)
  16400. {
  16401. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  16402. }
  16403. void SetServerSign(int value)
  16404. {
  16405. server_sign = value;
  16406. }
  16407. int GetBootNotificationInterval(void)
  16408. {
  16409. return BootNotificationInterval;
  16410. }
  16411. int GetInternetConn(void)
  16412. {
  16413. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  16414. }
  16415. int GetBackendConnectionTimeout(void)
  16416. {
  16417. return ShmSysConfigAndInfo->SysConfig.BackendConnTimeout>=0?ShmSysConfigAndInfo->SysConfig.BackendConnTimeout:300;
  16418. }
  16419. int isConnectorInitMode(int gun_index)
  16420. {
  16421. int tempIndex = 0;
  16422. int result = TRUE;
  16423. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  16424. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  16425. {
  16426. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  16427. {
  16428. tempIndex = ((gun_index==2) ? 1: 0);
  16429. }
  16430. else
  16431. {
  16432. tempIndex = gun_index;
  16433. }
  16434. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  16435. {
  16436. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  16437. {
  16438. result = (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  16439. } //end of the same index
  16440. }//end of for CHAdeMO_QUANTITY
  16441. }
  16442. else if(gunType[gun_index] == GUN_TYPE_CCS)
  16443. {
  16444. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  16445. {
  16446. tempIndex = ((gun_index==2) ? 1: 0);
  16447. }
  16448. else
  16449. {
  16450. tempIndex = gun_index;
  16451. }
  16452. for (int index = 0; index < CCS_QUANTITY; index++)
  16453. {
  16454. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  16455. {
  16456. result = (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  16457. } //end of the same index
  16458. } // end of for CCS_QUANTITY
  16459. }
  16460. else if(gunType[gun_index] == GUN_TYPE_GBT)
  16461. {
  16462. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  16463. {
  16464. tempIndex = ((gun_index==2) ? 1: 0);
  16465. }
  16466. else
  16467. {
  16468. tempIndex = gun_index;
  16469. }
  16470. for (int index = 0; index < GB_QUANTITY; index++)
  16471. {
  16472. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  16473. {
  16474. result = (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  16475. } //end of the same index
  16476. } // end of for GB_QUANTITY
  16477. }
  16478. else if(gunType[gun_index] == GUN_TYPE_DO)
  16479. {
  16480. tempIndex = gun_index;
  16481. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  16482. {
  16483. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  16484. {
  16485. result = (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  16486. } //end of the same index
  16487. }
  16488. }
  16489. else
  16490. {
  16491. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  16492. {
  16493. tempIndex = 2;
  16494. }
  16495. else
  16496. {
  16497. tempIndex = gun_index;
  16498. }
  16499. for (int index = 0; index < AC_QUANTITY; index++)
  16500. {
  16501. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  16502. {
  16503. result = (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  16504. }//end of the same index
  16505. }//end of for AC_QUANTITY
  16506. }
  16507. return result;
  16508. }
  16509. void refreshProcDogTimer()
  16510. {
  16511. ShmOCPP20Data->procDogTime = time((time_t*)NULL);
  16512. }
  16513. void InitialSystemValue(void)
  16514. {
  16515. localversion=0;
  16516. BootNotificationInterval = 10;
  16517. authorizeRetryTimes = 0;
  16518. GunStatusInterval = 10;
  16519. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  16520. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  16521. //Hear Beat
  16522. HeartBeatWithNOResponse = 0;
  16523. HeartBeatCountPerHour = 0;
  16524. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  16525. FirstHeartBeat = 0;
  16526. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  16527. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  16528. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  16529. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  16530. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  16531. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  16532. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  16533. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  16534. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  16535. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  16536. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  16537. //Status && ConnectorPlugIn Setting
  16538. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  16539. {
  16540. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  16541. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  16542. }
  16543. for (int index = 0; index < CCS_QUANTITY; index++)
  16544. {
  16545. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  16546. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  16547. }
  16548. for (int index = 0; index < GB_QUANTITY; index++)
  16549. {
  16550. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  16551. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  16552. }
  16553. for (int index = 0; index < AC_QUANTITY; index++)
  16554. {
  16555. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  16556. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  16557. }
  16558. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  16559. {
  16560. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  16561. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  16562. }
  16563. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  16564. {
  16565. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  16566. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  16567. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  16568. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  16569. refreshStartTimer(&clientTime.StatusNotification[gun_index]);
  16570. memset(&ShmOCPP20Data->StatusNotification[gun_index], 0x00, sizeof(struct StatusNotification_20));
  16571. }
  16572. refreshStartTimer(&clientTime.Heartbeat);
  16573. sleep(1);
  16574. }
  16575. void LWS_Send(char *str)
  16576. {
  16577. //=====================================================
  16578. // Check InternetConn 0: disconnected, 1: connected
  16579. //====================================================
  16580. if(GetOcppConnStatus() == 0)
  16581. {
  16582. DEBUG_INFO("offline now !!!\n");
  16583. return;
  16584. }
  16585. // Only disable isWebsocketSendable operation initiated by charger
  16586. if((strstr((char*)str, "\"Authorize\"") != NULL)
  16587. || (strstr((char*)str, "\"BootNotification\"") != NULL)
  16588. || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
  16589. || (strstr((char*)str, "\"DataTransfer\"") != NULL)
  16590. || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
  16591. || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
  16592. || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
  16593. || (strstr((char*)str, "\"Heartbeat\"") != NULL)
  16594. || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
  16595. || (strstr((char*)str, "\"MeterValues\"") != NULL)
  16596. || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
  16597. || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
  16598. || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
  16599. || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
  16600. || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
  16601. || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
  16602. || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
  16603. || (strstr((char*)str, "\"NotifyReport\"") != NULL)
  16604. || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
  16605. || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
  16606. || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
  16607. || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
  16608. || (strstr((char*)str, "\"SignCertificate\"") != NULL)
  16609. || (strstr((char*)str, "\"StatusNotification\"") != NULL)
  16610. || (strstr((char*)str, "\"TransactionEvent\"") != NULL))
  16611. {
  16612. isWebsocketSendable = OFF;
  16613. }
  16614. pthread_mutex_lock(&lock_send);
  16615. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  16616. sprintf((char *)SendBuffer, "%s", str);
  16617. SendBufLen = strlen(str);
  16618. pthread_mutex_unlock(&lock_send);
  16619. lws_callback_on_writable(wsi_client);
  16620. //lws_service(context, 0);
  16621. //sleep(1);
  16622. }
  16623. void LWS_SendNow(char *str)
  16624. {
  16625. //=====================================================
  16626. // Check InternetConn 0: disconnected, 1: connected
  16627. //====================================================
  16628. if(GetOcppConnStatus() == 0)
  16629. {
  16630. DEBUG_INFO("offline now !!!\n");
  16631. return;
  16632. }
  16633. // Only disable isWebsocketSendable operation initiated by charger
  16634. if((strstr((char*)str, "\"Authorize\"") != NULL)
  16635. || (strstr((char*)str, "\"BootNotification\"") != NULL)
  16636. || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
  16637. || (strstr((char*)str, "\"DataTransfer\"") != NULL)
  16638. || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
  16639. || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
  16640. || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
  16641. || (strstr((char*)str, "\"Heartbeat\"") != NULL)
  16642. || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
  16643. || (strstr((char*)str, "\"MeterValues\"") != NULL)
  16644. || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
  16645. || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
  16646. || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
  16647. || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
  16648. || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
  16649. || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
  16650. || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
  16651. || (strstr((char*)str, "\"NotifyReport\"") != NULL)
  16652. || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
  16653. || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
  16654. || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
  16655. || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
  16656. || (strstr((char*)str, "\"SignCertificate\"") != NULL)
  16657. || (strstr((char*)str, "\"StatusNotification\"") != NULL)
  16658. || (strstr((char*)str, "\"TransactionEvent\"") != NULL))
  16659. {
  16660. isWebsocketSendable = OFF;
  16661. }
  16662. pthread_mutex_lock(&lock_send);
  16663. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  16664. sprintf((char *)SendBuffer, "%s", str);
  16665. SendBufLen = strlen(str);
  16666. pthread_mutex_unlock(&lock_send);
  16667. lws_callback_on_writable(wsi_client);
  16668. lws_service(context, 0);
  16669. //sleep(1);
  16670. }