MessageHandler.c 956 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570
  1. #include "Module_OcppBackend20.h"
  2. #include "define.h"
  3. static char *APNAuthenticationEnumTypeStr[] = {
  4. MACROSTR(CHAP),
  5. MACROSTR(NONE),
  6. MACROSTR(PAP),
  7. MACROSTR(AUTO)
  8. };
  9. static char *AttributeEnumTypeStr[] = {
  10. MACROSTR(Actual),
  11. MACROSTR(Target),
  12. MACROSTR(MinSet),
  13. MACROSTR(MaxSet)
  14. };
  15. static char *AuthorizationStatusEnumTypeStr[] = {
  16. MACROSTR(Accepted),
  17. MACROSTR(Blocked),
  18. MACROSTR(ConcurrentTx),
  19. MACROSTR(Expired),
  20. MACROSTR(Invalid),
  21. MACROSTR(NoCredit),
  22. MACROSTR(NotAllowedTypeEVSE),
  23. MACROSTR(NotAtThisLocation),
  24. MACROSTR(NotAtThisTime),
  25. MACROSTR(Unknown)
  26. };
  27. #if 0
  28. static char *AuthorizeCertificateStatusEnumTypeStr[] = {
  29. MACROSTR(Accepted),
  30. MACROSTR(SignatureError),
  31. MACROSTR(CertificateExpired),
  32. MACROSTR(CertificateRevoked),
  33. MACROSTR(NoCertificateAvailable),
  34. MACROSTR(CertChainError),
  35. MACROSTR(ContractCancelled)
  36. };
  37. #endif
  38. static char *BootReasonEnumTypeStr[] = {
  39. MACROSTR(ApplicationReset),
  40. MACROSTR(FirmwareUpdate),
  41. MACROSTR(LocalReset),
  42. MACROSTR(PowerUp),
  43. MACROSTR(RemoteReset),
  44. MACROSTR(ScheduledReset),
  45. MACROSTR(Triggered),
  46. MACROSTR(Unknown),
  47. MACROSTR(Watchdog)
  48. };
  49. static char *CancelReservationStatusEnumTypeStr[] = {
  50. MACROSTR(Accepted),
  51. MACROSTR(Rejected)
  52. };
  53. static char *CertificateActionEnumTypeStr[] = {
  54. MACROSTR(Install),
  55. MACROSTR(Update)
  56. };
  57. static char *CertificateSignedStatusEnumTypeStr[] = {
  58. MACROSTR(Accepted),
  59. MACROSTR(Rejected)
  60. };
  61. static char *CertificateSigningUseEnumTypeStr[] = {
  62. MACROSTR(ChargingStationCertificate),
  63. MACROSTR(V2GCertificate)
  64. };
  65. static char *ChangeAvailabilityStatusEnumTypeStr[] = {
  66. MACROSTR(Accepted),
  67. MACROSTR(Rejected),
  68. MACROSTR(Scheduled)
  69. };
  70. #if 0
  71. static char *ChargingLimitSourceEnumTypeStr[] = {
  72. MACROSTR(EMS),
  73. MACROSTR(Other),
  74. MACROSTR(SO),
  75. MACROSTR(CSO)
  76. };
  77. #endif
  78. static char *ChargingProfileKindEnumTypeStr[] = {
  79. MACROSTR(Absolute),
  80. MACROSTR(Recurring),
  81. MACROSTR(Relative)
  82. };
  83. static char *ChargingProfilePurposeEnumTypeStr[] = {
  84. MACROSTR(ChargingStationExternalConstraints),
  85. MACROSTR(ChargingStationMaxProfile),
  86. MACROSTR(TxDefaultProfile),
  87. MACROSTR(TxProfile)
  88. };
  89. static char *ChargingProfileStatusEnumTypeStr[] = {
  90. MACROSTR(Accepted),
  91. MACROSTR(Rejected)
  92. };
  93. static char *ChargingRateUnitEnumTypeStr[] = {
  94. MACROSTR(W),
  95. MACROSTR(A)
  96. };
  97. static char *ChargingStateEnumTypeStr[] = {
  98. MACROSTR(Charging),
  99. MACROSTR(EVConnected),
  100. MACROSTR(SuspendedEV),
  101. MACROSTR(SuspendedEVSE),
  102. MACROSTR(Idle)
  103. };
  104. static char *ClearCacheStatusEnumTypeStr[] = {
  105. MACROSTR(Accepted),
  106. MACROSTR(Rejected)
  107. };
  108. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  109. MACROSTR(Accepted),
  110. MACROSTR(Unknown)
  111. };
  112. static char *ClearMessageStatusEnumTypeStr[] = {
  113. MACROSTR(Accepted),
  114. MACROSTR(Unknown)
  115. };
  116. static char *ClearMonitoringStatusEnumTypeStr[] = {
  117. MACROSTR(Accepted),
  118. MACROSTR(Rejected),
  119. MACROSTR(NotFound)
  120. };
  121. static char *ComponentCriterionEnumTypeStr[] = {
  122. MACROSTR(Active),
  123. MACROSTR(Available),
  124. MACROSTR(Enabled),
  125. MACROSTR(Problem)
  126. };
  127. #if 0
  128. static char *ConnectorEnumTypeStr[] = {
  129. MACROSTR(cCCS1),
  130. MACROSTR(cCCS2),
  131. MACROSTR(cG105),
  132. MACROSTR(cTesla),
  133. MACROSTR(cType1),
  134. MACROSTR(cType2),
  135. MACROSTR(s309-1P-16A),
  136. MACROSTR(s309-1P-32A),
  137. MACROSTR(s309-3P-16A),
  138. MACROSTR(s309-3P-32A),
  139. MACROSTR(sBS1361),
  140. MACROSTR(sCEE-7-7),
  141. MACROSTR(sType2),
  142. MACROSTR(sType3),
  143. MACROSTR(Other1PhMax16A),
  144. MACROSTR(Other1PhOver16A),
  145. MACROSTR(Other3Ph),
  146. MACROSTR(Pan),
  147. MACROSTR(wInductive),
  148. MACROSTR(wResonant),
  149. MACROSTR(Undetermined),
  150. MACROSTR(Unknown)
  151. };
  152. #endif
  153. static char *ConnectorStatusEnumTypeStr[] = {
  154. MACROSTR(Available),
  155. MACROSTR(Occupied),
  156. MACROSTR(Reserved),
  157. MACROSTR(Unavailable),
  158. MACROSTR(Faulted)
  159. };
  160. #if 0
  161. static char *CostKindEnumTypeStr[] = {
  162. MACROSTR(CarbonDioxideEmission),
  163. MACROSTR(RelativePricePercentage),
  164. MACROSTR(RenewableGenerationPercentage)
  165. };
  166. #endif
  167. static char *CustomerInformationStatusEnumTypeStr[] = {
  168. MACROSTR(Accepted),
  169. MACROSTR(Rejected),
  170. MACROSTR(Invalid)
  171. };
  172. static char *DataEnumTypeStr[] = {
  173. MACROSTR(string),
  174. MACROSTR(decimal),
  175. MACROSTR(integer),
  176. MACROSTR(dateTime),
  177. MACROSTR(boolean),
  178. MACROSTR(OptionList),
  179. MACROSTR(SequenceList),
  180. MACROSTR(MemberList)
  181. };
  182. static char *DataTransferStatusEnumTypeStr[] = {
  183. MACROSTR(Accepted),
  184. MACROSTR(Rejected),
  185. MACROSTR(UnknownMessageId),
  186. MACROSTR(UnknownVendorId)
  187. };
  188. static char *DeleteCertificateStatusEnumTypeStr[] = {
  189. MACROSTR(Accepted),
  190. MACROSTR(Failed),
  191. MACROSTR(NotFound)
  192. };
  193. static char *DisplayMessageStatusEnumTypeStr[] = {
  194. MACROSTR(Accepted),
  195. MACROSTR(NotSupportedMessageFormat),
  196. MACROSTR(Rejected),
  197. MACROSTR(NotSupportedPriority),
  198. MACROSTR(NotSupportedState),
  199. MACROSTR(UnknownTransaction)
  200. };
  201. #if 0
  202. static char *EnergyTransferModeEnumTypeStr[] = {
  203. MACROSTR(DC),
  204. MACROSTR(AC_single_phase),
  205. MACROSTR(AC_two_phase),
  206. MACROSTR(AC_three_phase)
  207. };
  208. #endif
  209. static char *EventNotificationEnumTypeStr[] = {
  210. MACROSTR(HardWiredNotification),
  211. MACROSTR(HardWiredMonitor),
  212. MACROSTR(PreconfiguredMonitor),
  213. MACROSTR(CustomMonitor)
  214. };
  215. static char *EventTriggerEnumTypeStr[] = {
  216. MACROSTR(Alerting),
  217. MACROSTR(Delta),
  218. MACROSTR(Periodic)
  219. };
  220. static char *FirmwareStatusEnumTypeStr[] = {
  221. MACROSTR(Downloaded),
  222. MACROSTR(DownloadFailed),
  223. MACROSTR(Downloading),
  224. MACROSTR(DownloadScheduled),
  225. MACROSTR(DownloadPaused),
  226. MACROSTR(Idle),
  227. MACROSTR(InstallationFailed),
  228. MACROSTR(Installing),
  229. MACROSTR(Installed),
  230. MACROSTR(InstallRebooting),
  231. MACROSTR(InstallScheduled),
  232. MACROSTR(InstallVerificationFailed),
  233. MACROSTR(InvalidSignature),
  234. MACROSTR(SignatureVerified)
  235. };
  236. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  237. MACROSTR(Accepted),
  238. MACROSTR(Rejected),
  239. MACROSTR(NotSupported),
  240. MACROSTR(EmptyResultSet)
  241. };
  242. static char *GenericStatusEnumTypeStr[] = {
  243. MACROSTR(Accepted),
  244. MACROSTR(Rejected)
  245. };
  246. static char *GetCertificateIdUseEnumTypeStr[] = {
  247. MACROSTR(V2GRootCertificate),
  248. MACROSTR(MORootCertificate),
  249. MACROSTR(CSMSRootCertificate),
  250. MACROSTR(V2GCertificateChain),
  251. MACROSTR(ManufacturerRootCertificate)
  252. };
  253. static char *GetCertificateStatusEnumTypeStr[] = {
  254. MACROSTR(Accepted),
  255. MACROSTR(Failed)
  256. };
  257. static char *GetChargingProfileStatusEnumTypeStr[] = {
  258. MACROSTR(Accepted),
  259. MACROSTR(NoProfiles)
  260. };
  261. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  262. MACROSTR(Accepted),
  263. MACROSTR(Unknown)
  264. };
  265. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  266. MACROSTR(Accepted),
  267. MACROSTR(NotFound)
  268. };
  269. static char *GetVariableStatusEnumTypeStr[] = {
  270. MACROSTR(Accepted),
  271. MACROSTR(Rejected),
  272. MACROSTR(UnknownComponent),
  273. MACROSTR(UnknownVariable),
  274. MACROSTR(NotSupportedAttributeType)
  275. };
  276. static char *HashAlgorithmEnumTypeStr[] = {
  277. MACROSTR(SHA256),
  278. MACROSTR(SHA384),
  279. MACROSTR(SHA512)
  280. };
  281. static char *IdTokenEnumTypeStr[] = {
  282. MACROSTR(Central),
  283. MACROSTR(eMAID),
  284. MACROSTR(ISO14443),
  285. MACROSTR(KeyCode),
  286. MACROSTR(Local),
  287. MACROSTR(NoAuthorization),
  288. MACROSTR(ISO15693)
  289. };
  290. static char *InstallCertificateUseEnumTypeStr[] = {
  291. MACROSTR(V2GRootCertificate),
  292. MACROSTR(MORootCertificate),
  293. MACROSTR(CSMSRootCertificate),
  294. MACROSTR(ManufacturerRootCertificate)
  295. };
  296. static char *InstallCertificateStatusEnumTypeStr[]={
  297. MACROSTR(Accepted),
  298. MACROSTR(Failed),
  299. MACROSTR(Rejected)
  300. };
  301. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  302. MACROSTR(Accepted),
  303. MACROSTR(Failed)
  304. };
  305. static char *LocationEnumTypeStr[] = {
  306. MACROSTR(Body),
  307. MACROSTR(Cable),
  308. MACROSTR(EV),
  309. MACROSTR(Inlet),
  310. MACROSTR(Outlet)
  311. };
  312. static char *LogEnumTypeStr[] = {
  313. MACROSTR(DiagnosticsLog),
  314. MACROSTR(SecurityLog)
  315. };
  316. static char *LogStatusEnumTypeStr[] = {
  317. MACROSTR(Accepted),
  318. MACROSTR(Rejected),
  319. MACROSTR(AcceptedCanceled)
  320. };
  321. static char *MeasurandEnumTypeStr[] = {
  322. MACROSTR(Current.Export),
  323. MACROSTR(Current.Import),
  324. MACROSTR(Current.Offered),
  325. MACROSTR(Energy.Active.Export.Register),
  326. MACROSTR(Energy.Active.Import.Register),
  327. MACROSTR(Energy.Reactive.Export.Register),
  328. MACROSTR(Energy.Reactive.Import.Register),
  329. MACROSTR(Energy.Active.Export.Interval),
  330. MACROSTR(Energy.Active.Import.Interval),
  331. MACROSTR(Energy.Active.Net),
  332. MACROSTR(Energy.Reactive.Export.Interval),
  333. MACROSTR(Energy.Reactive.Import.Interval),
  334. MACROSTR(Energy.Reactive.Net),
  335. MACROSTR(Energy.Apparent.Net),
  336. MACROSTR(Energy.Apparent.Import),
  337. MACROSTR(Energy.Apparent.Export),
  338. MACROSTR(Frequency),
  339. MACROSTR(Power.Active.Export),
  340. MACROSTR(Power.Active.Import),
  341. MACROSTR(Power.Factor),
  342. MACROSTR(Power.Offered),
  343. MACROSTR(Power.Reactive.Export),
  344. MACROSTR(Power.Reactive.Import),
  345. MACROSTR(SoC),
  346. MACROSTR(Voltage)
  347. };
  348. static char *MessageFormatEnumTypeStr[] = {
  349. MACROSTR(ASCII),
  350. MACROSTR(HTML),
  351. MACROSTR(URI),
  352. MACROSTR(UTF8)
  353. };
  354. static char *MessagePriorityEnumTypeStr[] = {
  355. MACROSTR(AlwaysFront),
  356. MACROSTR(InFront),
  357. MACROSTR(NormalCycle)
  358. };
  359. static char *MessageStateEnumTypeStr[] = {
  360. MACROSTR(Charging),
  361. MACROSTR(Faulted),
  362. MACROSTR(Idle),
  363. MACROSTR(Unavailable)
  364. };
  365. static char *MessageTriggerEnumTypeStr[] = {
  366. MACROSTR(BootNotification),
  367. MACROSTR(LogStatusNotification),
  368. MACROSTR(FirmwareStatusNotification),
  369. MACROSTR(Heartbeat),
  370. MACROSTR(MeterValues),
  371. MACROSTR(SignChargingStationCertificate),
  372. MACROSTR(SignV2GCertificate),
  373. MACROSTR(StatusNotification),
  374. MACROSTR(TransactionEvent),
  375. MACROSTR(SignCombinedCertificate),
  376. MACROSTR(PublishFirmwareStatusNotification)
  377. };
  378. static char *MonitorEnumTypeStr[] = {
  379. MACROSTR(UpperThreshold),
  380. MACROSTR(LowerThreshold),
  381. MACROSTR(Delta),
  382. MACROSTR(Periodic),
  383. MACROSTR(PeriodicClockAligned)
  384. };
  385. static char *MonitoringBaseEnumTypeStr[] = {
  386. MACROSTR(All),
  387. MACROSTR(FactoryDefault),
  388. MACROSTR(HardWiredOnly)
  389. };
  390. static char *MonitoringCriterionEnumTypeStr[] = {
  391. MACROSTR(ThresholdMonitoring),
  392. MACROSTR(DeltaMonitoring),
  393. MACROSTR(PeriodicMonitoring)
  394. };
  395. static char *MutabilityEnumTypeStr[] = {
  396. MACROSTR(ReadOnly),
  397. MACROSTR(WriteOnly),
  398. MACROSTR(ReadWrite)
  399. };
  400. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  401. MACROSTR(Accepted),
  402. MACROSTR(Rejected),
  403. MACROSTR(Processing)
  404. };
  405. static char *OCPPInterfaceEnumTypeStr[] = {
  406. MACROSTR(Wired0),
  407. MACROSTR(Wired1),
  408. MACROSTR(Wired2),
  409. MACROSTR(Wired3),
  410. MACROSTR(Wireless0),
  411. MACROSTR(Wireless1),
  412. MACROSTR(Wireless2),
  413. MACROSTR(Wireless3)
  414. };
  415. static char *OCPPTransportEnumTypeStr[] = {
  416. MACROSTR(JSON),
  417. MACROSTR(SOAP)
  418. };
  419. static char *OCPPVersionEnumTypeStr[] = {
  420. MACROSTR(OCPP12),
  421. MACROSTR(OCPP15),
  422. MACROSTR(OCPP16),
  423. MACROSTR(OCPP20)
  424. };
  425. static char *OperationalStatusEnumTypeStr[] = {
  426. MACROSTR(Inoperative),
  427. MACROSTR(Operative)
  428. };
  429. static char *PhaseEnumTypeStr[] = {
  430. MACROSTR(L1),
  431. MACROSTR(L2),
  432. MACROSTR(L3),
  433. MACROSTR(N),
  434. MACROSTR(L1-N),
  435. MACROSTR(L2-N),
  436. MACROSTR(L3-N),
  437. MACROSTR(L1-L2),
  438. MACROSTR(L2-L3),
  439. MACROSTR(L3-L1)
  440. };
  441. static char *PublishFirmwareStatusEnumTypeStr[] = {
  442. MACROSTR(Downloaded),
  443. MACROSTR(DownloadFailed),
  444. MACROSTR(Downloading),
  445. MACROSTR(DownloadScheduled),
  446. MACROSTR(DownloadPaused),
  447. MACROSTR(PublishFailed),
  448. MACROSTR(Published),
  449. MACROSTR(InvalidChecksum),
  450. MACROSTR(ChecksumVerified)
  451. };
  452. static char *ReadingContextEnumTypeStr[] = {
  453. MACROSTR(Interruption.Begin),
  454. MACROSTR(Interruption.End),
  455. MACROSTR(Other),
  456. MACROSTR(Sample.Clock),
  457. MACROSTR(Sample.Periodic),
  458. MACROSTR(Transaction.Begin),
  459. MACROSTR(Transaction.End),
  460. MACROSTR(Trigger)
  461. };
  462. #if 0
  463. static char *ReasonEnumTypeStr[] = {
  464. MACROSTR(DeAuthorized),
  465. MACROSTR(EmergencyStop),
  466. MACROSTR(EnergyLimitReached),
  467. MACROSTR(EVDisconnected),
  468. MACROSTR(GroundFault),
  469. MACROSTR(ImmediateReset),
  470. MACROSTR(Local),
  471. MACROSTR(LocalOutOfCredit),
  472. MACROSTR(MasterPass),
  473. MACROSTR(Other),
  474. MACROSTR(OvercurrentFault),
  475. MACROSTR(PowerLoss),
  476. MACROSTR(PowerQuality),
  477. MACROSTR(Reboot),
  478. MACROSTR(Remote),
  479. MACROSTR(SOCLimitReached),
  480. MACROSTR(StoppedByEV),
  481. MACROSTR(TimeLimitReached),
  482. MACROSTR(TimeLimitReached)
  483. };
  484. #endif
  485. static char *RecurrencyKindEnumTypeStr[] = {
  486. MACROSTR(Daily),
  487. MACROSTR(Weekly)
  488. };
  489. static char *RegistrationStatusEnumTypeStr[] = {
  490. MACROSTR(Accepted),
  491. MACROSTR(Pending),
  492. MACROSTR(Rejected)
  493. };
  494. static char *ReportBaseEnumTypeStr[] = {
  495. MACROSTR(ConfigurationInventory),
  496. MACROSTR(FullInventory),
  497. MACROSTR(SummaryInventory)
  498. };
  499. static char *RequestStartStopStatusEnumTypeStr[] = {
  500. MACROSTR(Accepted),
  501. MACROSTR(Rejected)
  502. };
  503. static char *ReservationUpdateStatusEnumTypeStr[] = {
  504. MACROSTR(Expired),
  505. MACROSTR(Removed)
  506. };
  507. static char *ReserveNowStatusEnumTypeStr[] = {
  508. MACROSTR(Accepted),
  509. MACROSTR(Faulted),
  510. MACROSTR(Occupied),
  511. MACROSTR(Rejected),
  512. MACROSTR(Unavailable)
  513. };
  514. static char *ResetEnumTypeStr[] = {
  515. MACROSTR(Immediate),
  516. MACROSTR(OnIdle)
  517. };
  518. static char *ResetStatusEnumTypeStr[] = {
  519. MACROSTR(Accepted),
  520. MACROSTR(Rejected),
  521. MACROSTR(Scheduled)
  522. };
  523. static char *SetMonitoringStatusEnumTypeStr[] = {
  524. MACROSTR(Accepted),
  525. MACROSTR(UnknownComponent),
  526. MACROSTR(UnknownVariable),
  527. MACROSTR(UnsupportedMonitorType),
  528. MACROSTR(Rejected),
  529. MACROSTR(OutOfRange),
  530. MACROSTR(Duplicate)
  531. };
  532. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  533. MACROSTR(Accepted),
  534. MACROSTR(Rejected),
  535. MACROSTR(Failed)
  536. };
  537. static char *SetVariableStatusEnumTypeStr[] = {
  538. MACROSTR(Accepted),
  539. MACROSTR(Rejected),
  540. MACROSTR(InvalidValue),
  541. MACROSTR(UnknownComponent),
  542. MACROSTR(UnknownVariable),
  543. MACROSTR(NotSupportedAttributeType),
  544. MACROSTR(OutOfRange),
  545. MACROSTR(RebootRequired)
  546. };
  547. static char *TransactionEventEnumTypeStr[] = {
  548. MACROSTR(Ended),
  549. MACROSTR(Started),
  550. MACROSTR(Updated)
  551. };
  552. static char *TriggerMessageStatusEnumTypeStr[] = {
  553. MACROSTR(Accepted),
  554. MACROSTR(Rejected),
  555. MACROSTR(NotImplemented)
  556. };
  557. static char *TriggerReasonEnumTypeStr[] = {
  558. MACROSTR(Authorized),
  559. MACROSTR(CablePluggedIn),
  560. MACROSTR(ChargingRateChanged),
  561. MACROSTR(ChargingStateChanged),
  562. MACROSTR(Deauthorized),
  563. MACROSTR(EnergyLimitReached),
  564. MACROSTR(EVCommunicationLost),
  565. MACROSTR(EVConnectTimeout),
  566. MACROSTR(MeterValueClock),
  567. MACROSTR(MeterValuePeriodic),
  568. MACROSTR(TimeLimitReached),
  569. MACROSTR(Trigger),
  570. MACROSTR(UnlockCommand),
  571. MACROSTR(StopAuthorized),
  572. MACROSTR(EVDeparted),
  573. MACROSTR(EVDetected),
  574. MACROSTR(RemoteStop),
  575. MACROSTR(RemoteStart),
  576. MACROSTR(AbnormalCondition),
  577. MACROSTR(SignedDataReceived),
  578. MACROSTR(ResetCommand)
  579. };
  580. static char *UnlockStatusEnumTypeStr[] = {
  581. MACROSTR(Unlocked),
  582. MACROSTR(UnlockFailed),
  583. MACROSTR(OngoingAuthorizedTransaction),
  584. MACROSTR(UnknownConnector)
  585. };
  586. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  587. MACROSTR(DownloadOngoing),
  588. MACROSTR(NoFirmware),
  589. MACROSTR(Unpublished)
  590. };
  591. static char *UpdateEnumTypeStr[] = {
  592. MACROSTR(Differential),
  593. MACROSTR(Full)
  594. };
  595. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  596. MACROSTR(Accepted),
  597. MACROSTR(Rejected),
  598. MACROSTR(AcceptedCanceled),
  599. MACROSTR(InvalidCertificate),
  600. MACROSTR(RevokedCertificate)
  601. };
  602. static char *UpdateStatusEnumTypeStr[] = {
  603. MACROSTR(Accepted),
  604. MACROSTR(Failed),
  605. MACROSTR(VersionMismatch)
  606. };
  607. static char *UploadLogStatusEnumTypeStr[] = {
  608. MACROSTR(BadMessage),
  609. MACROSTR(Idle),
  610. MACROSTR(NotSupportedOperation),
  611. MACROSTR(PermissionDenied),
  612. MACROSTR(Uploaded),
  613. MACROSTR(UploadFailure),
  614. MACROSTR(Uploading)
  615. };
  616. static char *VPNEnumTypeStr[] = {
  617. MACROSTR(IKEv2),
  618. MACROSTR(IPSec),
  619. MACROSTR(L2TP),
  620. MACROSTR(PPTP)
  621. };
  622. #if 0
  623. static char *ChargePointErrorCodeEnumTypeStr[] = {
  624. MACROSTR(ConnectorLockFailure),
  625. MACROSTR(EVCommunicationError),
  626. MACROSTR(GroundFailure),
  627. MACROSTR(HighTemperature),
  628. MACROSTR(InternalError),
  629. MACROSTR(LocalListConflict),
  630. MACROSTR(NoError),
  631. MACROSTR(OtherError),
  632. MACROSTR(OverCurrentFailure),
  633. MACROSTR(OverVoltage),
  634. MACROSTR(PowerMeterFailure),
  635. MACROSTR(PowerSwitchFailure),
  636. MACROSTR(ReaderFailure),
  637. MACROSTR(ResetFailure),
  638. MACROSTR(UnderVoltage),
  639. MACROSTR(WeakSignal)
  640. };
  641. #endif
  642. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  643. MACROSTR(Accepted),
  644. MACROSTR(Rejected)
  645. };
  646. static char *RemoteStartStopStatusEnumTypeStr[] = {
  647. MACROSTR(Accepted),
  648. MACROSTR(Rejected)
  649. };
  650. #if 0
  651. static char * StopTransactionReasonEnumTypeStr[] = {
  652. MACROSTR(EmergencyStop),
  653. MACROSTR(EVDisconnected),
  654. MACROSTR(HardReset),
  655. MACROSTR(Local),
  656. MACROSTR(Other),
  657. MACROSTR(PowerLoss),
  658. MACROSTR(Reboot),
  659. MACROSTR(Remote),
  660. MACROSTR(SoftReset),
  661. MACROSTR(UnlockCommand),
  662. MACROSTR(DeAuthorized)
  663. };
  664. #endif
  665. //ChargePointMaxProfile
  666. #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile_OCPP20.json"
  667. //TxDefaultProfile
  668. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  669. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  670. struct StatusCodeData *ShmStatusCodeData;
  671. struct PsuData *ShmPsuData ;
  672. struct OCPP20Data *ShmOCPP20Data;
  673. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  674. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  675. //===============================
  676. // Gun Total Numbers
  677. //===============================
  678. static int gunTotalNumber = 0;
  679. static uint8_t gunType[4] = {0};
  680. //===============================
  681. // Local List Version
  682. //===============================
  683. static int localversion=0;
  684. //===============================
  685. // OCPP sign variable
  686. //===============================
  687. static int server_sign = FALSE;
  688. int server_pending = FALSE;
  689. static int BootNotificationInterval = 10;
  690. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  691. //===============================
  692. // OCPP auth variable
  693. //===============================
  694. static int authorizeRetryTimes = 0; //number of Retry times
  695. //===============================
  696. // OCPP other variables
  697. //===============================
  698. static int HeartBeatWaitTime = 10;
  699. static int FirstHeartBeat = 0;
  700. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  701. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  702. static char CurrentChargingProfileScheduleStr[30] = {0};
  703. //========================================
  704. // OCPP status/previous related variables
  705. //========================================
  706. static int GunStatusInterval = 10;
  707. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  708. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  709. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  710. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  711. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  712. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  713. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  714. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  715. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  716. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  717. static int TransactionMessageAttemptsValue = 0;
  718. static int TransactionMessageRetryIntervalValue = 0;
  719. static struct AuthorizationData idTagQuery;
  720. //=============================================
  721. // OCPP HeartBeat Response Not Receive Counts
  722. //============================================
  723. static int HeartBeatWithNOResponse = 0;
  724. static int HeartBeatCountPerHour = 0;
  725. sqlite3 *db;
  726. extern void ChageWebSocketPingInterval(int WebSocketPingInterval);
  727. int TransactionMessageAttemptsGet(void);
  728. int TransactionMessageRetryIntervalGet(void);
  729. int GetOcppConnStatus(void);
  730. void SetOcppConnStatus(uint8_t status);
  731. int setKeyValue(char *key, char *value);
  732. void OCPP_get_TableAuthlocalAllData(void);
  733. void processUnkownKey(void);
  734. struct StructOCPPMeterValue
  735. {
  736. unsigned char TimeStamp[28];
  737. struct StructSampledValue SampledValue[10];
  738. };
  739. struct ClientTime
  740. {
  741. unsigned int Heartbeat;
  742. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  743. unsigned int StartTransaction;
  744. unsigned int StopTransaction;
  745. unsigned int MeterValues[CONNECTOR_QUANTITY];
  746. }clientTime;
  747. typedef union
  748. {
  749. //Operations Initiated by Central System
  750. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  751. struct
  752. {
  753. //CsMsgValue[0]
  754. unsigned char StatusNotificationReq:1; //bit 0,
  755. unsigned char StatusNotificationConf:1; //bit 1,
  756. unsigned char TriggerMeterValueReq:1; //bit 2,
  757. unsigned char TransactionEventReq:1; //bit 3,
  758. unsigned char SampleMeterReq:1; //bit 4,
  759. unsigned char ClockAlignMeterReq:1; //bit 5,
  760. unsigned char TriggerStatusNotificationReq:1; //bit 6,
  761. unsigned char isOnCharging:1; //bit7
  762. }bits[CONNECTOR_QUANTITY];
  763. }CpinitiateMsg;
  764. CpinitiateMsg cpinitateMsg;
  765. //=========================================
  766. // Save configuration
  767. //=========================================
  768. int runShellCmd(const char*cmd)
  769. {
  770. int result = FAIL;
  771. char buf[256];
  772. FILE *fp;
  773. fp = popen(cmd, "r");
  774. if(fp != NULL)
  775. {
  776. while(fgets(buf, sizeof(buf), fp) != NULL)
  777. {
  778. DEBUG_INFO("%s\n", buf);
  779. }
  780. result = PASS;
  781. }
  782. pclose(fp);
  783. return result;
  784. }
  785. int StoreUsrConfigData(struct SysConfigData *UsrData)
  786. {
  787. int result = PASS;
  788. int fd,wrd;
  789. unsigned int i,Chk;
  790. unsigned char *ptr, *BufTmp;
  791. int MtdBlockSize = 0x300000;
  792. Chk=0;
  793. ptr=(unsigned char *)UsrData;
  794. if((BufTmp=malloc(MtdBlockSize))!=NULL)
  795. {
  796. memset(BufTmp,0,MtdBlockSize);
  797. memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
  798. for(i=ARRAY_SIZE(UsrData->CsuBootLoadFwRev);i<MtdBlockSize-4;i++)
  799. Chk+=*(BufTmp+i);
  800. memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
  801. // Output configuration to file.
  802. fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
  803. if (fd < 0)
  804. {
  805. DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
  806. free(BufTmp);
  807. return 0;
  808. }
  809. wrd=write(fd, BufTmp, MtdBlockSize);
  810. close(fd);
  811. if(wrd<MtdBlockSize)
  812. {
  813. DEBUG_ERROR("write /mnt/EvseConfig.bin NG\n");
  814. free(BufTmp);
  815. return 0;
  816. }
  817. DEBUG_INFO("EvseConfig write to file in /mnt OK.\n");
  818. DEBUG_INFO("Erase /dev/mtd10.\n");
  819. runShellCmd("flash_erase /dev/mtd10 0 0");
  820. DEBUG_INFO("Write /dev/mtd10.\n");
  821. runShellCmd("nandwrite -p /dev/mtd10 /mnt/EvseConfig.bin");
  822. DEBUG_INFO("Erase /dev/mtd11.\n");
  823. runShellCmd("flash_erase /dev/mtd11 0 0");
  824. DEBUG_INFO("Write /dev/mtd11.\n");
  825. runShellCmd("nandwrite -p /dev/mtd11 /mnt/EvseConfig.bin");
  826. system("rm -f /mnt/EvseConfig.bin");
  827. DEBUG_INFO("EvseConfig write to flash OK\n");
  828. }
  829. else
  830. {
  831. DEBUG_ERROR("alloc BlockSize NG\r\n");
  832. result = FAIL;
  833. }
  834. if(BufTmp!=NULL)
  835. free(BufTmp);
  836. return result;
  837. }
  838. //=========================================
  839. // Date time related function
  840. //=========================================
  841. void getNowDatetime(uint8_t *data)
  842. {
  843. time_t t = time(NULL);
  844. struct tm tm = *localtime(&t);
  845. 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);
  846. }
  847. //=========================================
  848. // Sqlite3 related function
  849. //=========================================
  850. int DB_Initial()
  851. {
  852. int result = PASS;
  853. char* errMsg = NULL;
  854. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  855. "idToken text UNIQUE,"
  856. "type text,"
  857. "status text,"
  858. "cacheExpiryDateTime text,"
  859. "chargingPriority integer,"
  860. "language1 text,"
  861. "evseId text,"
  862. "language2 text,"
  863. "groupIdToken_idToken text,"
  864. "groupIdToken_type text,"
  865. "personalMessage text);";
  866. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  867. "idToken text UNIQUE,"
  868. "type text,"
  869. "status text,"
  870. "cacheExpiryDateTime text,"
  871. "chargingPriority integer,"
  872. "language1 text,"
  873. "evseId text,"
  874. "language2 text,"
  875. "groupIdToken_idToken text,"
  876. "groupIdToken_type text,"
  877. "personalMessage text,"
  878. "version text);";
  879. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  880. "componentName text NOT NULL ,"
  881. "componentInstance text, "
  882. "variableName text NOT NULL, "
  883. "variableInstance text, "
  884. "variableCharacteristicsDataType integer, "
  885. "variableCharacteristicsUnit text, "
  886. "variableCharacteristicsMaxLimit real,"
  887. "variableAttributesType text, "
  888. "variableAttributesTypeMutability text, "
  889. "variableAttributesTypeValue text, "
  890. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  891. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  892. "type text);";
  893. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  894. "slot integer UNIQUE, connectionData text);";
  895. char *sqlTransaction = "create table if not exists ocpp20_transaction_record (idx integer primary key,"
  896. "occurDatetime text,"
  897. "message_type text,"
  898. "message_content text)";
  899. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  900. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  901. {
  902. result = FAIL;
  903. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  904. sqlite3_close(db);
  905. }
  906. else
  907. {
  908. DEBUG_INFO( "OCPP local database open successfully.\n");
  909. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  910. {
  911. result = FAIL;
  912. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  913. }
  914. else
  915. {
  916. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  917. }
  918. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  919. {
  920. result = FAIL;
  921. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  922. }
  923. else
  924. {
  925. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  926. }
  927. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  928. {
  929. result = FAIL;
  930. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  931. }
  932. else
  933. {
  934. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  935. }
  936. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  937. {
  938. result = FAIL;
  939. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  940. }
  941. else
  942. {
  943. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  944. }
  945. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  946. {
  947. result = FAIL;
  948. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  949. }
  950. else
  951. {
  952. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  953. }
  954. if (sqlite3_exec(db, sqlTransaction, 0, 0, &errMsg) != SQLITE_OK)
  955. {
  956. result = FAIL;
  957. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_transaction_record table error message: %s\n", errMsg);
  958. }
  959. else
  960. {
  961. DEBUG_INFO( "Create OCPP 2.0 ocpp20_transaction_record table successfully\n");
  962. }
  963. //sqlite3_close(db);
  964. }
  965. return result;
  966. }
  967. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  968. {
  969. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  970. return 0;
  971. }
  972. void DB_getListVerion()
  973. {
  974. char sql[256];
  975. char* errMsg = NULL;
  976. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  977. /* Execute SQL statement */
  978. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  979. {
  980. DEBUG_INFO("SQL error: %s", errMsg);
  981. }
  982. }
  983. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  984. {
  985. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  986. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  987. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  988. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  989. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  990. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  991. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  992. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  993. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  994. return 0;
  995. }
  996. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  997. {
  998. char sql[256];
  999. char* errMsg = NULL;
  1000. memset(&idTagQuery, 0, sizeof(idTagQuery));
  1001. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  1002. if(isQueryFromCache)
  1003. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  1004. else
  1005. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  1006. /* Execute SQL statement */
  1007. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  1008. {
  1009. DEBUG_INFO("SQL error: %s", errMsg);
  1010. }
  1011. }
  1012. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  1013. {
  1014. for (int i = 0; i < columnCount; i++)
  1015. {
  1016. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  1017. }
  1018. return 0;
  1019. }
  1020. void DB_get_TableAuthlocalAllData(void)
  1021. {
  1022. char sql[256];
  1023. char* errMsg = NULL;
  1024. sprintf(sql,"select * from ocpp20_auth_local;");
  1025. /* Execute SQL statement */
  1026. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  1027. {
  1028. DEBUG_INFO("SQL error: %s", errMsg);
  1029. }
  1030. }
  1031. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  1032. {
  1033. for(int i = 0; i<columnCount; i++)
  1034. {
  1035. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1036. }
  1037. return 0;
  1038. }
  1039. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  1040. {
  1041. int result = PASS;
  1042. char sql[512];
  1043. char* errMsg = NULL;
  1044. 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;",
  1045. data->idToken.idToken,
  1046. data->idToken.type,
  1047. data->idTokenInfo.status,
  1048. data->idTokenInfo.cacheExpiryDateTime,
  1049. data->idTokenInfo.chargingPriority,
  1050. data->idTokenInfo.language1,
  1051. data->idTokenInfo.language2,
  1052. data->idTokenInfo.groupIdToken.idToken,
  1053. data->idTokenInfo.groupIdToken.type,
  1054. listVersion);
  1055. //* Execute SQL statement */
  1056. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1057. {
  1058. DEBUG_INFO("SQL error: %s\n", errMsg);
  1059. result = FAIL;
  1060. }
  1061. else
  1062. {
  1063. memset(sql, 0, ARRAY_SIZE(sql));
  1064. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  1065. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  1066. {
  1067. DEBUG_INFO("SQL error: %s\n", errMsg);
  1068. result = FAIL;
  1069. }
  1070. }
  1071. return result;
  1072. }
  1073. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  1074. {
  1075. int result = PASS;
  1076. char sql[512];
  1077. char* errMsg = NULL;
  1078. 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;",
  1079. idToken->idToken,
  1080. idToken->type,
  1081. idTokenInfo->status,
  1082. idTokenInfo->cacheExpiryDateTime,
  1083. idTokenInfo->chargingPriority,
  1084. idTokenInfo->language1,
  1085. idTokenInfo->language2,
  1086. idTokenInfo->groupIdToken.idToken,
  1087. idTokenInfo->groupIdToken.type);
  1088. //* Execute SQL statement */
  1089. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1090. {
  1091. DEBUG_INFO("SQL error: %s\n", errMsg);
  1092. result = FAIL;
  1093. }
  1094. return result;
  1095. }
  1096. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1097. {
  1098. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1099. // printf("localversion=%d\n", localversion);
  1100. return 0;
  1101. }
  1102. void DB_deleteIdTag(char idTag[])
  1103. {
  1104. char sql[512];
  1105. char* errMsg = NULL;
  1106. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1107. //* Execute SQL statement */
  1108. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1109. {
  1110. DEBUG_INFO("SQL error: %s", errMsg);
  1111. }
  1112. }
  1113. int DB_cleanLocalList()
  1114. {
  1115. int result = PASS;
  1116. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1117. char *errMsg = 0;
  1118. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1119. {
  1120. DEBUG_INFO("%s\n", errMsg);
  1121. result = FAIL;
  1122. }
  1123. return result;
  1124. }
  1125. int DB_cleanLocalCache()
  1126. {
  1127. int result = PASS;
  1128. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1129. char *errMsg = 0;
  1130. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1131. {
  1132. DEBUG_INFO("%s\n", errMsg);
  1133. result = FAIL;
  1134. }
  1135. return result;
  1136. }
  1137. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1138. {
  1139. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1140. return 0;
  1141. }
  1142. void DB_getBooType()
  1143. {
  1144. char sql[256];
  1145. char* errMsg = NULL;
  1146. sprintf(sql,"select * from ocpp20_boot_type;");
  1147. /* Execute SQL statement */
  1148. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1149. {
  1150. DEBUG_INFO("SQL error: %s\n", errMsg);
  1151. }
  1152. }
  1153. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1154. {
  1155. for(int i = 0; i<columnCount; i++)
  1156. {
  1157. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1158. }
  1159. return 0;
  1160. }
  1161. int DB_updateBootType(BootReasonEnumType reason)
  1162. {
  1163. int result = PASS;
  1164. char sql[512];
  1165. char* errMsg = NULL;
  1166. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1167. //* Execute SQL statement */
  1168. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1169. {
  1170. DEBUG_INFO("SQL error: %s\n", errMsg);
  1171. result = FAIL;
  1172. }
  1173. return result;
  1174. }
  1175. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1176. {
  1177. for(int i = 0; i<columnCount; i++)
  1178. {
  1179. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1180. }
  1181. return 0;
  1182. }
  1183. int DB_variableSaveToDb(struct ReportDataType *variable)
  1184. {
  1185. int result = FAIL;
  1186. char sql[4096];
  1187. char* errMsg = NULL;
  1188. sprintf(sql,"insert or replace into ocpp20_variable (componentName, componentInstance, variableName, variableInstance, variableCharacteristicsDataType, variableCharacteristicsUnit, variableCharacteristicsMaxLimit, variableAttributesType, variableAttributesTypeMutability, variableAttributesTypeValue) VALUES('%s', '%s', '%s', '%s', '%s', '%s', %f, '%s', '%s', '%s'); SELECT * from ocpp20_variable;",
  1189. variable->component.name,
  1190. variable->component.instance,
  1191. variable->variable.name,
  1192. variable->variable.instance,
  1193. variable->variableCharacteristics.dataType,
  1194. variable->variableCharacteristics.unit,
  1195. variable->variableCharacteristics.maxLimit,
  1196. variable->variableAttribute[0].type,
  1197. variable->variableAttribute[0].mutability,
  1198. variable->variableAttribute[0].value);
  1199. //* Execute SQL statement */
  1200. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1201. {
  1202. DEBUG_INFO("SQL error: %s\n", errMsg);
  1203. result = FAIL;
  1204. }
  1205. return result;
  1206. }
  1207. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1208. {
  1209. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1210. if(atoi(columnValue[0]) == 0)
  1211. {
  1212. DB_updateBootType(BootReasonEnumType_PowerUp);
  1213. // Create variable table content
  1214. /* AlignedDataCtrlr Required item */
  1215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1221. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1228. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1232. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.maxLimit = 20;
  1233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1235. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC,Current.Offered,Power.Offered");
  1237. else
  1238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,Current.Offered");
  1239. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1244. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 10;
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1248. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1255. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1262. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1266. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1269. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1271. else
  1272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1273. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1281. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1282. /* AuthCtrlrVariable Required item */
  1283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1289. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1296. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1303. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1310. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1317. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1324. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1328. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1332. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1333. /* AuthCacheCtrlr Variable Required item*/
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1340. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1347. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1355. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1359. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1363. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1370. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1371. /* ClockCtrlr Variable Required item */
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1377. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1378. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1385. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1393. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1400. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1407. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1415. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1422. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1429. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1430. /* ChargingStation Required item */
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1437. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1444. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1451. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1452. /* Connector Required item */
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1459. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1466. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1473. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1474. /* CustomizationCtrlr Required item */
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1481. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1482. /* DeviceDataCtrlr Required item */
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1490. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1498. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1506. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1514. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1517. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1522. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1525. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1530. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1538. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1546. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1547. /* DisplayMessageCtrlr Required item */
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1554. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1561. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1565. ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.maxLimit = 1;
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "1");
  1569. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1576. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1583. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1584. /* EVSE Required item */
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1591. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1598. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1605. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1612. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1613. /* LocalAuthListCtrlr Required item */
  1614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1620. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1622. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1624. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.maxLimit = 5000;
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1628. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1635. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "500");
  1643. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "20480");
  1651. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1655. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "100000");
  1659. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1660. /* MonitoringCtrlr Required item */
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1667. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1674. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1675. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1682. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1690. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1698. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1706. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1713. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1714. /* OCPPCommCtrlr Required item */
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1720. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1721. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1730. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1737. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1745. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1752. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1759. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1767. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1774. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1783. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1788. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1792. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1796. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1799. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1807. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1814. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1821. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1822. /* ReservationCtrlr Required item */
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1829. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1836. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1843. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1844. /* SampledDataCtrlr Required item */
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1850. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1851. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1857. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1858. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1865. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1869. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1871. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1872. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1874. else
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1876. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1878. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1884. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1888. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.maxLimit = 10;
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1892. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1896. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.maxLimit = 0;
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1899. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC,Current.Offered,Power.Offered");
  1901. else
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,Current.Offered");
  1903. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1908. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 10;
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
  1912. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1913. /* SecurityCtrlr Required item */
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1917. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]);
  1920. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword);
  1921. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1925. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1927. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1928. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  1929. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  1936. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1940. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.maxLimit = 1;
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1944. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
  1951. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1952. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1958. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1959. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
  1960. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1962. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.maxLimit = 10000;
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1964. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].value, "10000");
  1966. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize]);
  1967. /* SmartChargingCtrlr Required item */
  1968. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1974. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1981. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1988. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1992. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1995. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2000. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  2002. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2005. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  2009. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  2016. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2019. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2020. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2021. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  2023. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2028. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  2030. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2034. ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.maxLimit = 10;
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2036. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "10");
  2038. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2043. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2044. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  2045. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  2046. /* TariffCostCtrlr Required item */
  2047. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2048. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2051. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  2054. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  2062. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2065. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2066. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  2070. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  2078. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  2086. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2088. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2090. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  2094. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2098. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  2102. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  2103. /* TxCtrlr Required item */
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2110. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2118. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2125. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2132. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2139. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2146. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "0");
  2154. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2161. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2162. }
  2163. else
  2164. {
  2165. // Variable name init
  2166. /* AlignedDataCtrlr Required item */
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2183. /* AuthCtrlrVariable Required item */
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2198. /* AuthCacheCtrlr Variable Required item */
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2209. /* ClockCtrlr Variable Required item */
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2228. /* ChargingStation Required item */
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2235. /* Connector Required item */
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2242. /* CustomizationCtrlr Required item */
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  2245. /* DeviceDataCtrlr Required item */
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2268. /* DisplayMessageCtrlr Required item */
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2279. /* EVSE Required item */
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2288. /* LocalAuthListCtrlr Required item */
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2303. /* MonitoringCtrlr Required item */
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2322. /* OCPPCommCtrlr Required item */
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2354. /* ReservationCtrlr Required item */
  2355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2361. /* SampledDataCtrlr Required item */
  2362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2378. /* SecurityCtrlr Required item */
  2379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
  2392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
  2393. /* SmartChargingCtrlr Required item */
  2394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2416. /* TariffCostCtrlr Required item */
  2417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2435. /* TxCtrlr Required item */
  2436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2452. }
  2453. return 0;
  2454. }
  2455. void DB_variableIsCreate()
  2456. {
  2457. char sql[512];
  2458. char* errMsg = NULL;
  2459. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2460. /* Execute SQL statement */
  2461. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2462. {
  2463. DEBUG_INFO("SQL error: %s\n", errMsg);
  2464. }
  2465. }
  2466. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2467. {
  2468. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2469. {
  2470. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) == 0) &&
  2471. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) == 0) &&
  2472. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) == 0) &&
  2473. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) == 0))
  2474. {
  2475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2477. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2481. }
  2482. }
  2483. return 0;
  2484. }
  2485. void DB_variableLoadFromDb()
  2486. {
  2487. char sql[512];
  2488. char* errMsg = NULL;
  2489. sprintf(sql,"select * from ocpp20_variable order by idx;");
  2490. /* Execute SQL statement */
  2491. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2492. {
  2493. DEBUG_INFO("SQL error: %s\n", errMsg);
  2494. }
  2495. }
  2496. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2497. {
  2498. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2499. if(columnCount > 0)
  2500. {
  2501. for(int idx=0;idx<columnCount;idx++)
  2502. {
  2503. json_object *SetNetworkProfile;
  2504. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2505. if(!is_error(SetNetworkProfile))
  2506. {
  2507. // Required data
  2508. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2509. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2510. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2511. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2512. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2513. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2514. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2515. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2516. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2517. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2518. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2519. {
  2520. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2521. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2522. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2523. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2524. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2525. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2526. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2527. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2528. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2529. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2530. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2531. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2532. }
  2533. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2534. {
  2535. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2536. {
  2537. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2538. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2539. }
  2540. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2541. {
  2542. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2543. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2544. }
  2545. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2546. {
  2547. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2548. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2549. }
  2550. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2551. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2552. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2553. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2554. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2555. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2556. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2557. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2558. }
  2559. }
  2560. json_object_put(SetNetworkProfile);
  2561. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2562. }
  2563. }
  2564. return 0;
  2565. }
  2566. void DB_getNetworkProfileFromDb()
  2567. {
  2568. char sql[512];
  2569. char* errMsg = NULL;
  2570. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2571. /* Execute SQL statement */
  2572. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2573. {
  2574. DEBUG_INFO("SQL error: %s\n", errMsg);
  2575. }
  2576. }
  2577. int DB_addNetworkProfile(int slot, char *data)
  2578. {
  2579. int result = PASS;
  2580. char sql[512];
  2581. char* errMsg = NULL;
  2582. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2583. slot,
  2584. data);
  2585. //* Execute SQL statement */
  2586. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2587. {
  2588. DEBUG_INFO("SQL error: %s\n", errMsg);
  2589. result = FAIL;
  2590. }
  2591. return result;
  2592. }
  2593. int DB_deleteNetworkProfile(int slot)
  2594. {
  2595. int result = PASS;
  2596. char sql[512];
  2597. char* errMsg = NULL;
  2598. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2599. //* Execute SQL statement */
  2600. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2601. {
  2602. DEBUG_INFO("SQL error: %s", errMsg);
  2603. result = FAIL;
  2604. }
  2605. return result;
  2606. }
  2607. int getCurrentYear()
  2608. {
  2609. int result = 0;
  2610. time_t CurrentTime;
  2611. struct tm *tm;
  2612. CurrentTime = time(NULL);
  2613. tm=localtime(&CurrentTime);
  2614. result = (tm->tm_year + 1900);
  2615. return result;
  2616. }
  2617. int OCPP_insert_transaction_msg(uint8_t isStartTransaction, char *transactionMsg)
  2618. {
  2619. int result = PASS;
  2620. char* errMsg = NULL;
  2621. char sqlStr[8192];
  2622. sprintf(sqlStr, "insert into ocpp20_transaction_record(occurDatetime, message_type, message_content) values(CURRENT_TIMESTAMP, '%s', '%s');", (isStartTransaction?"startTransaction":"stopTransaction"), transactionMsg);
  2623. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2624. {
  2625. result = FAIL;
  2626. DEBUG_INFO( "Insert local transaction record error message: %s\n", errMsg);
  2627. }
  2628. 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));
  2629. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2630. {
  2631. result = FAIL;
  2632. DEBUG_INFO( "delete local transaction record error message: %s\n", errMsg);
  2633. }
  2634. return result;
  2635. }
  2636. //==========================================
  2637. // Check time passed since today
  2638. //==========================================
  2639. long long DiffTimebWithNow(struct timeb ST)
  2640. {
  2641. //return milli-second
  2642. struct timeb ET;
  2643. long long StartTime,StopTime;
  2644. ftime(&ET);
  2645. StartTime=(long long)ST.time;
  2646. StopTime=(long long)ET.time;
  2647. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2648. }
  2649. int getTimePassSinceToday(uint8_t gun_index)
  2650. {
  2651. int result = -1;
  2652. static time_t lastTime[4];
  2653. time_t t;
  2654. struct tm *tmStartToday;
  2655. struct timeb tbStartToday;
  2656. t=time(NULL);
  2657. if(difftime(t, lastTime[gun_index])>0)
  2658. {
  2659. tmStartToday=localtime(&t);
  2660. tmStartToday->tm_hour = 0;
  2661. tmStartToday->tm_min = 0;
  2662. tmStartToday->tm_sec = 0;
  2663. tbStartToday.time = mktime(tmStartToday);
  2664. tbStartToday.millitm = 0;
  2665. result = DiffTimebWithNow(tbStartToday)/1000;
  2666. lastTime[gun_index] = t;
  2667. }
  2668. return result;
  2669. }
  2670. int syncDateTimeRTC(uint8_t *data)
  2671. {
  2672. struct ParsingResult
  2673. {
  2674. int result;
  2675. int scanedElement;
  2676. int year;
  2677. int month;
  2678. int mday;
  2679. int hour;
  2680. int min;
  2681. int sec;
  2682. int tz_hour;
  2683. int tz_min;
  2684. float minSec;
  2685. }result;
  2686. struct tm tmOrg;
  2687. struct tm *tmTarget;
  2688. struct timeb tbTarget;
  2689. char buf[128];
  2690. memset(&result, 0x00, sizeof(struct ParsingResult));
  2691. result.result = PASS;
  2692. if(strstr((char*)data, ".") != NULL)
  2693. {
  2694. // Original data with mini second
  2695. if(strstr((char*)data, "Z") != NULL)
  2696. {
  2697. // Original data with Z
  2698. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%fZ",
  2699. &result.year,
  2700. &result.month,
  2701. &result.mday,
  2702. &result.hour,
  2703. &result.min,
  2704. &result.sec,
  2705. &result.minSec);
  2706. }
  2707. else
  2708. {
  2709. // Original data without Z
  2710. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  2711. &result.year,
  2712. &result.month,
  2713. &result.mday,
  2714. &result.hour,
  2715. &result.min,
  2716. &result.sec,
  2717. &result.minSec,
  2718. &result.tz_hour,
  2719. &result.tz_min);
  2720. }
  2721. }
  2722. else
  2723. {
  2724. // Original data without mini second
  2725. if(strstr((char*)data, "Z") != NULL)
  2726. {
  2727. // Original data with Z
  2728. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%dZ",
  2729. &result.year,
  2730. &result.month,
  2731. &result.mday,
  2732. &result.hour,
  2733. &result.min,
  2734. &result.sec);
  2735. }
  2736. else
  2737. {
  2738. // Original data without Z
  2739. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d%d:%d",
  2740. &result.year,
  2741. &result.month,
  2742. &result.mday,
  2743. &result.hour,
  2744. &result.min,
  2745. &result.sec,
  2746. &result.tz_hour,
  2747. &result.tz_min);
  2748. }
  2749. }
  2750. tmOrg.tm_year = result.year - 1900;
  2751. tmOrg.tm_mon = result.month - 1;
  2752. tmOrg.tm_mday = result.mday;
  2753. tmOrg.tm_hour = result.hour;
  2754. tmOrg.tm_min = result.min;
  2755. tmOrg.tm_sec = result.sec;
  2756. tmOrg.tm_gmtoff = 0;
  2757. tbTarget.time = mktime(&tmOrg);
  2758. tbTarget.timezone = 0;
  2759. tbTarget.time -= (result.tz_hour*3600) + (result.tz_min*60*(result.tz_hour>=0?1:-1));
  2760. tmTarget = gmtime(&tbTarget.time);
  2761. 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);
  2762. //DEBUG_INFO(" org date time: %s\n", data);
  2763. //DEBUG_INFO("parse date time: %s\n", buf);
  2764. system(buf);
  2765. system("/sbin/hwclock -w --systohc");
  2766. if(result.scanedElement < 6)
  2767. result.result = FAIL;
  2768. return result.result;
  2769. }
  2770. //==========================================
  2771. // GetCompositeSchedule logic related function
  2772. //==========================================
  2773. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2774. {
  2775. //return milli-second
  2776. unsigned int StartTime,StopTime;
  2777. StartTime=(unsigned int)ST.time;
  2778. StopTime=(unsigned int)ET.time;
  2779. return (StopTime-StartTime);
  2780. }
  2781. int DiffTimebWithNowSec(struct timeb ST)
  2782. {
  2783. //return milli-second
  2784. struct timeb ET;
  2785. unsigned int StartTime,StopTime;
  2786. ftime(&ET);
  2787. StartTime=(unsigned int)ST.time;
  2788. StopTime=(unsigned int)ET.time;
  2789. return (StopTime-StartTime);
  2790. }
  2791. int getStartStop(uint8_t *start, uint8_t *stop)
  2792. {
  2793. int result = -1;
  2794. struct tm tmStart;
  2795. struct timeb tbStart;
  2796. struct tm tmStop;
  2797. struct timeb tbStop;
  2798. 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) &&
  2799. (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))
  2800. {
  2801. //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);
  2802. //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);
  2803. tmStart.tm_year -= 1900;
  2804. tmStart.tm_mon -= 1;
  2805. tbStart.time = mktime(&tmStart);
  2806. tbStart.millitm = 0;
  2807. tmStop.tm_year -= 1900;
  2808. tmStop.tm_mon -= 1;
  2809. tbStop.time = mktime(&tmStop);
  2810. tbStop.millitm = 0;
  2811. result = DiffTimebSec(tbStart, tbStop);
  2812. //DEBUG_INFO("getStartStop(): %d\n", result);
  2813. }
  2814. else
  2815. {
  2816. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2817. }
  2818. return result;
  2819. }
  2820. int isOvertNow(uint8_t *start)
  2821. {
  2822. int result = NO;
  2823. struct ParsingResult
  2824. {
  2825. int result;
  2826. int scanedElement;
  2827. int year;
  2828. int month;
  2829. int mday;
  2830. int hour;
  2831. int min;
  2832. int sec;
  2833. int tz_hour;
  2834. int tz_min;
  2835. float minSec;
  2836. }parsingResult;
  2837. struct tm tmStart;
  2838. struct timeb tbStart;
  2839. if(strstr((char*)start, ".") != NULL)
  2840. {
  2841. // Original data with mini second
  2842. if(strstr((char*)start, "Z") != NULL)
  2843. {
  2844. // Original data with Z
  2845. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
  2846. &parsingResult.year,
  2847. &parsingResult.month,
  2848. &parsingResult.mday,
  2849. &parsingResult.hour,
  2850. &parsingResult.min,
  2851. &parsingResult.sec,
  2852. &parsingResult.minSec);
  2853. }
  2854. else
  2855. {
  2856. // Original data without Z
  2857. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  2858. &parsingResult.year,
  2859. &parsingResult.month,
  2860. &parsingResult.mday,
  2861. &parsingResult.hour,
  2862. &parsingResult.min,
  2863. &parsingResult.sec,
  2864. &parsingResult.minSec,
  2865. &parsingResult.tz_hour,
  2866. &parsingResult.tz_min);
  2867. }
  2868. }
  2869. else
  2870. {
  2871. // Original data without mini second
  2872. if(strstr((char*)start, "Z") != NULL)
  2873. {
  2874. // Original data with Z
  2875. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
  2876. &parsingResult.year,
  2877. &parsingResult.month,
  2878. &parsingResult.mday,
  2879. &parsingResult.hour,
  2880. &parsingResult.min,
  2881. &parsingResult.sec);
  2882. }
  2883. else
  2884. {
  2885. // Original data without Z
  2886. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
  2887. &parsingResult.year,
  2888. &parsingResult.month,
  2889. &parsingResult.mday,
  2890. &parsingResult.hour,
  2891. &parsingResult.min,
  2892. &parsingResult.sec,
  2893. &parsingResult.tz_hour,
  2894. &parsingResult.tz_min);
  2895. }
  2896. }
  2897. if(parsingResult.scanedElement >= 6)
  2898. {
  2899. tmStart.tm_year = parsingResult.year - 1900;
  2900. tmStart.tm_mon = parsingResult.month - 1;
  2901. tmStart.tm_mday = parsingResult.mday;
  2902. tmStart.tm_hour = parsingResult.hour;
  2903. tmStart.tm_min = parsingResult.min;
  2904. tmStart.tm_sec = parsingResult.sec;
  2905. tmStart.tm_gmtoff = 0;
  2906. tbStart.time = mktime(&tmStart);
  2907. tbStart.timezone = 0;
  2908. tbStart.millitm = 0;
  2909. tbStart.time -= (parsingResult.tz_hour*3600) + (parsingResult.tz_min*60*(parsingResult.tz_hour>=0?1:-1));
  2910. if(DiffTimebWithNowSec(tbStart) <= 0)
  2911. result = NO;
  2912. else
  2913. result = YES;
  2914. }
  2915. else
  2916. {
  2917. DEBUG_WARN("Start date parsing error.\n");
  2918. }
  2919. return result;
  2920. }
  2921. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2922. {
  2923. int result = -1;
  2924. struct tm tmStart;
  2925. struct timeb tbStart;
  2926. struct tm tmStop;
  2927. struct timeb tbStop;
  2928. 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) &&
  2929. (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))
  2930. {
  2931. tmStart.tm_year -= 1900;
  2932. tmStart.tm_mon -= 1;
  2933. tbStart.time = mktime(&tmStart);
  2934. tbStart.millitm = 0;
  2935. tmStop.tm_year -= 1900;
  2936. tmStop.tm_mon -= 1;
  2937. tbStop.time = mktime(&tmStop);
  2938. tbStop.millitm = 0;
  2939. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2940. }
  2941. return result;
  2942. }
  2943. void checkChargePointMaxProfile(uint32_t durationReq, struct ChargingProfileType *compositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  2944. {
  2945. FILE *fp;
  2946. char profileFileName[128];
  2947. char *line = NULL;
  2948. size_t len = 0;
  2949. time_t CurrentTime;
  2950. struct tm *tmComposite;
  2951. struct ChargingProfileType maxProfile;
  2952. uint8_t limitMax=0;
  2953. int compositePeriodIdx = 0;
  2954. CurrentTime = time(NULL);
  2955. tmComposite=localtime(&CurrentTime);
  2956. 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);
  2957. if(isUnitA)
  2958. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit, "A");
  2959. else
  2960. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit, "W");
  2961. compositeProfile->chargingSchedule[idxSchedule].duration = durationReq;
  2962. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  2963. {
  2964. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2965. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  2966. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2967. }
  2968. compositeProfile->id = 0;
  2969. compositeProfile->stackLevel = 99 ;
  2970. sprintf((char*)compositeProfile->chargingProfileKind ,"Absolute");
  2971. maxProfile.id = -1;
  2972. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  2973. system("rm -f /tmp/*.json");
  2974. system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
  2975. // Search max profile
  2976. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  2977. if((access(profileFileName, F_OK))!=-1)
  2978. {
  2979. fp = fopen(profileFileName, "r");
  2980. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  2981. {
  2982. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2983. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  2984. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2985. }
  2986. maxProfile.id = -1;
  2987. maxProfile.stackLevel = -1;
  2988. while(getline(&line, &len, fp) != -1)
  2989. {
  2990. json_object *obj = NULL;
  2991. obj = json_tokener_parse(line);
  2992. if(is_error(obj))
  2993. {
  2994. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  2995. }
  2996. else
  2997. {
  2998. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  2999. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3000. )
  3001. {
  3002. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3003. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3004. )
  3005. {
  3006. struct tm tmFrom, tmTo;
  3007. struct timeb tbFrom, tbTo;
  3008. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
  3009. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
  3010. {
  3011. tmFrom.tm_year -= 1900;
  3012. tmFrom.tm_mon -= 1;
  3013. tbFrom.time = mktime(&tmFrom);
  3014. tmTo.tm_year -= 1900;
  3015. tmTo.tm_mon -= 1;
  3016. tbTo.time = mktime(&tmTo);
  3017. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3018. {
  3019. if(maxProfile.id == -1)
  3020. DEBUG_INFO("MaxProfile found.\n");
  3021. else
  3022. DEBUG_INFO("MaxProfile updated.\n");
  3023. // Required item
  3024. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3025. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3026. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3027. if(isUnitA)
  3028. {
  3029. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3030. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3031. {
  3032. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3033. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3034. 3:
  3035. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3036. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3037. }
  3038. }
  3039. else
  3040. {
  3041. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3042. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3043. {
  3044. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3045. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3046. 3:
  3047. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3048. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3049. }
  3050. }
  3051. // Optional item
  3052. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3053. {
  3054. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3055. }
  3056. else
  3057. {
  3058. sprintf((char*)maxProfile.validFrom, " ");
  3059. }
  3060. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3061. {
  3062. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3063. }
  3064. else
  3065. {
  3066. sprintf((char*)maxProfile.validTo, " ");
  3067. }
  3068. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3069. {
  3070. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3071. }
  3072. else
  3073. {
  3074. sprintf((char*)maxProfile.recurrencyKind, " ");
  3075. }
  3076. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3077. {
  3078. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3079. }
  3080. else
  3081. {
  3082. sprintf((char*)maxProfile.transactionId, " ");
  3083. }
  3084. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3085. {
  3086. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3087. }
  3088. else
  3089. {
  3090. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3091. }
  3092. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3093. {
  3094. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3095. }
  3096. else
  3097. {
  3098. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile->chargingSchedule[idxSchedule].startSchedule);
  3099. }
  3100. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3101. {
  3102. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3103. }
  3104. else
  3105. {
  3106. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3107. }
  3108. }
  3109. }
  3110. }
  3111. else
  3112. {
  3113. if(maxProfile.id == -1)
  3114. DEBUG_INFO("MaxProfile found.\n");
  3115. else
  3116. DEBUG_INFO("MaxProfile updated.\n");
  3117. // Required item
  3118. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3119. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3120. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3121. if(isUnitA)
  3122. {
  3123. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3124. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3125. {
  3126. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3127. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3128. 3:
  3129. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3130. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3131. }
  3132. }
  3133. else
  3134. {
  3135. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3136. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3137. {
  3138. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3139. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3140. 3:
  3141. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3142. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3143. }
  3144. }
  3145. // Optional item
  3146. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3147. {
  3148. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3149. }
  3150. else
  3151. {
  3152. sprintf((char*)maxProfile.validFrom, " ");
  3153. }
  3154. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3155. {
  3156. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3157. }
  3158. else
  3159. {
  3160. sprintf((char*)maxProfile.validTo, " ");
  3161. }
  3162. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3163. {
  3164. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3165. }
  3166. else
  3167. {
  3168. sprintf((char*)maxProfile.recurrencyKind, " ");
  3169. }
  3170. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3171. {
  3172. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3173. }
  3174. else
  3175. {
  3176. sprintf((char*)maxProfile.transactionId, " ");
  3177. }
  3178. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3179. {
  3180. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3181. }
  3182. else
  3183. {
  3184. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3185. }
  3186. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3187. {
  3188. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3189. }
  3190. else
  3191. {
  3192. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile->chargingSchedule[idxSchedule].startSchedule);
  3193. }
  3194. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3195. {
  3196. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3197. }
  3198. else
  3199. {
  3200. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3201. }
  3202. }
  3203. }
  3204. }
  3205. json_object_put(obj);
  3206. }
  3207. fclose(fp);
  3208. /*
  3209. if(maxProfile.ChargingProfileId !=-1)
  3210. {
  3211. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3212. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3213. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3214. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3215. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3216. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3217. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3218. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  3219. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3220. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3221. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3222. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3223. {
  3224. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3225. {
  3226. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3227. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3228. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3229. }
  3230. }
  3231. }
  3232. else
  3233. DEBUG_INFO("MaxProfile not found.\n");
  3234. DEBUG_INFO("------------------------------------\n");*/
  3235. }
  3236. if(maxProfile.id != -1)
  3237. {
  3238. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3239. {
  3240. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3241. {
  3242. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3243. 0:
  3244. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3245. }
  3246. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3247. {
  3248. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3249. {
  3250. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  3251. 0:
  3252. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  3253. if(idxPeriod > 0)
  3254. {
  3255. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3256. {
  3257. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3258. }
  3259. }
  3260. }
  3261. }
  3262. }
  3263. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3264. {
  3265. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3266. {
  3267. maxProfile.chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
  3268. }
  3269. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3270. {
  3271. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3272. {
  3273. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod;
  3274. if(idxPeriod > 0)
  3275. {
  3276. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3277. {
  3278. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3279. }
  3280. }
  3281. }
  3282. }
  3283. }
  3284. else
  3285. {
  3286. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3287. {
  3288. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3289. {
  3290. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3291. 0:
  3292. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3293. }
  3294. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3295. {
  3296. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3297. {
  3298. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3299. 0:
  3300. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3301. if(idxPeriod > 0)
  3302. {
  3303. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3304. {
  3305. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3306. }
  3307. }
  3308. }
  3309. }
  3310. }
  3311. else
  3312. {
  3313. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3314. {
  3315. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3316. 0:
  3317. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3318. }
  3319. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3320. {
  3321. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3322. {
  3323. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3324. 0:
  3325. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3326. if(idxPeriod > 0)
  3327. {
  3328. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3329. {
  3330. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3331. }
  3332. }
  3333. }
  3334. }
  3335. }
  3336. }
  3337. /*
  3338. DEBUG_INFO("MaxProfile after align.\n");
  3339. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3340. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3341. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3342. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3343. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3344. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3345. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3346. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3347. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3348. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3349. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3350. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3351. {
  3352. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3353. {
  3354. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3355. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3356. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3357. }
  3358. }
  3359. DEBUG_INFO("------------------------------------\n");*/
  3360. }
  3361. // Find each profile period quantity
  3362. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  3363. {
  3364. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  3365. limitMax = idx+1;
  3366. }
  3367. if(maxProfile.id != -1)
  3368. {
  3369. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3370. {
  3371. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3372. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3373. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  3374. {
  3375. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3376. {
  3377. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3378. compositePeriodIdx++;
  3379. }
  3380. else
  3381. {
  3382. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3383. }
  3384. }
  3385. }
  3386. }
  3387. DEBUG_INFO("ChargePointMaxProfile ready.\n");
  3388. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[idxSchedule].startSchedule);
  3389. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[idxSchedule].duration);
  3390. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit);
  3391. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3392. {
  3393. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  3394. {
  3395. compositeProfile->id = 1;
  3396. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  3397. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  3398. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  3399. }
  3400. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  3401. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  3402. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  3403. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  3404. }
  3405. if(line)
  3406. free(line);
  3407. }
  3408. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  3409. {
  3410. FILE *fp;
  3411. char profileFileName[128];
  3412. char *line = NULL;
  3413. size_t len = 0;
  3414. time_t CurrentTime;
  3415. struct tm *tmComposite;
  3416. struct ChargingProfileType maxProfile;
  3417. struct ChargingProfileType defaultTxProfile;
  3418. struct ChargingProfileType txProfile;
  3419. struct ChargingSchedulePeriodType tmpPeriod;
  3420. uint8_t limitMax=0;
  3421. uint8_t limitDef=0;
  3422. uint8_t limitTx=0;
  3423. int compositePeriodIdx = 0;
  3424. CurrentTime = time(NULL);
  3425. tmComposite=localtime(&CurrentTime);
  3426. 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);
  3427. if(isUnitA)
  3428. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3429. else
  3430. sprintf((char*)compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3431. compositeProfile->chargingSchedule[idxSchedule].duration = durationReq;
  3432. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3433. {
  3434. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3435. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3436. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3437. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  3438. }
  3439. compositeProfile->id = 0;
  3440. compositeProfile->stackLevel = 99 ;
  3441. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  3442. maxProfile.id = -1;
  3443. defaultTxProfile.id = -1;
  3444. txProfile.id = -1;
  3445. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  3446. defaultTxProfile.chargingSchedule[idxSchedule].duration = -1;
  3447. txProfile.chargingSchedule[idxSchedule].duration = -1;
  3448. system("rm -f /tmp/*.json");
  3449. system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
  3450. /*
  3451. * Search valid charging profile
  3452. */
  3453. //DEBUG_INFO("====================================\n");
  3454. // Search tx profile
  3455. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  3456. if((access(profileFileName, F_OK))!=-1)
  3457. {
  3458. fp = fopen(profileFileName, "r");
  3459. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3460. {
  3461. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3462. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3463. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3464. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3465. }
  3466. txProfile.id = -1;
  3467. txProfile.stackLevel = -1;
  3468. while(getline(&line, &len, fp) != -1)
  3469. {
  3470. json_object *obj = NULL;
  3471. obj = json_tokener_parse(line);
  3472. if(is_error(obj))
  3473. {
  3474. DEBUG_ERROR("Parse txProfile from file error.\n");
  3475. }
  3476. else
  3477. {
  3478. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  3479. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  3480. )
  3481. {
  3482. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3483. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3484. )
  3485. {
  3486. struct tm tmFrom, tmTo;
  3487. struct timeb tbFrom, tbTo;
  3488. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
  3489. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
  3490. {
  3491. tmFrom.tm_year -= 1900;
  3492. tmFrom.tm_mon -= 1;
  3493. tbFrom.time = mktime(&tmFrom);
  3494. tmTo.tm_year -= 1900;
  3495. tmTo.tm_mon -= 1;
  3496. tbTo.time = mktime(&tmTo);
  3497. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3498. {
  3499. if(txProfile.id == -1)
  3500. DEBUG_INFO("TxProfile found.\n");
  3501. else
  3502. DEBUG_INFO("TxProfile updated.\n");
  3503. // Required item
  3504. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3505. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3506. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3507. if(isUnitA)
  3508. {
  3509. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3510. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3511. {
  3512. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3513. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3514. 3:
  3515. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3516. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3517. }
  3518. }
  3519. else
  3520. {
  3521. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3522. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3523. {
  3524. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3525. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3526. 3:
  3527. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3528. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3529. }
  3530. }
  3531. // Optional item
  3532. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3533. {
  3534. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3535. }
  3536. else
  3537. {
  3538. sprintf((char*)txProfile.validFrom, " ");
  3539. }
  3540. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3541. {
  3542. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3543. }
  3544. else
  3545. {
  3546. sprintf((char*)txProfile.validTo, " ");
  3547. }
  3548. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3549. {
  3550. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3551. }
  3552. else
  3553. {
  3554. sprintf((char*)txProfile.recurrencyKind, " ");
  3555. }
  3556. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3557. {
  3558. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3559. }
  3560. else
  3561. {
  3562. sprintf((char*)txProfile.transactionId, " ");
  3563. }
  3564. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3565. {
  3566. txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3567. }
  3568. else
  3569. {
  3570. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  3571. }
  3572. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3573. {
  3574. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3575. }
  3576. else
  3577. {
  3578. 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));
  3579. }
  3580. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3581. {
  3582. txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3583. }
  3584. else
  3585. {
  3586. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3587. }
  3588. }
  3589. }
  3590. }
  3591. else
  3592. {
  3593. if(txProfile.id == -1)
  3594. DEBUG_INFO("TxProfile found.\n");
  3595. else
  3596. DEBUG_INFO("TxProfile updated.\n");
  3597. // Required item
  3598. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3599. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3600. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3601. if(isUnitA)
  3602. {
  3603. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3604. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3605. {
  3606. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3607. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3608. 3:
  3609. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3610. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3611. }
  3612. }
  3613. else
  3614. {
  3615. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3616. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3617. {
  3618. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3619. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3620. 3:
  3621. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3622. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3623. }
  3624. }
  3625. // Optional item
  3626. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3627. {
  3628. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3629. }
  3630. else
  3631. {
  3632. sprintf((char*)txProfile.validFrom, " ");
  3633. }
  3634. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3635. {
  3636. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3637. }
  3638. else
  3639. {
  3640. sprintf((char*)txProfile.validTo, " ");
  3641. }
  3642. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3643. {
  3644. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3645. }
  3646. else
  3647. {
  3648. sprintf((char*)txProfile.recurrencyKind, " ");
  3649. }
  3650. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3651. {
  3652. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3653. }
  3654. else
  3655. {
  3656. sprintf((char*)txProfile.transactionId, " ");
  3657. }
  3658. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3659. {
  3660. txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3661. }
  3662. else
  3663. {
  3664. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  3665. }
  3666. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3667. {
  3668. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3669. }
  3670. else
  3671. {
  3672. 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));
  3673. }
  3674. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3675. {
  3676. txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3677. }
  3678. else
  3679. {
  3680. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3681. }
  3682. }
  3683. }
  3684. }
  3685. json_object_put(obj);
  3686. }
  3687. fclose(fp);
  3688. /*
  3689. if(txProfile.ChargingProfileId != -1)
  3690. {
  3691. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3692. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3693. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3694. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3695. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3696. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3697. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3698. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[idxSchedule].StartSchedule);
  3699. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  3700. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3701. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3702. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3703. {
  3704. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3705. {
  3706. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3707. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3708. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3709. }
  3710. }
  3711. }
  3712. else
  3713. DEBUG_INFO("TxProfile not found.\n");*/
  3714. }
  3715. // Search default tx profile
  3716. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  3717. if((access(profileFileName, F_OK))==-1)
  3718. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  3719. if((access(profileFileName, F_OK))!=-1)
  3720. {
  3721. fp = fopen(profileFileName, "r");
  3722. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3723. {
  3724. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3725. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3726. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3727. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3728. }
  3729. defaultTxProfile.id = -1;
  3730. defaultTxProfile.stackLevel = -1;
  3731. while(getline(&line, &len, fp) != -1)
  3732. {
  3733. json_object *obj = NULL;
  3734. obj = json_tokener_parse(line);
  3735. if(is_error(obj))
  3736. {
  3737. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  3738. }
  3739. else
  3740. {
  3741. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  3742. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  3743. )
  3744. {
  3745. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3746. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3747. )
  3748. {
  3749. struct tm tmFrom, tmTo;
  3750. struct timeb tbFrom, tbTo;
  3751. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
  3752. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
  3753. {
  3754. tmFrom.tm_year -= 1900;
  3755. tmFrom.tm_mon -= 1;
  3756. tbFrom.time = mktime(&tmFrom);
  3757. tmTo.tm_year -= 1900;
  3758. tmTo.tm_mon -= 1;
  3759. tbTo.time = mktime(&tmTo);
  3760. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3761. {
  3762. if(defaultTxProfile.id == -1)
  3763. DEBUG_INFO("TxDefaultProfile found.\n");
  3764. else
  3765. DEBUG_INFO("TxDefaultProfile updated.\n");
  3766. // Required item
  3767. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3768. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3769. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3770. if(isUnitA)
  3771. {
  3772. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3773. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3774. {
  3775. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3776. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3777. 3:
  3778. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3779. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3780. }
  3781. }
  3782. else
  3783. {
  3784. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3785. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3786. {
  3787. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3788. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3789. 3:
  3790. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3791. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3792. }
  3793. }
  3794. // Optional item
  3795. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3796. {
  3797. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3798. }
  3799. else
  3800. {
  3801. sprintf((char*)defaultTxProfile.validFrom, " ");
  3802. }
  3803. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3804. {
  3805. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3806. }
  3807. else
  3808. {
  3809. sprintf((char*)defaultTxProfile.validTo, " ");
  3810. }
  3811. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3812. {
  3813. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3814. }
  3815. else
  3816. {
  3817. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3818. }
  3819. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3820. {
  3821. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3822. }
  3823. else
  3824. {
  3825. sprintf((char*)defaultTxProfile.transactionId, " ");
  3826. }
  3827. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3828. {
  3829. defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3830. }
  3831. else
  3832. {
  3833. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3834. }
  3835. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3836. {
  3837. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3838. }
  3839. else
  3840. {
  3841. 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));
  3842. }
  3843. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3844. {
  3845. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3846. }
  3847. else
  3848. {
  3849. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3850. }
  3851. }
  3852. }
  3853. }
  3854. else
  3855. {
  3856. if(defaultTxProfile.id == -1)
  3857. DEBUG_INFO("TxDefaultProfile found.\n");
  3858. else
  3859. DEBUG_INFO("TxDefaultProfile updated.\n");
  3860. // Required item
  3861. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3862. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3863. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3864. if(isUnitA)
  3865. {
  3866. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3867. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3868. {
  3869. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3870. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3871. 3:
  3872. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3873. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3874. }
  3875. }
  3876. else
  3877. {
  3878. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3879. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3880. {
  3881. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3882. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3883. 3:
  3884. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3885. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3886. }
  3887. }
  3888. // Optional item
  3889. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3890. {
  3891. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3892. }
  3893. else
  3894. {
  3895. sprintf((char*)defaultTxProfile.validFrom, " ");
  3896. }
  3897. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3898. {
  3899. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3900. }
  3901. else
  3902. {
  3903. sprintf((char*)defaultTxProfile.validTo, " ");
  3904. }
  3905. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3906. {
  3907. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3908. }
  3909. else
  3910. {
  3911. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3912. }
  3913. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3914. {
  3915. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3916. }
  3917. else
  3918. {
  3919. sprintf((char*)defaultTxProfile.transactionId, " ");
  3920. }
  3921. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3922. {
  3923. defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3924. }
  3925. else
  3926. {
  3927. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3928. }
  3929. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3930. {
  3931. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3932. }
  3933. else
  3934. {
  3935. 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));
  3936. }
  3937. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3938. {
  3939. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3940. }
  3941. else
  3942. {
  3943. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3944. }
  3945. }
  3946. }
  3947. }
  3948. json_object_put(obj);
  3949. }
  3950. fclose(fp);
  3951. /*
  3952. if(defaultTxProfile.ChargingProfileId != -1)
  3953. {
  3954. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3955. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3956. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3957. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3958. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3959. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3960. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3961. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].StartSchedule);
  3962. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  3963. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3964. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3965. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3966. {
  3967. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3968. {
  3969. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3970. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3971. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3972. }
  3973. }
  3974. }
  3975. else
  3976. DEBUG_INFO("TxDefaultProfile not found.\n");
  3977. DEBUG_INFO("------------------------------------\n");*/
  3978. }
  3979. // Search max profile
  3980. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  3981. if((access(profileFileName, F_OK))!=-1)
  3982. {
  3983. fp = fopen(profileFileName, "r");
  3984. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3985. {
  3986. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3987. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3988. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3989. }
  3990. maxProfile.id = -1;
  3991. maxProfile.stackLevel = -1;
  3992. while(getline(&line, &len, fp) != -1)
  3993. {
  3994. json_object *obj = NULL;
  3995. obj = json_tokener_parse(line);
  3996. if(is_error(obj))
  3997. {
  3998. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3999. }
  4000. else
  4001. {
  4002. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  4003. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  4004. )
  4005. {
  4006. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  4007. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  4008. )
  4009. {
  4010. struct tm tmFrom, tmTo;
  4011. struct timeb tbFrom, tbTo;
  4012. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
  4013. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
  4014. {
  4015. tmFrom.tm_year -= 1900;
  4016. tmFrom.tm_mon -= 1;
  4017. tbFrom.time = mktime(&tmFrom);
  4018. tmTo.tm_year -= 1900;
  4019. tmTo.tm_mon -= 1;
  4020. tbTo.time = mktime(&tmTo);
  4021. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  4022. {
  4023. if(maxProfile.id == -1)
  4024. DEBUG_INFO("MaxProfile found.\n");
  4025. else
  4026. DEBUG_INFO("MaxProfile updated.\n");
  4027. // Required item
  4028. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  4029. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  4030. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  4031. if(isUnitA)
  4032. {
  4033. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4034. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  4035. {
  4036. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4037. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4038. 3:
  4039. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4040. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  4041. }
  4042. }
  4043. else
  4044. {
  4045. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4046. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  4047. {
  4048. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4049. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4050. 3:
  4051. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4052. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  4053. }
  4054. }
  4055. // Optional item
  4056. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  4057. {
  4058. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  4059. }
  4060. else
  4061. {
  4062. sprintf((char*)maxProfile.validFrom, " ");
  4063. }
  4064. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  4065. {
  4066. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  4067. }
  4068. else
  4069. {
  4070. sprintf((char*)maxProfile.validTo, " ");
  4071. }
  4072. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  4073. {
  4074. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  4075. }
  4076. else
  4077. {
  4078. sprintf((char*)maxProfile.recurrencyKind, " ");
  4079. }
  4080. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  4081. {
  4082. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  4083. }
  4084. else
  4085. {
  4086. sprintf((char*)maxProfile.transactionId, " ");
  4087. }
  4088. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  4089. {
  4090. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  4091. }
  4092. else
  4093. {
  4094. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4095. }
  4096. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  4097. {
  4098. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  4099. }
  4100. else
  4101. {
  4102. 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));
  4103. }
  4104. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  4105. {
  4106. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  4107. }
  4108. else
  4109. {
  4110. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4111. }
  4112. }
  4113. }
  4114. }
  4115. else
  4116. {
  4117. if(maxProfile.id == -1)
  4118. DEBUG_INFO("MaxProfile found.\n");
  4119. else
  4120. DEBUG_INFO("MaxProfile updated.\n");
  4121. // Required item
  4122. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  4123. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  4124. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  4125. if(isUnitA)
  4126. {
  4127. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4128. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  4129. {
  4130. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4131. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4132. 3:
  4133. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4134. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  4135. }
  4136. }
  4137. else
  4138. {
  4139. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4140. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  4141. {
  4142. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4143. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4144. 3:
  4145. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4146. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  4147. }
  4148. }
  4149. // Optional item
  4150. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  4151. {
  4152. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  4153. }
  4154. else
  4155. {
  4156. sprintf((char*)maxProfile.validFrom, " ");
  4157. }
  4158. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  4159. {
  4160. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  4161. }
  4162. else
  4163. {
  4164. sprintf((char*)maxProfile.validTo, " ");
  4165. }
  4166. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  4167. {
  4168. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  4169. }
  4170. else
  4171. {
  4172. sprintf((char*)maxProfile.recurrencyKind, " ");
  4173. }
  4174. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  4175. {
  4176. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  4177. }
  4178. else
  4179. {
  4180. sprintf((char*)maxProfile.transactionId, " ");
  4181. }
  4182. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  4183. {
  4184. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  4185. }
  4186. else
  4187. {
  4188. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4189. }
  4190. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  4191. {
  4192. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  4193. }
  4194. else
  4195. {
  4196. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile->chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  4197. }
  4198. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  4199. {
  4200. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  4201. }
  4202. else
  4203. {
  4204. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4205. }
  4206. }
  4207. }
  4208. }
  4209. json_object_put(obj);
  4210. }
  4211. fclose(fp);
  4212. /*
  4213. if(maxProfile.ChargingProfileId !=-1)
  4214. {
  4215. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  4216. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  4217. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  4218. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  4219. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  4220. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  4221. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  4222. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  4223. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  4224. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4225. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4226. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4227. {
  4228. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4229. {
  4230. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4231. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4232. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4233. }
  4234. }
  4235. }
  4236. else
  4237. DEBUG_INFO("MaxProfile not found.\n");
  4238. DEBUG_INFO("------------------------------------\n");*/
  4239. }
  4240. /*
  4241. * Align found profile start schedule & periods
  4242. */
  4243. //DEBUG_INFO("====================================\n");
  4244. /*
  4245. // For local test usage, force modify found profile start schedule info
  4246. 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);
  4247. 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);
  4248. 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);
  4249. */
  4250. if(txProfile.id != -1)
  4251. {
  4252. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4253. {
  4254. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4255. {
  4256. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4257. 0:
  4258. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4259. }
  4260. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4261. {
  4262. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4263. {
  4264. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4265. 0:
  4266. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4267. if(idxPeriod > 0)
  4268. {
  4269. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4270. {
  4271. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4272. }
  4273. }
  4274. }
  4275. }
  4276. }
  4277. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4278. {
  4279. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4280. {
  4281. 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?
  4282. 0:
  4283. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4284. }
  4285. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4286. {
  4287. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4288. {
  4289. 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?
  4290. 0:
  4291. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4292. if(idxPeriod > 0)
  4293. {
  4294. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4295. {
  4296. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4297. }
  4298. }
  4299. }
  4300. }
  4301. }
  4302. else
  4303. {
  4304. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4305. {
  4306. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4307. {
  4308. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4309. 0:
  4310. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4311. }
  4312. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4313. {
  4314. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4315. {
  4316. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4317. 0:
  4318. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4319. if(idxPeriod > 0)
  4320. {
  4321. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4322. {
  4323. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4324. }
  4325. }
  4326. }
  4327. }
  4328. }
  4329. else
  4330. {
  4331. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4332. {
  4333. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4334. 0:
  4335. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4336. }
  4337. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4338. {
  4339. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4340. {
  4341. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4342. 0:
  4343. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4344. if(idxPeriod > 0)
  4345. {
  4346. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4347. {
  4348. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4349. }
  4350. }
  4351. }
  4352. }
  4353. }
  4354. }
  4355. /*
  4356. DEBUG_INFO("txProfile after align.\n");
  4357. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  4358. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  4359. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  4360. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  4361. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  4362. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  4363. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  4364. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  4365. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  4366. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4367. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4368. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4369. {
  4370. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4371. {
  4372. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4373. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4374. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4375. }
  4376. }*/
  4377. }
  4378. if(defaultTxProfile.id != -1)
  4379. {
  4380. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4381. {
  4382. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4383. {
  4384. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4385. 0:
  4386. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4387. }
  4388. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4389. {
  4390. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4391. {
  4392. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4393. 0:
  4394. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4395. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4396. {
  4397. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4398. }
  4399. if(idxPeriod > 0)
  4400. {
  4401. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4402. {
  4403. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4404. }
  4405. }
  4406. }
  4407. }
  4408. }
  4409. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4410. {
  4411. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4412. {
  4413. 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?
  4414. 0:
  4415. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4416. }
  4417. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4418. {
  4419. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4420. {
  4421. 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?
  4422. 0:
  4423. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4424. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4425. {
  4426. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4427. }
  4428. if(idxPeriod > 0)
  4429. {
  4430. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4431. {
  4432. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4433. }
  4434. }
  4435. }
  4436. }
  4437. }
  4438. else
  4439. {
  4440. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4441. {
  4442. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4443. {
  4444. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4445. 0:
  4446. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4447. }
  4448. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4449. {
  4450. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4451. {
  4452. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4453. 0:
  4454. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4455. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4456. {
  4457. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4458. }
  4459. if(idxPeriod > 0)
  4460. {
  4461. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4462. {
  4463. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4464. }
  4465. }
  4466. }
  4467. }
  4468. }
  4469. else
  4470. {
  4471. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4472. {
  4473. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4474. 0:
  4475. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4476. }
  4477. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4478. {
  4479. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4480. {
  4481. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4482. 0:
  4483. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4484. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[idxSchedule].duration)
  4485. {
  4486. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4487. }
  4488. if(idxPeriod > 0)
  4489. {
  4490. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4491. {
  4492. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4493. }
  4494. }
  4495. }
  4496. }
  4497. }
  4498. }
  4499. /*
  4500. DEBUG_INFO("defaultTxProfile after align.\n");
  4501. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  4502. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  4503. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  4504. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  4505. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  4506. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  4507. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  4508. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  4509. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  4510. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4511. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4512. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4513. {
  4514. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4515. {
  4516. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4517. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4518. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4519. }
  4520. }
  4521. DEBUG_INFO("------------------------------------\n");*/
  4522. }
  4523. if(maxProfile.id != -1)
  4524. {
  4525. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4526. {
  4527. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4528. {
  4529. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4530. 0:
  4531. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4532. }
  4533. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4534. {
  4535. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4536. {
  4537. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule))<0?
  4538. 0:
  4539. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4540. if(idxPeriod > 0)
  4541. {
  4542. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4543. {
  4544. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4545. }
  4546. }
  4547. }
  4548. }
  4549. }
  4550. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4551. {
  4552. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4553. {
  4554. 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?
  4555. 0:
  4556. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  4557. }
  4558. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4559. {
  4560. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4561. {
  4562. 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?
  4563. 0:
  4564. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[idxSchedule].startSchedule)));
  4565. if(idxPeriod > 0)
  4566. {
  4567. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4568. {
  4569. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4570. }
  4571. }
  4572. }
  4573. }
  4574. }
  4575. else
  4576. {
  4577. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4578. {
  4579. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4580. {
  4581. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4582. 0:
  4583. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4584. }
  4585. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4586. {
  4587. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4588. {
  4589. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4590. 0:
  4591. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4592. if(idxPeriod > 0)
  4593. {
  4594. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4595. {
  4596. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4597. }
  4598. }
  4599. }
  4600. }
  4601. }
  4602. else
  4603. {
  4604. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  4605. {
  4606. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4607. 0:
  4608. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4609. }
  4610. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4611. {
  4612. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4613. {
  4614. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4615. 0:
  4616. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile->chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4617. if(idxPeriod > 0)
  4618. {
  4619. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4620. {
  4621. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4622. }
  4623. }
  4624. }
  4625. }
  4626. }
  4627. }
  4628. /*
  4629. DEBUG_INFO("MaxProfile after align.\n");
  4630. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  4631. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  4632. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  4633. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  4634. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  4635. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  4636. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  4637. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  4638. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  4639. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4640. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4641. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4642. {
  4643. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4644. {
  4645. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4646. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4647. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4648. }
  4649. }
  4650. DEBUG_INFO("------------------------------------\n");*/
  4651. }
  4652. /*
  4653. * Merge to conposite schedule
  4654. */
  4655. //DEBUG_INFO("====================================\n");
  4656. // Find each profile period quantity
  4657. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4658. {
  4659. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4660. limitMax = idx+1;
  4661. }
  4662. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4663. {
  4664. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4665. limitDef = idx+1;
  4666. }
  4667. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  4668. {
  4669. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  4670. limitTx = idx+1;
  4671. }
  4672. // TxProfile found, composite schedule based on it
  4673. if(txProfile.id != -1)
  4674. {
  4675. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  4676. {
  4677. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  4678. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  4679. (txProfile.chargingSchedule[idxSchedule].duration > 0))
  4680. {
  4681. if(maxProfile.id != -1)
  4682. {
  4683. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4684. {
  4685. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  4686. {
  4687. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4688. {
  4689. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  4690. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  4691. 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);
  4692. }
  4693. else
  4694. {
  4695. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  4696. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  4697. tmpPeriod.limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit;
  4698. }
  4699. }
  4700. if(idxMaxPeriod == (limitMax-1))
  4701. {
  4702. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4703. {
  4704. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4705. {
  4706. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4707. compositePeriodIdx++;
  4708. }
  4709. else
  4710. {
  4711. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4712. }
  4713. }
  4714. }
  4715. }
  4716. }
  4717. else
  4718. {
  4719. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4720. {
  4721. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  4722. compositePeriodIdx++;
  4723. }
  4724. else
  4725. {
  4726. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  4727. }
  4728. }
  4729. }
  4730. if(idxTxPeriod == (limitTx-1))
  4731. {
  4732. if(defaultTxProfile.id != -1)
  4733. {
  4734. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  4735. {
  4736. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  4737. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  4738. (defaultTxProfile.chargingSchedule[idxSchedule].duration>0))
  4739. {
  4740. if(maxProfile.id != -1)
  4741. {
  4742. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4743. {
  4744. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  4745. {
  4746. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4747. {
  4748. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4749. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4750. 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);
  4751. }
  4752. else
  4753. {
  4754. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4755. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4756. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  4757. }
  4758. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4759. {
  4760. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4761. {
  4762. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4763. compositePeriodIdx++;
  4764. }
  4765. else
  4766. {
  4767. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4768. }
  4769. }
  4770. // Delete duplicate period
  4771. if(compositePeriodIdx > 1)
  4772. {
  4773. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  4774. {
  4775. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  4776. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  4777. compositePeriodIdx -= 1;
  4778. }
  4779. }
  4780. }
  4781. else
  4782. break;
  4783. }
  4784. }
  4785. else
  4786. {
  4787. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4788. {
  4789. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4790. compositePeriodIdx++;
  4791. }
  4792. else
  4793. {
  4794. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4795. }
  4796. }
  4797. }
  4798. }
  4799. }
  4800. }
  4801. }
  4802. }
  4803. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  4804. else if(defaultTxProfile.id != -1)
  4805. {
  4806. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  4807. {
  4808. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  4809. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  4810. (defaultTxProfile.chargingSchedule[idxSchedule].duration > 0))
  4811. {
  4812. if(maxProfile.id != -1)
  4813. {
  4814. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4815. {
  4816. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  4817. {
  4818. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4819. {
  4820. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4821. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4822. 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);
  4823. }
  4824. else
  4825. {
  4826. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  4827. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  4828. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  4829. }
  4830. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4831. {
  4832. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4833. {
  4834. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4835. compositePeriodIdx++;
  4836. }
  4837. else
  4838. {
  4839. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4840. }
  4841. }
  4842. // Delete duplicate period
  4843. if(compositePeriodIdx > 1)
  4844. {
  4845. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  4846. {
  4847. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  4848. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  4849. compositePeriodIdx -= 1;
  4850. }
  4851. }
  4852. }
  4853. else
  4854. break;
  4855. }
  4856. }
  4857. else
  4858. {
  4859. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4860. {
  4861. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4862. compositePeriodIdx++;
  4863. }
  4864. else
  4865. {
  4866. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  4867. }
  4868. }
  4869. }
  4870. }
  4871. }
  4872. // Fill other period by MaxProfile
  4873. if(maxProfile.id != -1)
  4874. {
  4875. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  4876. {
  4877. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  4878. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  4879. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  4880. {
  4881. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  4882. (maxProfile.chargingSchedule[idxSchedule].duration > compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  4883. {
  4884. tmpPeriod.startPeriod = (compositePeriodIdx==0)?0:compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  4885. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  4886. tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
  4887. }
  4888. if((compositePeriodIdx > 0) && (maxProfile.chargingSchedule[idxSchedule].duration > compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  4889. {
  4890. tmpPeriod.startPeriod = (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod>compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod)?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod:compositeProfile->chargingSchedule[idxSchedule].duration;
  4891. tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  4892. tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
  4893. }
  4894. if(tmpPeriod.limit != -1)
  4895. {
  4896. if(tmpPeriod.limit != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  4897. {
  4898. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  4899. {
  4900. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4901. compositePeriodIdx++;
  4902. }
  4903. else
  4904. {
  4905. memcpy(&compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4906. }
  4907. }
  4908. // Delete duplicate period
  4909. if(compositePeriodIdx > 1)
  4910. {
  4911. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  4912. {
  4913. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  4914. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  4915. compositePeriodIdx -= 1;
  4916. }
  4917. }
  4918. }
  4919. }
  4920. }
  4921. }
  4922. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  4923. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[idxSchedule].startSchedule);
  4924. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[idxSchedule].duration);
  4925. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[idxSchedule].chargingRateUnit);
  4926. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4927. {
  4928. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  4929. {
  4930. compositeProfile->id = 1;
  4931. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  4932. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  4933. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  4934. }
  4935. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  4936. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  4937. if(compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  4938. compositeProfile->chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  4939. }
  4940. if(line)
  4941. free(line);
  4942. checkChargePointMaxProfile(durationReq, &ShmOCPP20Data->MaxChargingProfile, idxSchedule, isUnitA);
  4943. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  4944. }
  4945. //==========================================
  4946. // Init all share memory
  4947. //==========================================
  4948. int InitShareMemory()
  4949. {
  4950. int result = PASS;
  4951. int MeterSMId;
  4952. //creat ShmSysConfigAndInfo
  4953. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  4954. {
  4955. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  4956. result = FAIL;
  4957. }
  4958. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4959. {
  4960. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  4961. result = FAIL;
  4962. }
  4963. else
  4964. {}
  4965. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  4966. {
  4967. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  4968. result = FAIL;
  4969. }
  4970. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4971. {
  4972. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  4973. result = FAIL;
  4974. }
  4975. else
  4976. {}
  4977. //creat ShmPsuData
  4978. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  4979. {
  4980. DEBUG_ERROR("shmget ShmPsuData NG\n");
  4981. result = FAIL;
  4982. }
  4983. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4984. {
  4985. DEBUG_ERROR("shmat ShmPsuData NG\n");
  4986. result = FAIL;
  4987. }
  4988. else
  4989. {}
  4990. //creat ShmOCPP20Data
  4991. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  4992. {
  4993. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  4994. result = FAIL;
  4995. }
  4996. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4997. {
  4998. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  4999. result = FAIL;
  5000. }
  5001. else
  5002. {}
  5003. /****************************** For Initial Settings************************************************/
  5004. /*
  5005. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  5006. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  5007. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  5008. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  5009. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  5010. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  5011. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  5012. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  5013. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  5014. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  5015. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  5016. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  5017. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  5018. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  5019. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  5020. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  5021. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  5022. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  5023. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  5024. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  5025. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  5026. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  5027. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  5028. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  5029. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  5030. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  5031. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  5032. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  5033. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  5034. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  5035. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  5036. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  5037. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  5038. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  5039. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  5040. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  5041. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  5042. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  5043. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  5044. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  5045. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  5046. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  5047. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  5048. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  5049. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  5050. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  5051. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  5052. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  5053. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  5054. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  5055. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  5056. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  5057. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  5058. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  5059. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  5060. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  5061. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  5062. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  5063. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  5064. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  5065. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  5066. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  5067. */
  5068. return result;
  5069. }
  5070. int ProcessShareMemory()
  5071. {
  5072. if(InitShareMemory() == FAIL)
  5073. {
  5074. DEBUG_ERROR("InitShareMemory NG\n");
  5075. if(ShmStatusCodeData!=NULL)
  5076. {
  5077. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  5078. }
  5079. sleep(5);
  5080. return FAIL;
  5081. }
  5082. return PASS;
  5083. }
  5084. //---------------------common routine---------------------------//
  5085. void checkNetworkProfile(void)
  5086. {
  5087. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  5088. json_object *priority;
  5089. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  5090. if(!is_error(priority))
  5091. {
  5092. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  5093. {
  5094. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  5095. {
  5096. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  5097. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  5098. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  5099. {
  5100. memcpy(ShmOCPP20Data->OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  5101. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  5102. break;
  5103. }
  5104. }
  5105. }
  5106. }
  5107. json_object_put(priority);
  5108. DEBUG_INFO("Get network profile URL: %s\n", ShmOCPP20Data->OcppServerURL);
  5109. }
  5110. void CheckSystemValue(void)
  5111. {
  5112. char filenmae[100]={0};
  5113. char str[100]={0};
  5114. int tempIndex = 0;
  5115. //===============================
  5116. // EVSE operation check
  5117. //===============================
  5118. //===============================
  5119. // Heartbeat check
  5120. //===============================
  5121. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  5122. {
  5123. clientTime.Heartbeat = time((time_t*)NULL);
  5124. if(server_sign == TRUE)
  5125. {
  5126. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  5127. }
  5128. else
  5129. {
  5130. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  5131. }
  5132. }
  5133. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  5134. {
  5135. //parameter for test
  5136. sendHeartbeatRequest(0);
  5137. //==============================================
  5138. // Reset Waiting Time
  5139. //==============================================
  5140. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  5141. }
  5142. //===============================
  5143. // CSU Trigger Authorize Request
  5144. //===============================
  5145. if(isWebsocketSendable &&
  5146. (server_sign == TRUE) &&
  5147. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  5148. (authorizeRetryTimes < 3))
  5149. {
  5150. sendAuthorizeRequest(0);
  5151. authorizeRetryTimes = authorizeRetryTimes + 1;
  5152. if(authorizeRetryTimes < 3)
  5153. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5154. }
  5155. else if((server_sign == TRUE) &&
  5156. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  5157. (authorizeRetryTimes >= 3))
  5158. {
  5159. authorizeRetryTimes = 0;
  5160. SetOcppConnStatus(FALSE);
  5161. server_sign = FALSE;
  5162. }
  5163. else if((server_sign == FALSE) &&
  5164. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  5165. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  5166. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  5167. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  5168. {
  5169. sendAuthorizeRequest(0);
  5170. }
  5171. if(isWebsocketSendable &&
  5172. (server_sign == TRUE) &&
  5173. (ShmOCPP20Data->GetMonitoringReport.requestId > 0))
  5174. {
  5175. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.monitoringCriteria);idxCriterion++)
  5176. {
  5177. if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_ThresholdMonitoring]) == 0)
  5178. {
  5179. /*
  5180. * TODO:
  5181. * 1. Report component that are ThresholdMonitoring
  5182. */
  5183. }
  5184. else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_DeltaMonitoring]) == 0)
  5185. {
  5186. /*
  5187. * TODO:
  5188. * 1. Report component that are DeltaMonitoring
  5189. */
  5190. }
  5191. else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_PeriodicMonitoring]) == 0)
  5192. {
  5193. /*
  5194. * TODO:
  5195. * 1. Report component that are PeriodicMonitoring
  5196. */
  5197. }
  5198. else
  5199. {
  5200. /*
  5201. * TODO:
  5202. * 1. Process unknown criteria condition
  5203. */
  5204. }
  5205. }
  5206. ShmOCPP20Data->GetMonitoringReport.requestId = 0;
  5207. }
  5208. if(isWebsocketSendable &&
  5209. (server_sign == TRUE) &&
  5210. (ShmOCPP20Data->GetReport.requestId > 0))
  5211. {
  5212. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetReport.componentCriteria);idxCriterion++)
  5213. {
  5214. if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Active]) == 0)
  5215. {
  5216. /*
  5217. * TODO:
  5218. * 1. Report component that are active
  5219. */
  5220. }
  5221. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Available]) == 0)
  5222. {
  5223. /*
  5224. * TODO:
  5225. * 1. Report component that are available
  5226. */
  5227. }
  5228. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Enabled]) == 0)
  5229. {
  5230. /*
  5231. * TODO:
  5232. * 1. Report component that are enable
  5233. */
  5234. }
  5235. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Problem]) == 0)
  5236. {
  5237. /*
  5238. * TODO:
  5239. * 1. Report component that are problem
  5240. */
  5241. }
  5242. else
  5243. {
  5244. /*
  5245. * TODO:
  5246. * 1. Process unknown criteria condition
  5247. */
  5248. }
  5249. }
  5250. ShmOCPP20Data->GetReport.requestId = 0;
  5251. }
  5252. if(isWebsocketSendable &&
  5253. (server_sign == TRUE) &&
  5254. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  5255. {
  5256. uint8_t reportIdx = 0;
  5257. ShmOCPP20Data->NotifyReport.requestId = ShmOCPP20Data->GetBaseReport.requestId;
  5258. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  5259. {
  5260. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  5261. {
  5262. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  5263. {
  5264. 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))
  5265. {
  5266. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  5267. reportIdx++;
  5268. }
  5269. }
  5270. else
  5271. {
  5272. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  5273. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  5274. ShmOCPP20Data->NotifyReport.seqNo += 1;
  5275. else
  5276. ShmOCPP20Data->NotifyReport.seqNo = 0;
  5277. sendNotifyReportRequest();
  5278. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  5279. reportIdx = 0;
  5280. }
  5281. }
  5282. }
  5283. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  5284. {
  5285. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  5286. {
  5287. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  5288. {
  5289. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  5290. reportIdx++;
  5291. }
  5292. else
  5293. {
  5294. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  5295. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  5296. ShmOCPP20Data->NotifyReport.seqNo += 1;
  5297. else
  5298. ShmOCPP20Data->NotifyReport.seqNo = 0;
  5299. sendNotifyReportRequest();
  5300. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  5301. reportIdx = 0;
  5302. }
  5303. }
  5304. }
  5305. else
  5306. {
  5307. /*
  5308. * TODO:
  5309. * 1. Fill out summary inventory to response message, currently not support
  5310. */
  5311. }
  5312. if(reportIdx > 0)
  5313. {
  5314. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  5315. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  5316. ShmOCPP20Data->NotifyReport.seqNo += 1;
  5317. else
  5318. ShmOCPP20Data->NotifyReport.seqNo = 0;
  5319. sendNotifyReportRequest();
  5320. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  5321. reportIdx = 0;
  5322. }
  5323. ShmOCPP20Data->GetBaseReport.requestId = 0;
  5324. }
  5325. if(isWebsocketSendable &&
  5326. (server_sign == TRUE) &&
  5327. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  5328. {
  5329. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  5330. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  5331. if(ShmOCPP20Data->NotifyEvent.seqNo < INT_MAX)
  5332. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  5333. else
  5334. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  5335. sendNotifyEventRequest();
  5336. memset(&ShmOCPP20Data->NotifyEvent.eventData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)* sizeof(struct EventDataType ));
  5337. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  5338. }
  5339. if(isWebsocketSendable &&
  5340. (server_sign == TRUE) &&
  5341. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq)
  5342. {
  5343. if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Install]) == 0)
  5344. {
  5345. /*
  5346. * TODO:
  5347. * 1.
  5348. */
  5349. }
  5350. else if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Update]) == 0)
  5351. {
  5352. /*
  5353. * TODO:
  5354. * 1.
  5355. */
  5356. }
  5357. else
  5358. {
  5359. /*
  5360. * TODO:
  5361. * 1.
  5362. */
  5363. }
  5364. sendGet15118EVCertificateRequest();
  5365. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  5366. }
  5367. //===============================
  5368. // Each connector operation check
  5369. //===============================
  5370. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  5371. {
  5372. //==========================================
  5373. // csu trigger DataTransferReq
  5374. //==========================================
  5375. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  5376. {
  5377. sendDataTransferRequest(gun_index);
  5378. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  5379. }
  5380. //==============================================
  5381. // Charger start transaction
  5382. //==============================================
  5383. /*
  5384. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  5385. {
  5386. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  5387. sendStartTransactionRequest(gun_index);
  5388. clientTime.StartTransaction = time((time_t*)NULL);
  5389. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  5390. }*/
  5391. //==============================================
  5392. // Charger stop transaction
  5393. //==============================================
  5394. /*
  5395. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  5396. {
  5397. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  5398. sendStopTransactionRequest(gun_index);
  5399. clientTime.StopTransaction = time((time_t*)NULL);
  5400. }*/
  5401. //==============================================
  5402. // Charger status notification & Transaction event report
  5403. //==============================================
  5404. //--- Check Mode Change ---//
  5405. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  5406. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5407. {
  5408. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5409. {
  5410. tempIndex = ((gun_index==2) ? 1: 0);
  5411. }
  5412. else
  5413. {
  5414. tempIndex = gun_index;
  5415. }
  5416. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5417. {
  5418. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5419. {
  5420. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  5421. {
  5422. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  5423. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  5424. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  5425. if((SystemInitial == 0) &&
  5426. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  5427. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  5428. {
  5429. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  5430. }
  5431. }
  5432. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  5433. {
  5434. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  5435. if((access(filenmae,F_OK))!=-1)
  5436. {
  5437. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  5438. sprintf(str,"rm -f %s",filenmae);
  5439. system(str);
  5440. }
  5441. }
  5442. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  5443. #if 1 // for TempStopTransaction
  5444. if(((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  5445. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  5446. {
  5447. checkTempStopTransaction(gun_index);
  5448. }
  5449. #endif
  5450. }
  5451. }
  5452. }
  5453. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5454. {
  5455. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5456. {
  5457. tempIndex = ((gun_index==2) ? 1: 0);
  5458. }
  5459. else
  5460. {
  5461. tempIndex = gun_index;
  5462. }
  5463. for (int index = 0; index < CCS_QUANTITY; index++)
  5464. {
  5465. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5466. {
  5467. 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]*/ )
  5468. {
  5469. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  5470. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  5471. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  5472. if((SystemInitial == 0) &&
  5473. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  5474. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  5475. {
  5476. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  5477. }
  5478. }
  5479. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  5480. {
  5481. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  5482. if((access(filenmae,F_OK))!=-1)
  5483. {
  5484. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  5485. sprintf(str,"rm -f %s",filenmae);
  5486. system(str);
  5487. }
  5488. }
  5489. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  5490. #if 1 // for TempStopTransaction
  5491. if(((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  5492. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  5493. {
  5494. checkTempStopTransaction(gun_index);
  5495. }
  5496. #endif
  5497. }
  5498. }
  5499. }
  5500. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5501. {
  5502. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5503. {
  5504. tempIndex = ((gun_index==2) ? 1: 0);
  5505. }
  5506. else
  5507. {
  5508. tempIndex = gun_index;
  5509. }
  5510. for (int index = 0; index < GB_QUANTITY; index++)
  5511. {
  5512. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5513. {
  5514. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  5515. {
  5516. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  5517. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  5518. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  5519. if((SystemInitial == 0) &&
  5520. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  5521. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  5522. {
  5523. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  5524. }
  5525. }
  5526. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  5527. {
  5528. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  5529. if((access(filenmae,F_OK))!=-1)
  5530. {
  5531. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  5532. sprintf(str,"rm -f %s",filenmae);
  5533. system(str);
  5534. }
  5535. }
  5536. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  5537. #if 1 // for TempStopTransaction
  5538. if(((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  5539. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  5540. {
  5541. checkTempStopTransaction(gun_index);
  5542. }
  5543. #endif
  5544. }
  5545. }
  5546. }
  5547. else if(gunType[gun_index] == GUN_TYPE_DO)
  5548. {
  5549. tempIndex = gun_index;
  5550. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5551. {
  5552. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5553. {
  5554. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  5555. {
  5556. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  5557. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  5558. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  5559. if((SystemInitial == 0) &&
  5560. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING) &&
  5561. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE))
  5562. {
  5563. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  5564. }
  5565. }
  5566. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  5567. {
  5568. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  5569. if((access(filenmae,F_OK))!=-1)
  5570. {
  5571. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  5572. sprintf(str,"rm -f %s",filenmae);
  5573. system(str);
  5574. }
  5575. }
  5576. 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);
  5577. #if 1 // for TempStopTransaction
  5578. if(((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)) &&
  5579. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  5580. {
  5581. checkTempStopTransaction(gun_index);
  5582. }
  5583. #endif
  5584. }
  5585. }
  5586. }
  5587. else
  5588. {
  5589. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5590. {
  5591. tempIndex = 2;
  5592. }
  5593. else
  5594. {
  5595. tempIndex = gun_index;
  5596. }
  5597. for (int index = 0; index < AC_QUANTITY; index++)
  5598. {
  5599. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5600. {
  5601. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  5602. {
  5603. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  5604. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  5605. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  5606. if((SystemInitial == 0) &&
  5607. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  5608. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  5609. {
  5610. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  5611. }
  5612. }
  5613. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  5614. {
  5615. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  5616. if((access(filenmae,F_OK))!=-1)
  5617. {
  5618. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  5619. sprintf(str,"rm -f %s",filenmae);
  5620. system(str);
  5621. }
  5622. }
  5623. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  5624. #if 1 // for TempStopTransaction
  5625. if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  5626. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  5627. {
  5628. checkTempStopTransaction(gun_index);
  5629. }
  5630. #endif
  5631. }
  5632. }// END
  5633. }
  5634. if(isWebsocketSendable && (server_sign == TRUE) && ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 5) &&
  5635. ((cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) || (cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq == ON)) )
  5636. {
  5637. if(SystemInitial > 0)
  5638. SystemInitial -= 1;
  5639. sendStatusNotificationRequest(gun_index);
  5640. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  5641. }
  5642. //===============================
  5643. // CSU Trigger Smart Charging Profilw
  5644. //===============================
  5645. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  5646. {
  5647. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index], 0, TRUE);
  5648. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  5649. }
  5650. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  5651. {
  5652. sendTransactionEventRequest(gun_index);
  5653. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  5654. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  5655. }
  5656. //==============================================
  5657. // Meter report
  5658. //==============================================
  5659. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  5660. {
  5661. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  5662. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  5663. }
  5664. // ClockAlign MeterValue
  5665. 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))
  5666. {
  5667. //check Transaction active
  5668. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5669. {
  5670. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5671. {
  5672. tempIndex = ((gun_index==2) ? 1: 0);
  5673. }
  5674. else
  5675. {
  5676. tempIndex = gun_index;
  5677. }
  5678. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5679. {
  5680. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5681. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5682. {
  5683. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5684. }
  5685. }// End for CHAdeMO
  5686. }
  5687. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5688. {
  5689. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5690. {
  5691. tempIndex = ((gun_index==2) ? 1: 0);
  5692. }
  5693. else
  5694. {
  5695. tempIndex = gun_index;
  5696. }
  5697. for (int index = 0; index < CCS_QUANTITY; index++)
  5698. {
  5699. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5700. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5701. {
  5702. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5703. }
  5704. } // End for CCS
  5705. }
  5706. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5707. {
  5708. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5709. {
  5710. tempIndex = ((gun_index==2) ? 1: 0);
  5711. }
  5712. else
  5713. {
  5714. tempIndex = gun_index;
  5715. }
  5716. for (int index = 0; index < GB_QUANTITY; index++)
  5717. {
  5718. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5719. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5720. {
  5721. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5722. }
  5723. }// End for GB
  5724. }
  5725. else if(gunType[gun_index] == GUN_TYPE_DO)
  5726. {
  5727. tempIndex = gun_index;
  5728. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5729. {
  5730. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5731. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5732. {
  5733. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5734. }
  5735. }
  5736. }
  5737. else
  5738. {
  5739. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5740. {
  5741. tempIndex = 2;
  5742. }
  5743. else
  5744. {
  5745. tempIndex = gun_index;
  5746. }
  5747. for (int index = 0; index < AC_QUANTITY; index++)
  5748. {
  5749. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5750. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5751. {
  5752. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  5753. }
  5754. }//End for AC
  5755. }
  5756. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  5757. {
  5758. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  5759. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  5760. }
  5761. }
  5762. // Sample period MeterValue
  5763. if((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > ((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)>10)?(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1):10))
  5764. {
  5765. //check Transaction active
  5766. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  5767. {
  5768. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5769. {
  5770. tempIndex = ((gun_index==2) ? 1: 0);
  5771. }
  5772. else
  5773. {
  5774. tempIndex = gun_index;
  5775. }
  5776. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5777. {
  5778. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5779. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5780. {
  5781. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5782. {
  5783. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5784. }
  5785. }
  5786. }// End for CHAdeMO
  5787. }
  5788. else if(gunType[gun_index] == GUN_TYPE_CCS)
  5789. {
  5790. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5791. {
  5792. tempIndex = ((gun_index==2) ? 1: 0);
  5793. }
  5794. else
  5795. {
  5796. tempIndex = gun_index;
  5797. }
  5798. for (int index = 0; index < CCS_QUANTITY; index++)
  5799. {
  5800. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5801. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5802. {
  5803. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5804. {
  5805. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5806. }
  5807. }
  5808. } // End for CCS
  5809. }
  5810. else if(gunType[gun_index] == GUN_TYPE_GBT)
  5811. {
  5812. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5813. {
  5814. tempIndex = ((gun_index==2) ? 1: 0);
  5815. }
  5816. else
  5817. {
  5818. tempIndex = gun_index;
  5819. }
  5820. for (int index = 0; index < GB_QUANTITY; index++)
  5821. {
  5822. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5823. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5824. {
  5825. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5826. {
  5827. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5828. }
  5829. }
  5830. }// End for GB
  5831. }
  5832. else if(gunType[gun_index] == GUN_TYPE_DO)
  5833. {
  5834. tempIndex = gun_index;
  5835. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5836. {
  5837. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5838. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5839. {
  5840. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  5841. {
  5842. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5843. }
  5844. }
  5845. }
  5846. }
  5847. else
  5848. {
  5849. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5850. {
  5851. tempIndex = 2;
  5852. }
  5853. else
  5854. {
  5855. tempIndex = gun_index;
  5856. }
  5857. for (int index = 0; index < AC_QUANTITY; index++)
  5858. {
  5859. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  5860. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5861. {
  5862. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  5863. {
  5864. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  5865. }
  5866. }
  5867. }//End for AC
  5868. }
  5869. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  5870. {
  5871. if(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0)
  5872. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  5873. storeTempStopTransaction(gun_index);
  5874. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  5875. }
  5876. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  5877. }
  5878. //==============================================
  5879. // Check Connector reserved
  5880. //==============================================
  5881. //===============================
  5882. // Check if Reserve is expired
  5883. //===============================
  5884. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  5885. {
  5886. double diff_t;
  5887. struct tm tp;
  5888. // current time
  5889. time_t t = time(NULL);
  5890. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  5891. tp.tm_isdst = -1;
  5892. time_t utc = mktime(&tp);
  5893. diff_t = difftime(utc, t);
  5894. if(diff_t <= 0)
  5895. {
  5896. DEBUG_INFO("reserve expired.\n");
  5897. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  5898. }
  5899. }//END OF Check if Reserve is expired
  5900. //==========================================
  5901. // csu trigger FirmwareStatusNotificationReq
  5902. //==========================================
  5903. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  5904. {
  5905. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  5906. }
  5907. //==========================================
  5908. // csu cleared charging limit request
  5909. //==========================================
  5910. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq == ON))
  5911. {
  5912. sendClearedChargingLimitRequest(gun_index);
  5913. }
  5914. //==========================================
  5915. // csu trigger CancelReservationConf
  5916. //==========================================
  5917. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  5918. {
  5919. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  5920. }
  5921. //==========================================
  5922. // csu notify EV charging need request
  5923. //==========================================
  5924. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq == ON))
  5925. {
  5926. sendNotifyEVChargingNeedsRequest(gun_index);
  5927. }
  5928. //==========================================
  5929. // csu trigger ChangeAvailabilityConf
  5930. //==========================================
  5931. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  5932. {
  5933. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  5934. }
  5935. //==========================================
  5936. // csu trigger UnlockConnectorConf
  5937. //==========================================
  5938. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  5939. {
  5940. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  5941. }
  5942. //==========================================
  5943. // csu trigger ReserveNowConf
  5944. //==========================================
  5945. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  5946. {
  5947. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  5948. }
  5949. //==========================================
  5950. // csu trigger ReserveNowConf
  5951. //==========================================
  5952. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq == ON))
  5953. {
  5954. sendReservationStatusUpdateRequest(gun_index);
  5955. }
  5956. //==========================================
  5957. // csu trigger LogStatusNotificationReq
  5958. //==========================================
  5959. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq == ON))
  5960. {
  5961. sendLogStatusNotificationRequest((char *)ShmOCPP20Data->LogStatusNotification.status);
  5962. }
  5963. //==========================================
  5964. // csu trigger SignCertificateReq
  5965. //==========================================
  5966. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.SignCertificateReq == ON))
  5967. {
  5968. if((access("/Storage/OCPP/certCP.csr",F_OK) != -1) &&
  5969. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0) )
  5970. {
  5971. sendSignCertificateRequest(CertificateSignedStatusEnumType_ChargingStationCertificate);
  5972. }
  5973. else if((access("/Storage/OCPP/certV2G.csr",F_OK) != -1) &&
  5974. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0))
  5975. {
  5976. sendSignCertificateRequest(CertificateSignedStatusEnumType_V2GCertificate);
  5977. }
  5978. }
  5979. }
  5980. }
  5981. //==========================================
  5982. // send request routine
  5983. //==========================================
  5984. int sendAuthorizeRequest(int gun_index)
  5985. {
  5986. mtrace();
  5987. int result = FAIL;
  5988. char message[4096]={0};
  5989. char guid[37];
  5990. char tempdata[128]={0};
  5991. json_object *Authorize = json_object_new_object();
  5992. json_object *idToken = json_object_new_object();
  5993. DEBUG_INFO("sendAuthorizeRequest...\n");
  5994. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  5995. //Local Authorize
  5996. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  5997. {
  5998. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  5999. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  6000. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  6001. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  6002. result = PASS;
  6003. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6004. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6005. authorizeRetryTimes = 0;
  6006. return result;
  6007. }
  6008. 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)) ||
  6009. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  6010. {
  6011. // Query idtag from cache
  6012. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  6013. // Query idtag from list
  6014. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  6015. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  6016. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  6017. {
  6018. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  6019. {
  6020. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  6021. }
  6022. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  6023. {
  6024. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  6025. }
  6026. // Return authorize result if does not connect to server
  6027. if(!ShmOCPP20Data->OcppConnStatus)
  6028. {
  6029. DEBUG_INFO("Local Authorization Fail.\n");
  6030. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  6031. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6032. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  6033. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  6034. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6035. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6036. authorizeRetryTimes = 0;
  6037. return result;
  6038. }
  6039. }
  6040. else
  6041. {
  6042. DEBUG_INFO("Local Authorization get result.\n");
  6043. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  6044. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6045. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  6046. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  6047. else
  6048. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  6049. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  6050. result = PASS;
  6051. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6052. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6053. authorizeRetryTimes = 0;
  6054. return result;
  6055. }
  6056. }
  6057. //get data from shared memory
  6058. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6059. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  6060. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  6061. json_object_object_add(Authorize, "idToken", idToken);
  6062. random_uuid(guid);
  6063. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  6064. json_object_put(Authorize);
  6065. LWS_Send(message);
  6066. sprintf(tempdata, "Authorize,%d", gun_index);
  6067. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6068. {
  6069. result = PASS;
  6070. }
  6071. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6072. return result;
  6073. }
  6074. int sendBootNotificationRequest()
  6075. {
  6076. mtrace();
  6077. int result = FAIL;
  6078. char message[4096]={0};
  6079. char guid[37]={0};
  6080. char tempdata[128]={0};
  6081. json_object *BootNotification = json_object_new_object();
  6082. json_object *chargingStation = json_object_new_object();
  6083. json_object *modem = json_object_new_object();
  6084. DEBUG_INFO("sendBootNotificationRequest...\n");
  6085. // Fill BootNotification fields
  6086. DB_getBooType();
  6087. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  6088. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  6089. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  6090. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  6091. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  6092. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  6093. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  6094. {
  6095. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  6096. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  6097. json_object_object_add(chargingStation, "modem", modem);
  6098. }
  6099. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  6100. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  6101. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  6102. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  6103. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  6104. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  6105. random_uuid(guid);
  6106. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  6107. json_object_put(BootNotification);
  6108. LWS_Send(message);
  6109. sprintf(tempdata, "BootNotification,0");
  6110. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6111. {
  6112. result = PASS;
  6113. }
  6114. return result;
  6115. }
  6116. int sendClearedChargingLimitRequest(int gun_index)
  6117. {
  6118. mtrace();
  6119. int result = FAIL;
  6120. char message[4096]={0};
  6121. char guid[37]={0};
  6122. char tempdata[128]={0};
  6123. json_object *ClearedChargingLimit = json_object_new_object();
  6124. DEBUG_INFO("sendClearedChargingLimitRequest...\n");
  6125. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  6126. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  6127. random_uuid(guid);
  6128. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  6129. json_object_put(ClearedChargingLimit);
  6130. LWS_Send(message);
  6131. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  6132. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6133. {
  6134. result = PASS;
  6135. }
  6136. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  6137. return result;
  6138. }
  6139. int sendDataTransferRequest(int gun_index)
  6140. {
  6141. mtrace();
  6142. char message[1000]={0};
  6143. char guid[37]={0};
  6144. char tempdata[65]={0};
  6145. int result = FAIL;
  6146. DEBUG_INFO("sendDataTransferRequest...\n");
  6147. random_uuid(guid);
  6148. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  6149. MESSAGE_TYPE_CALL,
  6150. guid,
  6151. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  6152. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  6153. ShmOCPP20Data->DataTransfer[gun_index].data);
  6154. LWS_Send(message);
  6155. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  6156. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6157. {
  6158. result = PASS;
  6159. }
  6160. return result;
  6161. }
  6162. int sendFirmwareStatusNotificationRequest(char *status)
  6163. {
  6164. mtrace();
  6165. int result = FAIL;
  6166. char message[110]={0};
  6167. char guid[37]={0};
  6168. char tempdata[65]={0};
  6169. json_object *FirmwareStatusNotification = json_object_new_object();
  6170. DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
  6171. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  6172. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  6173. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  6174. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  6175. random_uuid(guid);
  6176. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6177. json_object_put(FirmwareStatusNotification);
  6178. LWS_SendNow(message);
  6179. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  6180. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6181. {
  6182. result = PASS;
  6183. }
  6184. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  6185. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  6186. //record status
  6187. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  6188. {
  6189. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  6190. }
  6191. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  6192. {
  6193. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  6194. }
  6195. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  6196. {
  6197. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  6198. }
  6199. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  6200. {
  6201. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  6202. }
  6203. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  6204. {
  6205. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  6206. }
  6207. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  6208. {
  6209. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  6210. }
  6211. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  6212. {
  6213. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  6214. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  6215. }
  6216. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  6217. {
  6218. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  6219. }
  6220. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  6221. {
  6222. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  6223. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  6224. }
  6225. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  6226. {
  6227. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  6228. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  6229. }
  6230. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  6231. {
  6232. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  6233. }
  6234. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  6235. {
  6236. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  6237. }
  6238. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  6239. {
  6240. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  6241. }
  6242. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  6243. {
  6244. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  6245. }
  6246. return result;
  6247. }
  6248. int sendGet15118EVCertificateRequest()
  6249. {
  6250. mtrace();
  6251. int result = FAIL;
  6252. char message[4096]={0};
  6253. char guid[37]={0};
  6254. char tempdata[128]={0};
  6255. json_object *Get15118EVCertificate = json_object_new_object();
  6256. DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
  6257. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  6258. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  6259. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  6260. random_uuid(guid);
  6261. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  6262. json_object_put(Get15118EVCertificate);
  6263. LWS_Send(message);
  6264. sprintf(tempdata, "Get15118EVCertificate,0");
  6265. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6266. {
  6267. result = PASS;
  6268. }
  6269. return result;
  6270. }
  6271. int sendGetCertificateStatusRequest()
  6272. {
  6273. mtrace();
  6274. int result = FAIL;
  6275. char message[4096]={0};
  6276. char guid[37]={0};
  6277. char tempdata[128]={0};
  6278. json_object *GetCertificateStatus = json_object_new_object();
  6279. json_object *ocspRequestData = json_object_new_object();
  6280. DEBUG_INFO("sendGetCertificateStatusRequest...\n");
  6281. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  6282. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  6283. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  6284. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  6285. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  6286. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  6287. random_uuid(guid);
  6288. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  6289. json_object_put(GetCertificateStatus);
  6290. LWS_Send(message);
  6291. sprintf(tempdata, "GetCertificateStatus,0");
  6292. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6293. {
  6294. result = PASS;
  6295. }
  6296. return result;
  6297. }
  6298. int sendHeartbeatRequest()
  6299. {
  6300. mtrace();
  6301. int result = FAIL;
  6302. char message[40096]={0};
  6303. char guid[37]={0};
  6304. char tempdata[128]={0};
  6305. DEBUG_INFO("sendHeartbeatRequest...\n");
  6306. random_uuid(guid);
  6307. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  6308. , MESSAGE_TYPE_CALL
  6309. , guid );
  6310. LWS_Send(message);
  6311. sprintf(tempdata, "Heartbeat,%d", 0);
  6312. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6313. {
  6314. result = PASS;
  6315. }
  6316. return result;
  6317. }
  6318. int sendLogStatusNotificationRequest(char *status)
  6319. {
  6320. mtrace();
  6321. int result = FAIL;
  6322. char message[4096]={0};
  6323. char guid[37]={0};
  6324. char tempdata[128]={0};
  6325. json_object *LogStatusNotification = json_object_new_object();
  6326. DEBUG_INFO("sendLogStatusNotificationRequest...\n");
  6327. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  6328. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  6329. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  6330. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  6331. random_uuid(guid);
  6332. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  6333. json_object_put(LogStatusNotification);
  6334. LWS_SendNow(message);
  6335. sprintf(tempdata, "LogStatusNotification,%d", 0);
  6336. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6337. {
  6338. result = PASS;
  6339. }
  6340. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  6341. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  6342. //record status
  6343. if(strcmp(status,"BadMessage")==0)
  6344. {
  6345. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  6346. }
  6347. else if(strcmp(status,"Idle")==0)
  6348. {
  6349. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  6350. }
  6351. else if(strcmp(status,"NotSupportedOperation")==0)
  6352. {
  6353. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  6354. }
  6355. else if(strcmp(status,"PermissionDenied")==0)
  6356. {
  6357. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  6358. }
  6359. else if(strcmp(status,"Uploaded")==0)
  6360. {
  6361. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  6362. }
  6363. else if(strcmp(status,"UploadFailure")==0)
  6364. {
  6365. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  6366. }
  6367. else if(strcmp(status,"Uploading")==0)
  6368. {
  6369. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  6370. }
  6371. return result;
  6372. }
  6373. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  6374. {
  6375. mtrace();
  6376. int result = FAIL;
  6377. char guid[37]={0};
  6378. char tempdata[65]={0};
  6379. int tempIndex = 0;
  6380. json_object *MeterValueReq = json_object_new_object();
  6381. json_object *meterValues = json_object_new_array();
  6382. json_object *sampledValues = json_object_new_array();
  6383. DEBUG_INFO("sendMeterValuesRequest...\n");
  6384. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  6385. memset(&ShmOCPP20Data->MeterValues[gun_index], 0, sizeof(struct MeterValues_20));
  6386. //set value
  6387. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  6388. //UTC Date time
  6389. struct timeval tmnow;
  6390. struct tm *tm;
  6391. char buf[28];//, usec_buf[6];
  6392. gettimeofday(&tmnow, NULL);
  6393. time_t t;
  6394. t = time(NULL);
  6395. /*UTC time and date*/
  6396. tm = gmtime(&t);
  6397. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6398. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  6399. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  6400. //idx_sample=0;
  6401. //********************************(1)Current.Import L1************************************************/
  6402. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  6403. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  6404. (dataType == ReadingContextEnumType_Trigger))
  6405. {
  6406. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6407. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6408. {
  6409. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6410. {
  6411. tempIndex = ((gun_index==2) ? 1: 0);
  6412. }
  6413. else
  6414. {
  6415. tempIndex = gun_index;
  6416. }
  6417. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6418. {
  6419. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6420. {
  6421. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  6422. }
  6423. }
  6424. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6425. }
  6426. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6427. {
  6428. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6429. {
  6430. tempIndex = ((gun_index==2) ? 1: 0);
  6431. }
  6432. else
  6433. {
  6434. tempIndex = gun_index;
  6435. }
  6436. for (int index = 0; index < CCS_QUANTITY; index++)
  6437. {
  6438. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6439. {
  6440. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  6441. }
  6442. }
  6443. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6444. }
  6445. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6446. {
  6447. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6448. {
  6449. tempIndex = ((gun_index==2) ? 1: 0);
  6450. }
  6451. else
  6452. {
  6453. tempIndex = gun_index;
  6454. }
  6455. for (int index = 0; index < GB_QUANTITY; index++)
  6456. {
  6457. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6458. {
  6459. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  6460. }
  6461. }
  6462. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6463. }
  6464. else if(gunType[gun_index] == GUN_TYPE_DO)
  6465. {
  6466. tempIndex = gun_index;
  6467. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6468. {
  6469. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6470. {
  6471. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
  6472. }
  6473. }
  6474. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6475. }
  6476. else
  6477. {
  6478. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6479. {
  6480. tempIndex = 2;
  6481. }
  6482. else
  6483. {
  6484. tempIndex = gun_index;
  6485. }
  6486. for (int index = 0; index < AC_QUANTITY; index++)
  6487. {
  6488. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6489. {
  6490. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  6491. }
  6492. }
  6493. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6494. }
  6495. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  6496. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  6497. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6498. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  6499. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  6500. }
  6501. //idx_sample=1;
  6502. //********************************(2)Energy.Active.Import.Register ************************************************/
  6503. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
  6504. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
  6505. (dataType == ReadingContextEnumType_Trigger))
  6506. {
  6507. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6508. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6509. {
  6510. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6511. {
  6512. tempIndex = ((gun_index==2) ? 1: 0);
  6513. }
  6514. else
  6515. {
  6516. tempIndex = gun_index;
  6517. }
  6518. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6519. {
  6520. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6521. {
  6522. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  6523. }
  6524. }
  6525. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6526. }
  6527. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6528. {
  6529. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6530. {
  6531. tempIndex = ((gun_index==2) ? 1: 0);
  6532. }
  6533. else
  6534. {
  6535. tempIndex = gun_index;
  6536. }
  6537. for (int index = 0; index < CCS_QUANTITY; index++)
  6538. {
  6539. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6540. {
  6541. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  6542. }
  6543. }
  6544. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6545. }
  6546. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6547. {
  6548. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6549. {
  6550. tempIndex = ((gun_index==2) ? 1: 0);
  6551. }
  6552. else
  6553. {
  6554. tempIndex = gun_index;
  6555. }
  6556. for (int index = 0; index < GB_QUANTITY; index++)
  6557. {
  6558. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6559. {
  6560. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  6561. }
  6562. }
  6563. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6564. }
  6565. else if(gunType[gun_index] == GUN_TYPE_DO)
  6566. {
  6567. tempIndex = gun_index;
  6568. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6569. {
  6570. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6571. {
  6572. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  6573. }
  6574. }
  6575. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6576. }
  6577. else
  6578. {
  6579. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6580. {
  6581. tempIndex = 2;
  6582. }
  6583. else
  6584. {
  6585. tempIndex = gun_index;
  6586. }
  6587. for (int index = 0; index < AC_QUANTITY; index++)
  6588. {
  6589. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6590. {
  6591. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  6592. }
  6593. }
  6594. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6595. }
  6596. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  6597. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  6598. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6599. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  6600. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  6601. }
  6602. //idx_sample=2;
  6603. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  6604. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
  6605. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
  6606. (dataType == ReadingContextEnumType_Trigger))
  6607. {
  6608. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6609. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6610. {
  6611. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6612. {
  6613. tempIndex = ((gun_index==2) ? 1: 0);
  6614. }
  6615. else
  6616. {
  6617. tempIndex = gun_index;
  6618. }
  6619. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6620. {
  6621. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6622. {
  6623. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  6624. }
  6625. } // END OF FOR CHAdeMO_QUANTITY
  6626. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6627. }
  6628. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6629. {
  6630. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6631. {
  6632. tempIndex = ((gun_index==2) ? 1: 0);
  6633. }
  6634. else
  6635. {
  6636. tempIndex = gun_index;
  6637. }
  6638. for (int index = 0; index < CCS_QUANTITY; index++)
  6639. {
  6640. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6641. {
  6642. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  6643. }
  6644. } // END OF CCS_QUANTITY
  6645. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6646. }
  6647. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6648. {
  6649. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6650. {
  6651. tempIndex = ((gun_index==2) ? 1: 0);
  6652. }
  6653. else
  6654. {
  6655. tempIndex = gun_index;
  6656. }
  6657. for (int index = 0; index < GB_QUANTITY; index++)
  6658. {
  6659. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6660. {
  6661. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  6662. }
  6663. } // END OF GB_QUANTITY
  6664. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6665. }
  6666. else if(gunType[gun_index] == GUN_TYPE_DO)
  6667. {
  6668. tempIndex = gun_index;
  6669. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6670. {
  6671. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6672. {
  6673. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
  6674. }
  6675. }
  6676. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6677. }
  6678. else
  6679. {
  6680. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6681. {
  6682. tempIndex = 2;
  6683. }
  6684. else
  6685. {
  6686. tempIndex = gun_index;
  6687. }
  6688. for (int index = 0; index < AC_QUANTITY; index++)
  6689. {
  6690. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6691. {
  6692. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  6693. }
  6694. }
  6695. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6696. }
  6697. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  6698. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  6699. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6700. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  6701. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  6702. }
  6703. //idx_sample=3;
  6704. //********************************(4)Power.Active.Import************************************************/
  6705. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
  6706. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
  6707. (dataType == ReadingContextEnumType_Trigger))
  6708. {
  6709. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6710. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6711. {
  6712. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6713. {
  6714. tempIndex = ((gun_index==2) ? 1: 0);
  6715. }
  6716. else
  6717. {
  6718. tempIndex = gun_index;
  6719. }
  6720. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6721. {
  6722. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6723. {
  6724. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  6725. }
  6726. } // END OF FOR
  6727. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6728. }
  6729. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6730. {
  6731. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6732. {
  6733. tempIndex = ((gun_index==2) ? 1: 0);
  6734. }
  6735. else
  6736. {
  6737. tempIndex = gun_index;
  6738. }
  6739. for (int index = 0; index < CCS_QUANTITY; index++)
  6740. {
  6741. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6742. {
  6743. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  6744. }
  6745. }
  6746. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6747. }
  6748. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6749. {
  6750. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6751. {
  6752. tempIndex = ((gun_index==2) ? 1: 0);
  6753. }
  6754. else
  6755. {
  6756. tempIndex = gun_index;
  6757. }
  6758. for (int index = 0; index < GB_QUANTITY; index++)
  6759. {
  6760. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6761. {
  6762. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  6763. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  6764. }
  6765. }
  6766. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6767. }
  6768. else if(gunType[gun_index] == GUN_TYPE_DO)
  6769. {
  6770. tempIndex = gun_index;
  6771. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6772. {
  6773. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6774. {
  6775. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  6776. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
  6777. }
  6778. }
  6779. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6780. }
  6781. else
  6782. {
  6783. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6784. {
  6785. tempIndex = 2;
  6786. }
  6787. else
  6788. {
  6789. tempIndex = gun_index;
  6790. }
  6791. for (int index = 0; index < AC_QUANTITY; index++)
  6792. {
  6793. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6794. {
  6795. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  6796. }
  6797. }
  6798. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6799. }
  6800. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  6801. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  6802. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6803. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  6804. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  6805. }
  6806. //idx_sample=4;
  6807. //***********************************************(5)VOLTAGE L1******************************************************/
  6808. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  6809. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  6810. (dataType == ReadingContextEnumType_Trigger))
  6811. {
  6812. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  6813. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6814. {
  6815. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6816. {
  6817. tempIndex = ((gun_index==2) ? 1: 0);
  6818. }
  6819. else
  6820. {
  6821. tempIndex = gun_index;
  6822. }
  6823. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6824. {
  6825. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6826. {
  6827. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  6828. }
  6829. }
  6830. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6831. }
  6832. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6833. {
  6834. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6835. {
  6836. tempIndex = ((gun_index==2) ? 1: 0);
  6837. }
  6838. else
  6839. {
  6840. tempIndex = gun_index;
  6841. }
  6842. for (int index = 0; index < CCS_QUANTITY; index++)
  6843. {
  6844. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6845. {
  6846. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  6847. }
  6848. }
  6849. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6850. }
  6851. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6852. {
  6853. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6854. {
  6855. tempIndex = ((gun_index==2) ? 1: 0);
  6856. }
  6857. else
  6858. {
  6859. tempIndex = gun_index;
  6860. }
  6861. for (int index = 0; index < GB_QUANTITY; index++)
  6862. {
  6863. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6864. {
  6865. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  6866. }
  6867. }
  6868. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6869. }
  6870. else if(gunType[gun_index] == GUN_TYPE_DO)
  6871. {
  6872. tempIndex = gun_index;
  6873. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6874. {
  6875. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6876. {
  6877. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
  6878. }
  6879. }
  6880. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6881. }
  6882. else
  6883. {
  6884. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6885. {
  6886. tempIndex = 2;
  6887. }
  6888. else
  6889. {
  6890. tempIndex = gun_index;
  6891. }
  6892. for (int index = 0; index < AC_QUANTITY; index++)
  6893. {
  6894. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6895. {
  6896. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  6897. }
  6898. }
  6899. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  6900. }
  6901. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  6902. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  6903. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6904. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  6905. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  6906. }
  6907. //***********************************************(6)SOC******************************************************/
  6908. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
  6909. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
  6910. (dataType == ReadingContextEnumType_Trigger))
  6911. {
  6912. 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))
  6913. {
  6914. if((ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0') && (gunType[gun_index] != GUN_TYPE_DO))
  6915. {
  6916. tempIndex = ((gun_index==2) ? 1: 0);
  6917. }
  6918. else
  6919. {
  6920. tempIndex = gun_index;
  6921. }
  6922. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6923. {
  6924. //tempIndex = ((gun_index==2) ? 1: 0);
  6925. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6926. {
  6927. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6928. {
  6929. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  6930. }
  6931. }
  6932. }
  6933. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6934. {
  6935. //tempIndex = ((gun_index==2) ? 1: 0);
  6936. for (int index = 0; index < CCS_QUANTITY; index++)
  6937. {
  6938. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6939. {
  6940. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  6941. }
  6942. }
  6943. }
  6944. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6945. {
  6946. //tempIndex = ((gun_index==2) ? 1: 0);
  6947. for (int index = 0; index < GB_QUANTITY; index++)
  6948. {
  6949. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6950. {
  6951. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  6952. }
  6953. }
  6954. }
  6955. else if(gunType[gun_index] == GUN_TYPE_DO)
  6956. {
  6957. //tempIndex = ((gun_index==2) ? 1: 0);
  6958. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6959. {
  6960. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6961. {
  6962. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  6963. }
  6964. }
  6965. }
  6966. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  6967. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  6968. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6969. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  6970. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  6971. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  6972. }
  6973. }
  6974. //********************************(7)Current.Import L2************************************************/
  6975. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  6976. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  6977. (dataType == ReadingContextEnumType_Trigger))
  6978. {
  6979. // Only for AC 3 phase
  6980. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  6981. {
  6982. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6983. {
  6984. tempIndex = 2;
  6985. }
  6986. else
  6987. {
  6988. tempIndex = gun_index;
  6989. }
  6990. for (int index = 0; index < AC_QUANTITY; index++)
  6991. {
  6992. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6993. {
  6994. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  6995. }
  6996. }
  6997. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  6998. }
  6999. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  7000. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7001. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7002. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  7003. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  7004. }
  7005. //********************************(8)Current.Import L3************************************************/
  7006. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7007. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7008. (dataType == ReadingContextEnumType_Trigger))
  7009. {
  7010. // Only for AC 3 phase
  7011. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7012. {
  7013. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7014. {
  7015. tempIndex = 2;
  7016. }
  7017. else
  7018. {
  7019. tempIndex = gun_index;
  7020. }
  7021. for (int index = 0; index < AC_QUANTITY; index++)
  7022. {
  7023. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7024. {
  7025. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  7026. }
  7027. }
  7028. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7029. }
  7030. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  7031. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7032. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7033. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  7034. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  7035. }
  7036. //***********************************************(9)VOLTAGE L2******************************************************/
  7037. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7038. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7039. (dataType == ReadingContextEnumType_Trigger))
  7040. {
  7041. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7042. {
  7043. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7044. {
  7045. tempIndex = 2;
  7046. }
  7047. else
  7048. {
  7049. tempIndex = gun_index;
  7050. }
  7051. for (int index = 0; index < AC_QUANTITY; index++)
  7052. {
  7053. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7054. {
  7055. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  7056. }
  7057. }
  7058. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  7059. }
  7060. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  7061. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7062. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7063. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  7064. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  7065. }
  7066. //***********************************************(10)VOLTAGE L3******************************************************/
  7067. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7068. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7069. (dataType == ReadingContextEnumType_Trigger))
  7070. {
  7071. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7072. {
  7073. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7074. {
  7075. tempIndex = 2;
  7076. }
  7077. else
  7078. {
  7079. tempIndex = gun_index;
  7080. }
  7081. for (int index = 0; index < AC_QUANTITY; index++)
  7082. {
  7083. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7084. {
  7085. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  7086. }
  7087. }
  7088. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7089. }
  7090. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  7091. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7092. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7093. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  7094. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  7095. }
  7096. //***********************************************(11)Current.Offered******************************************************/
  7097. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
  7098. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
  7099. (dataType == ReadingContextEnumType_Trigger))
  7100. {
  7101. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7102. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7103. {
  7104. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7105. {
  7106. tempIndex = ((gun_index==2) ? 1: 0);
  7107. }
  7108. else
  7109. {
  7110. tempIndex = gun_index;
  7111. }
  7112. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7113. {
  7114. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7115. {
  7116. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].AvailableChargingCurrent/10);
  7117. }
  7118. } // END OF FOR
  7119. }
  7120. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7121. {
  7122. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7123. {
  7124. tempIndex = ((gun_index==2) ? 1: 0);
  7125. }
  7126. else
  7127. {
  7128. tempIndex = gun_index;
  7129. }
  7130. for (int index = 0; index < CCS_QUANTITY; index++)
  7131. {
  7132. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7133. {
  7134. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].AvailableChargingCurrent/10);
  7135. }
  7136. }
  7137. }
  7138. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7139. {
  7140. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7141. {
  7142. tempIndex = ((gun_index==2) ? 1: 0);
  7143. }
  7144. else
  7145. {
  7146. tempIndex = gun_index;
  7147. }
  7148. for (int index = 0; index < GB_QUANTITY; index++)
  7149. {
  7150. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7151. {
  7152. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7153. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].AvailableChargingCurrent/10);;
  7154. }
  7155. }
  7156. }
  7157. else if(gunType[gun_index] == GUN_TYPE_DO)
  7158. {
  7159. tempIndex = gun_index;
  7160. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7161. {
  7162. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7163. {
  7164. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7165. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.AvailableChargingCurrent/10);;
  7166. }
  7167. }
  7168. }
  7169. else
  7170. {
  7171. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7172. {
  7173. tempIndex = 2;
  7174. }
  7175. else
  7176. {
  7177. tempIndex = gun_index;
  7178. }
  7179. for (int index = 0; index < AC_QUANTITY; index++)
  7180. {
  7181. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7182. {
  7183. uint16_t currentOffer;
  7184. if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
  7185. {
  7186. currentOffer = ShmSysConfigAndInfo->SysConfig.RatingCurrent;
  7187. }
  7188. else
  7189. {
  7190. currentOffer = ((ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent>ShmSysConfigAndInfo->SysConfig.RatingCurrent)?ShmSysConfigAndInfo->SysConfig.RatingCurrent:ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
  7191. }
  7192. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = currentOffer;
  7193. }
  7194. }
  7195. }
  7196. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].context, ReadingContextEnumTypeStr[dataType]);
  7197. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]);
  7198. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7199. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.uint , "A");
  7200. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.multiplier = 0;
  7201. }
  7202. //***********************************************(12)Power.Offered******************************************************/
  7203. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
  7204. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
  7205. (dataType == ReadingContextEnumType_Trigger))
  7206. {
  7207. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7208. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7209. {
  7210. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7211. {
  7212. tempIndex = ((gun_index==2) ? 1: 0);
  7213. }
  7214. else
  7215. {
  7216. tempIndex = gun_index;
  7217. }
  7218. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7219. {
  7220. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7221. {
  7222. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].AvailableChargingPower*10);
  7223. }
  7224. } // END OF FOR
  7225. }
  7226. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7227. {
  7228. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7229. {
  7230. tempIndex = ((gun_index==2) ? 1: 0);
  7231. }
  7232. else
  7233. {
  7234. tempIndex = gun_index;
  7235. }
  7236. for (int index = 0; index < CCS_QUANTITY; index++)
  7237. {
  7238. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7239. {
  7240. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].AvailableChargingPower*10);
  7241. }
  7242. }
  7243. }
  7244. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7245. {
  7246. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7247. {
  7248. tempIndex = ((gun_index==2) ? 1: 0);
  7249. }
  7250. else
  7251. {
  7252. tempIndex = gun_index;
  7253. }
  7254. for (int index = 0; index < GB_QUANTITY; index++)
  7255. {
  7256. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7257. {
  7258. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7259. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].AvailableChargingPower*10);
  7260. }
  7261. }
  7262. }
  7263. else if(gunType[gun_index] == GUN_TYPE_DO)
  7264. {
  7265. tempIndex = gun_index;
  7266. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7267. {
  7268. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7269. {
  7270. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7271. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.AvailableChargingPower*10);
  7272. }
  7273. }
  7274. }
  7275. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].context, ReadingContextEnumTypeStr[dataType]);
  7276. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]);
  7277. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7278. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.uint , "W");
  7279. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.multiplier = 0;
  7280. }
  7281. // Message create ====================================================================================================
  7282. random_uuid(guid);
  7283. for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
  7284. {
  7285. json_object *meterValue = json_object_new_object();
  7286. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7287. {
  7288. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  7289. {
  7290. json_object *sampledValue = json_object_new_object();
  7291. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7292. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7293. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7294. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  7295. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7296. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  7297. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7298. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  7299. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7300. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  7301. {
  7302. json_object *unitOfMeasure = json_object_new_object();
  7303. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7304. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7305. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7306. }
  7307. json_object_array_add(sampledValues, sampledValue);
  7308. }
  7309. }
  7310. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  7311. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7312. json_object_array_add(meterValues, meterValue);
  7313. idxMeter++;
  7314. }
  7315. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  7316. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  7317. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  7318. ,gun_index + 1
  7319. ,MESSAGE_TYPE_CALL
  7320. ,guid
  7321. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  7322. json_object_put(MeterValueReq);
  7323. if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]) == 0) ||
  7324. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]) == 0) ||
  7325. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]) == 0))
  7326. {
  7327. // Transaction meter value send by TransactionEvent message
  7328. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  7329. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  7330. result = PASS;
  7331. }
  7332. else
  7333. {
  7334. // Put request guid to hash map
  7335. sprintf(tempdata, "MeterValues,%d", (gun_index));
  7336. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7337. {
  7338. result = PASS;
  7339. }
  7340. if((dataType != ReadingContextEnumType_Trigger) &&
  7341. (dataType != ReadingContextEnumType_Sample_Clock))
  7342. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  7343. else
  7344. {
  7345. if(FirstHeartBeat)
  7346. LWS_Send(queuedata +2);
  7347. }
  7348. }
  7349. return result;
  7350. }
  7351. int sendNotifyChargingLimitRequest(int gun_index)
  7352. {
  7353. mtrace();
  7354. int result = FAIL;
  7355. char message[4096]={0};
  7356. char guid[37]={0};
  7357. char tempdata[128]={0};
  7358. json_object *NotifyChargingLimit = json_object_new_object();
  7359. json_object *chargingLimit = json_object_new_object();
  7360. DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
  7361. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  7362. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  7363. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  7364. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  7365. random_uuid(guid);
  7366. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  7367. json_object_put(NotifyChargingLimit);
  7368. LWS_Send(message);
  7369. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  7370. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7371. {
  7372. result = PASS;
  7373. }
  7374. return result;
  7375. }
  7376. int sendNotifyCustomerInformationRequest()
  7377. {
  7378. mtrace();
  7379. int result = FAIL;
  7380. char message[4096]={0};
  7381. char guid[37]={0};
  7382. char tempdata[128]={0};
  7383. json_object *NotifyCustomerInformation = json_object_new_object();
  7384. DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
  7385. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  7386. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  7387. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  7388. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  7389. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  7390. random_uuid(guid);
  7391. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  7392. json_object_put(NotifyCustomerInformation);
  7393. LWS_Send(message);
  7394. sprintf(tempdata, "NotifyCustomerInformation,0");
  7395. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7396. {
  7397. result = PASS;
  7398. }
  7399. return result;
  7400. }
  7401. int sendNotifyDisplayMessagesRequest()
  7402. {
  7403. mtrace();
  7404. int result = FAIL;
  7405. char message[4096]={0};
  7406. char guid[37]={0};
  7407. char tempdata[128]={0};
  7408. json_object *NotifyDisplayMessages = json_object_new_object();
  7409. json_object *messageInfos = json_object_new_array();
  7410. DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
  7411. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  7412. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  7413. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  7414. {
  7415. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  7416. {
  7417. json_object *messageInfo = json_object_new_object();
  7418. json_object *message = json_object_new_object();
  7419. json_object *display = json_object_new_object();
  7420. json_object *evse = json_object_new_object();
  7421. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  7422. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  7423. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  7424. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  7425. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  7426. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  7427. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  7428. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  7429. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  7430. json_object_object_add(messageInfo, "message", message);
  7431. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  7432. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  7433. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  7434. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  7435. json_object_object_add(display, "evse",evse);
  7436. json_object_object_add(messageInfo, "evse", display);
  7437. json_object_array_add(messageInfos, messageInfo);
  7438. }
  7439. }
  7440. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  7441. random_uuid(guid);
  7442. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7443. json_object_put(NotifyDisplayMessages);
  7444. LWS_Send(message);
  7445. sprintf(tempdata, "NotifyDisplayMessages,0");
  7446. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7447. {
  7448. result = PASS;
  7449. }
  7450. return result;
  7451. }
  7452. int sendNotifyEVChargingNeedsRequest(int gun_index)
  7453. {
  7454. mtrace();
  7455. int result = FAIL;
  7456. char message[4096]={0};
  7457. char guid[37]={0};
  7458. char tempdata[128]={0};
  7459. json_object *NotifyEVChargingNeeds = json_object_new_object();
  7460. json_object *chargingNeeds = json_object_new_object();
  7461. json_object *acChargingParameters = json_object_new_object();
  7462. json_object *dcChargingParameters = json_object_new_object();
  7463. DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
  7464. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  7465. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  7466. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  7467. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  7468. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  7469. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  7470. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  7471. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  7472. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  7473. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  7474. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  7475. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  7476. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  7477. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  7478. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  7479. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  7480. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  7481. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  7482. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  7483. random_uuid(guid);
  7484. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  7485. json_object_put(NotifyEVChargingNeeds);
  7486. LWS_Send(message);
  7487. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  7488. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7489. {
  7490. result = PASS;
  7491. }
  7492. return result;
  7493. }
  7494. int sendNotifyEVChargingScheduleRequest(int gun_index)
  7495. {
  7496. mtrace();
  7497. int result = FAIL;
  7498. char message[4096]={0};
  7499. char guid[37]={0};
  7500. char tempdata[128]={0};
  7501. json_object *NotifyEVChargingSchedule = json_object_new_object();
  7502. json_object *chargingSchedule = json_object_new_object();
  7503. json_object *periods = json_object_new_array();
  7504. DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
  7505. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  7506. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  7507. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  7508. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  7509. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  7510. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  7511. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  7512. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7513. {
  7514. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7515. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7516. {
  7517. json_object *Period = json_object_new_object();
  7518. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7519. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7520. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7521. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7522. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7523. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7524. json_object_array_add(periods, Period);
  7525. }
  7526. }
  7527. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  7528. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  7529. random_uuid(guid);
  7530. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  7531. json_object_put(NotifyEVChargingSchedule);
  7532. LWS_Send(message);
  7533. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  7534. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7535. {
  7536. result = PASS;
  7537. }
  7538. return result;
  7539. }
  7540. int sendNotifyEventRequest()
  7541. {
  7542. mtrace();
  7543. int result = FAIL;
  7544. char message[4096]={0};
  7545. char guid[37]={0};
  7546. char tempdata[128]={0};
  7547. json_object *NotifyEvent = json_object_new_object();
  7548. json_object *eventDatas = json_object_new_array();
  7549. DEBUG_INFO("sendNotifyEventRequest...\n");
  7550. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  7551. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  7552. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  7553. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  7554. {
  7555. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  7556. {
  7557. json_object *eventData = json_object_new_object();
  7558. json_object *component = json_object_new_object();
  7559. json_object *evse = json_object_new_object();
  7560. json_object *variable = json_object_new_object();
  7561. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  7562. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  7563. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  7564. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  7565. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  7566. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  7567. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  7568. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  7569. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  7570. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  7571. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  7572. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  7573. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  7574. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  7575. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  7576. json_object_object_add(component, "evse",evse);
  7577. json_object_object_add(eventData, "component", component);
  7578. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  7579. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  7580. json_object_object_add(eventData, "variable", variable);
  7581. json_object_array_add(eventDatas, eventData);
  7582. }
  7583. }
  7584. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  7585. random_uuid(guid);
  7586. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  7587. json_object_put(NotifyEvent);
  7588. LWS_Send(message);
  7589. sprintf(tempdata, "NotifyEvent,0");
  7590. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7591. {
  7592. result = PASS;
  7593. }
  7594. return result;
  7595. }
  7596. int sendNotifyMonitoringReportRequest()
  7597. {
  7598. mtrace();
  7599. int result = FAIL;
  7600. char message[4096]={0};
  7601. char guid[37]={0};
  7602. char tempdata[128]={0};
  7603. json_object *NotifyMonitoringReport = json_object_new_object();
  7604. json_object *monitors = json_object_new_array();
  7605. DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
  7606. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  7607. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  7608. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  7609. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  7610. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  7611. {
  7612. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  7613. {
  7614. json_object *monitor = json_object_new_object();
  7615. json_object *component = json_object_new_object();
  7616. json_object *evse = json_object_new_object();
  7617. json_object *variable = json_object_new_object();
  7618. json_object *variableMonitorings = json_object_new_array();
  7619. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  7620. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  7621. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  7622. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  7623. json_object_object_add(component, "evse",evse);
  7624. json_object_object_add(monitor, "component", component);
  7625. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  7626. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  7627. json_object_object_add(monitor, "variable", variable);
  7628. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  7629. {
  7630. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  7631. {
  7632. json_object *variableMonitoring = json_object_new_object();
  7633. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  7634. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  7635. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  7636. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  7637. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  7638. json_object_array_add(variableMonitorings, variableMonitoring);
  7639. }
  7640. }
  7641. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  7642. json_object_array_add(monitors, monitor);
  7643. }
  7644. }
  7645. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  7646. random_uuid(guid);
  7647. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  7648. json_object_put(NotifyMonitoringReport);
  7649. LWS_Send(message);
  7650. sprintf(tempdata, "NotifyMonitoringReport,0");
  7651. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7652. {
  7653. result = PASS;
  7654. }
  7655. return result;
  7656. }
  7657. int sendNotifyReportRequest()
  7658. {
  7659. mtrace();
  7660. int result = FAIL;
  7661. char message[4096]={0};
  7662. char guid[37]={0};
  7663. char tempdata[128]={0};
  7664. json_object *NotifyReport = json_object_new_object();
  7665. json_object *reportDatas = json_object_new_array();
  7666. DEBUG_INFO("sendNotifyReportRequest...\n");
  7667. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  7668. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  7669. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  7670. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  7671. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  7672. {
  7673. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  7674. {
  7675. json_object *reportData = json_object_new_object();
  7676. json_object *component = json_object_new_object();
  7677. json_object *evse = json_object_new_object();
  7678. json_object *variable = json_object_new_object();
  7679. json_object *variableAttributes = json_object_new_array();
  7680. json_object *variableCharacteristics = json_object_new_object();
  7681. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  7682. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  7683. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  7684. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  7685. json_object_object_add(component, "evse",evse);
  7686. json_object_object_add(reportData, "component", component);
  7687. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  7688. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  7689. json_object_object_add(reportData, "variable",variable);
  7690. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  7691. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  7692. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  7693. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  7694. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  7695. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  7696. {
  7697. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  7698. {
  7699. json_object *variableAttribute = json_object_new_object();
  7700. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  7701. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  7702. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  7703. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  7704. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  7705. json_object_array_add(variableAttributes, variableAttribute);
  7706. }
  7707. }
  7708. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  7709. json_object_array_add(reportDatas, reportData);
  7710. }
  7711. }
  7712. json_object_object_add(NotifyReport, "reportData", reportDatas);
  7713. random_uuid(guid);
  7714. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  7715. json_object_put(NotifyReport);
  7716. LWS_SendNow(message);
  7717. sprintf(tempdata, "NotifyReport,0");
  7718. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7719. {
  7720. result = PASS;
  7721. }
  7722. return result;
  7723. }
  7724. int sendPublishFirmwareStatusNotificationRequest()
  7725. {
  7726. mtrace();
  7727. int result = FAIL;
  7728. char message[4096]={0};
  7729. char guid[37]={0};
  7730. char tempdata[128]={0};
  7731. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  7732. json_object *locations = json_object_new_array();
  7733. DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
  7734. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  7735. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  7736. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  7737. {
  7738. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  7739. }
  7740. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  7741. random_uuid(guid);
  7742. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  7743. json_object_put(PublishFirmwareStatusNotification);
  7744. LWS_Send(message);
  7745. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  7746. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7747. {
  7748. result = PASS;
  7749. }
  7750. return result;
  7751. }
  7752. int sendReportChargingProfilesRequest(int gun_index)
  7753. {
  7754. mtrace();
  7755. int result = FAIL;
  7756. char message[4096]={0};
  7757. char guid[37]={0};
  7758. char tempdata[128]={0};
  7759. json_object *ReportChargingProfiles = json_object_new_object();
  7760. json_object *chargingProfiles = json_object_new_array();
  7761. DEBUG_INFO("sendReportChargingProfilesRequest...\n");
  7762. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  7763. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  7764. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  7765. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  7766. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  7767. {
  7768. json_object *chargingProfile = json_object_new_object();
  7769. json_object *chargingSchedules = json_object_new_array();
  7770. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  7771. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  7772. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  7773. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  7774. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  7775. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  7776. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  7777. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  7778. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  7779. {
  7780. json_object *chargingSchedule = json_object_new_object();
  7781. json_object *chargingSchedulePeriods = json_object_new_array();
  7782. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  7783. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  7784. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  7785. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  7786. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  7787. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  7788. {
  7789. json_object *chargingSchedulePeriod = json_object_new_object();
  7790. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  7791. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  7792. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  7793. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  7794. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  7795. }
  7796. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  7797. json_object_array_add(chargingSchedules, chargingSchedule);
  7798. }
  7799. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  7800. json_object_array_add(chargingProfiles, chargingProfile);
  7801. }
  7802. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  7803. random_uuid(guid);
  7804. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  7805. json_object_put(ReportChargingProfiles);
  7806. LWS_Send(message);
  7807. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  7808. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7809. {
  7810. result = PASS;
  7811. }
  7812. return result;
  7813. }
  7814. int sendReservationStatusUpdateRequest(int gun_index)
  7815. {
  7816. mtrace();
  7817. int result = FAIL;
  7818. char message[4096]={0};
  7819. char guid[37]={0};
  7820. char tempdata[128]={0};
  7821. json_object *ReservationStatusUpdate = json_object_new_object();
  7822. DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
  7823. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  7824. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  7825. random_uuid(guid);
  7826. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  7827. json_object_put(ReservationStatusUpdate);
  7828. LWS_Send(message);
  7829. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  7830. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7831. {
  7832. result = PASS;
  7833. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  7834. }
  7835. return result;
  7836. }
  7837. int sendSecurityEventNotificationRequest()
  7838. {
  7839. mtrace();
  7840. int result = FAIL;
  7841. char message[4096]={0};
  7842. char guid[37]={0};
  7843. char tempdata[128]={0};
  7844. json_object *SecurityEventNotification = json_object_new_object();
  7845. DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
  7846. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  7847. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  7848. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techInfo));
  7849. random_uuid(guid);
  7850. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  7851. json_object_put(SecurityEventNotification);
  7852. LWS_Send(message);
  7853. sprintf(tempdata, "SecurityEventNotification,0");
  7854. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7855. {
  7856. result = PASS;
  7857. }
  7858. return result;
  7859. }
  7860. int sendSignCertificateRequest(CertificateSigningUseEnumType certType)
  7861. {
  7862. mtrace();
  7863. int result = FAIL;
  7864. char message[4096]={0};
  7865. char guid[37]={0};
  7866. char tempdata[128]={0};
  7867. json_object *SignCertificate = json_object_new_object();
  7868. DEBUG_INFO("sendSignCertificateRequest...\n");
  7869. // Read csr file content
  7870. memset(ShmOCPP20Data->SignCertificate.csr, 0x00, ARRAY_SIZE(ShmOCPP20Data->SignCertificate.csr));
  7871. FILE *fp=fopen(((certType == CertificateSignedStatusEnumType_V2GCertificate)?"/Storage/OCPP/certV2G.csr":"/Storage/OCPP/certCP.csr"),"r");
  7872. char *line = NULL;
  7873. size_t len = 0;
  7874. while(getline(&line, &len, fp) != -1)
  7875. {
  7876. if((strstr(line, "BEGIN CERTIFICATE REQUEST") == NULL) && (strstr(line, "END CERTIFICATE REQUEST") == NULL))
  7877. {
  7878. memcpy(&ShmOCPP20Data->SignCertificate.csr[strlen((char*)ShmOCPP20Data->SignCertificate.csr)], line, (strlen(line)-1));
  7879. }
  7880. }
  7881. fclose(fp);
  7882. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  7883. sprintf((char*)ShmOCPP20Data->SignCertificate.certificateType, CertificateSigningUseEnumTypeStr[certType]);
  7884. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  7885. random_uuid(guid);
  7886. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  7887. json_object_put(SignCertificate);
  7888. LWS_Send(message);
  7889. sprintf(tempdata, "SignCertificate,0");
  7890. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7891. {
  7892. result = PASS;
  7893. }
  7894. return result;
  7895. }
  7896. int sendStatusNotificationRequest(int gun_index)
  7897. {
  7898. mtrace();
  7899. int result = FAIL;
  7900. char message[600]={0};
  7901. char guid[37];
  7902. int currentStatus = 0;
  7903. struct timeval tmnow;
  7904. struct tm *tm;
  7905. char buf[28];//, usec_buf[6];
  7906. char tempdata[65]={0};
  7907. int tempIndex = 0;
  7908. uint8_t isStateChanged = TRUE;
  7909. DEBUG_INFO("sendStatusNotificationRequest...\n");
  7910. gettimeofday(&tmnow, NULL);
  7911. time_t t;
  7912. t = time(NULL);
  7913. /*UTC time and date*/
  7914. tm = gmtime(&t);
  7915. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  7916. #if 0 // remove temporally
  7917. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  7918. strcat(buf,".");
  7919. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  7920. strcat(buf,usec_buf);
  7921. #endif
  7922. printf("%s",buf);
  7923. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  7924. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  7925. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  7926. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  7927. /*
  7928. enum _SYSTEM_STATUS
  7929. {
  7930. S_BOOTING = 0,
  7931. S_IDLE, = 1
  7932. S_AUTHORIZING, =2
  7933. S_REASSIGN_CHECK, =3
  7934. S_REASSIGN, =4
  7935. S_PRECHARGE, =5
  7936. S_PREPARING_FOR_EV, =6
  7937. S_PREPARING_FOR_EVSE, =7
  7938. S_CHARGING, =8
  7939. S_TERMINATING, =9
  7940. S_COMPLETE, =10
  7941. S_ALARM, =11
  7942. S_FAULT =12
  7943. }
  7944. */
  7945. //check Transaction active
  7946. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  7947. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7948. {
  7949. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7950. {
  7951. tempIndex = ((gun_index==2) ? 1: 0);
  7952. }
  7953. else
  7954. {
  7955. tempIndex = gun_index;
  7956. }
  7957. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7958. {
  7959. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  7960. {
  7961. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  7962. {
  7963. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7964. {
  7965. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  7966. }
  7967. else
  7968. {
  7969. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  7970. }
  7971. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7972. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7973. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  7974. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  7975. }
  7976. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7977. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7978. ) //S_PRECHARGE
  7979. {
  7980. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  7981. }
  7982. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7983. {
  7984. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  7985. }
  7986. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7987. {
  7988. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  7989. }
  7990. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7991. {
  7992. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  7993. }
  7994. 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
  7995. {
  7996. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  7997. }
  7998. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7999. {
  8000. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8001. }
  8002. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8003. {
  8004. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8005. }
  8006. } //end of the same index
  8007. }//end of for CHAdeMO_QUANTITY
  8008. }
  8009. else if(gunType[gun_index] == GUN_TYPE_CCS)
  8010. {
  8011. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8012. {
  8013. tempIndex = ((gun_index==2) ? 1: 0);
  8014. }
  8015. else
  8016. {
  8017. tempIndex = gun_index;
  8018. }
  8019. for (int index = 0; index < CCS_QUANTITY; index++)
  8020. {
  8021. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  8022. {
  8023. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8024. {
  8025. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  8026. {
  8027. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8028. }
  8029. else
  8030. {
  8031. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8032. }
  8033. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8034. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8035. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8036. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8037. }
  8038. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8039. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8040. ) //S_PRECHARGE
  8041. {
  8042. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8043. }
  8044. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8045. {
  8046. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8047. }
  8048. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8049. {
  8050. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8051. }
  8052. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  8053. {
  8054. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8055. }
  8056. 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
  8057. {
  8058. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  8059. }
  8060. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  8061. {
  8062. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8063. }
  8064. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8065. {
  8066. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8067. }
  8068. } //end of the same index
  8069. } // end of for CCS_QUANTITY
  8070. }
  8071. else if(gunType[gun_index] == GUN_TYPE_GBT)
  8072. {
  8073. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8074. {
  8075. tempIndex = ((gun_index==2) ? 1: 0);
  8076. }
  8077. else
  8078. {
  8079. tempIndex = gun_index;
  8080. }
  8081. for (int index = 0; index < GB_QUANTITY; index++)
  8082. {
  8083. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  8084. {
  8085. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8086. {
  8087. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8088. {
  8089. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8090. }
  8091. else
  8092. {
  8093. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8094. }
  8095. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8096. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8097. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8098. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8099. }
  8100. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8101. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8102. ) //S_PRECHARGE
  8103. {
  8104. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8105. }
  8106. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8107. {
  8108. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8109. }
  8110. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8111. {
  8112. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8113. }
  8114. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8115. {
  8116. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8117. }
  8118. 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
  8119. {
  8120. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8121. }
  8122. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  8123. {
  8124. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8125. }
  8126. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8127. {
  8128. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8129. }
  8130. } //end of the same index
  8131. } // end of for GB_QUANTITY
  8132. }
  8133. else if(gunType[gun_index] == GUN_TYPE_DO)
  8134. {
  8135. tempIndex = gun_index;
  8136. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8137. {
  8138. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  8139. {
  8140. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8141. {
  8142. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8143. {
  8144. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8145. }
  8146. else
  8147. {
  8148. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8149. }
  8150. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8151. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8152. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8153. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8154. }
  8155. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8156. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8157. ) //S_PRECHARGE
  8158. {
  8159. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8160. }
  8161. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8162. {
  8163. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8164. }
  8165. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8166. {
  8167. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8168. }
  8169. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8170. {
  8171. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8172. }
  8173. 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
  8174. {
  8175. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8176. }
  8177. 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
  8178. {
  8179. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8180. }
  8181. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8182. {
  8183. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8184. }
  8185. } //end of the same index
  8186. }
  8187. }
  8188. else
  8189. {
  8190. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8191. {
  8192. tempIndex = 2;
  8193. }
  8194. else
  8195. {
  8196. tempIndex = gun_index;
  8197. }
  8198. for (int index = 0; index < AC_QUANTITY; index++)
  8199. {
  8200. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  8201. {
  8202. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  8203. {
  8204. 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))
  8205. {
  8206. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8207. }
  8208. else
  8209. {
  8210. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8211. }
  8212. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8213. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8214. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8215. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8216. }
  8217. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  8218. {
  8219. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8220. }
  8221. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  8222. {
  8223. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8224. }
  8225. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  8226. {
  8227. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8228. }
  8229. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8230. {
  8231. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8232. }
  8233. 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
  8234. {
  8235. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8236. }
  8237. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8238. {
  8239. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8240. }
  8241. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8242. {
  8243. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8244. }
  8245. }//end of the same index
  8246. }//end of for AC_QUANTITY
  8247. }
  8248. //it's option
  8249. if((strstr((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]) != NULL) &&
  8250. !cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq)
  8251. {
  8252. isStateChanged = FALSE;
  8253. }
  8254. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  8255. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  8256. random_uuid(guid);
  8257. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  8258. , MESSAGE_TYPE_CALL
  8259. , guid
  8260. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  8261. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  8262. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  8263. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  8264. if((server_sign == TRUE) && isStateChanged)
  8265. {
  8266. LWS_Send(message);
  8267. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  8268. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8269. {
  8270. result = PASS;
  8271. }
  8272. }
  8273. else
  8274. {
  8275. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  8276. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  8277. result = PASS;
  8278. }
  8279. return result;
  8280. }
  8281. int sendTransactionEventRequest(int gun_index)
  8282. {
  8283. mtrace();
  8284. int result = FAIL;
  8285. char message[1024*20]={0};
  8286. char guid[37]={0};
  8287. char tempdata[128]={0};
  8288. uint8_t tempIndex;
  8289. json_object *TransactionEvent = json_object_new_object();
  8290. json_object *transactionInfo = json_object_new_object();
  8291. json_object *idToken = json_object_new_object();
  8292. json_object *evse = json_object_new_object();
  8293. json_object *meterValues = json_object_new_array();
  8294. char TempStopTransaction[256];
  8295. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  8296. DEBUG_INFO("sendTransactionEventRequest...\n");
  8297. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  8298. {
  8299. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8300. {
  8301. tempIndex = ((gun_index==2) ? 1: 0);
  8302. }
  8303. else
  8304. {
  8305. tempIndex = gun_index;
  8306. }
  8307. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8308. {
  8309. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  8310. {
  8311. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8312. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8313. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8314. else
  8315. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8316. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8317. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8318. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8319. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  8320. {
  8321. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8322. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8323. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8324. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8325. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8326. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8327. {
  8328. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8329. }
  8330. else
  8331. {
  8332. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8333. }
  8334. }
  8335. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8336. {
  8337. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8338. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8339. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8340. }
  8341. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8342. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8343. ) //S_PRECHARGE
  8344. {
  8345. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8346. {
  8347. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8348. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  8349. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  8350. storeTempStopTransaction(gun_index);
  8351. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8352. }
  8353. else
  8354. {
  8355. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8356. }
  8357. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8358. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8359. }
  8360. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8361. {
  8362. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8363. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8364. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8365. }
  8366. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8367. {
  8368. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8369. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8370. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8371. if((access(TempStopTransaction,F_OK))!=-1)
  8372. {
  8373. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8374. }
  8375. }
  8376. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8377. {
  8378. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8379. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8380. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8381. }
  8382. 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
  8383. {
  8384. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8385. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8386. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8387. }
  8388. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8389. {
  8390. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8391. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8392. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8393. }
  8394. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8395. {
  8396. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8397. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8398. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8399. }
  8400. } //end of the same index
  8401. }//end of for CHAdeMO_QUANTITY
  8402. }
  8403. else if(gunType[gun_index] == GUN_TYPE_CCS)
  8404. {
  8405. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8406. {
  8407. tempIndex = ((gun_index==2) ? 1: 0);
  8408. }
  8409. else
  8410. {
  8411. tempIndex = gun_index;
  8412. }
  8413. for (int index = 0; index < CCS_QUANTITY; index++)
  8414. {
  8415. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  8416. {
  8417. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8418. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8419. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8420. else
  8421. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8422. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8423. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8424. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8425. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8426. {
  8427. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8428. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8429. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8430. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8431. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8432. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  8433. {
  8434. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8435. }
  8436. else
  8437. {
  8438. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8439. }
  8440. }
  8441. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8442. {
  8443. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8444. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8445. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8446. }
  8447. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8448. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8449. ) //S_PRECHARGE
  8450. {
  8451. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8452. {
  8453. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8454. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  8455. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  8456. storeTempStopTransaction(gun_index);
  8457. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8458. }
  8459. else
  8460. {
  8461. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8462. }
  8463. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8464. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8465. }
  8466. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8467. {
  8468. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8469. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8470. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8471. }
  8472. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8473. {
  8474. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8475. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8476. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8477. if((access(TempStopTransaction,F_OK))!=-1)
  8478. {
  8479. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8480. }
  8481. }
  8482. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8483. {
  8484. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8485. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8486. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8487. }
  8488. 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
  8489. {
  8490. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8491. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8492. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8493. }
  8494. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8495. {
  8496. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8497. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8498. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8499. }
  8500. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8501. {
  8502. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8503. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8504. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8505. }
  8506. } //end of the same index
  8507. } // end of for CCS_QUANTITY
  8508. }
  8509. else if(gunType[gun_index] == GUN_TYPE_GBT)
  8510. {
  8511. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8512. {
  8513. tempIndex = ((gun_index==2) ? 1: 0);
  8514. }
  8515. else
  8516. {
  8517. tempIndex = gun_index;
  8518. }
  8519. for (int index = 0; index < GB_QUANTITY; index++)
  8520. {
  8521. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  8522. {
  8523. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8524. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8525. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8526. else
  8527. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8528. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8529. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8530. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8531. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8532. {
  8533. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8534. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8535. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8536. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8537. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8538. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  8539. {
  8540. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8541. }
  8542. else
  8543. {
  8544. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8545. }
  8546. }
  8547. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8548. {
  8549. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8550. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8551. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8552. }
  8553. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8554. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8555. ) //S_PRECHARGE
  8556. {
  8557. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8558. {
  8559. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8560. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  8561. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  8562. storeTempStopTransaction(gun_index);
  8563. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8564. }
  8565. else
  8566. {
  8567. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8568. }
  8569. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8570. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8571. }
  8572. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8573. {
  8574. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8575. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8576. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8577. }
  8578. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8579. {
  8580. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8581. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8582. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8583. if((access(TempStopTransaction,F_OK))!=-1)
  8584. {
  8585. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8586. }
  8587. }
  8588. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8589. {
  8590. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8591. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8592. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8593. }
  8594. 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
  8595. {
  8596. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8597. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8598. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8599. }
  8600. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8601. {
  8602. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8603. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8604. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8605. }
  8606. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8607. {
  8608. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8609. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8610. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8611. }
  8612. } //end of the same index
  8613. } // end of for GB_QUANTITY
  8614. }
  8615. else if(gunType[gun_index] == GUN_TYPE_DO)
  8616. {
  8617. tempIndex = gun_index;
  8618. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8619. {
  8620. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  8621. {
  8622. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8623. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8624. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8625. else
  8626. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8627. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8628. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8629. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8630. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8631. {
  8632. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8633. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8634. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8635. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8636. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8637. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8638. {
  8639. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8640. }
  8641. else
  8642. {
  8643. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8644. }
  8645. }
  8646. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8647. {
  8648. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8649. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8650. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8651. }
  8652. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8653. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8654. ) //S_PRECHARGE
  8655. {
  8656. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8657. {
  8658. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8659. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  8660. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  8661. storeTempStopTransaction(gun_index);
  8662. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8663. }
  8664. else
  8665. {
  8666. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8667. }
  8668. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8669. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8670. }
  8671. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8672. {
  8673. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8674. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8675. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8676. }
  8677. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8678. {
  8679. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8680. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8681. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8682. if((access(TempStopTransaction,F_OK))!=-1)
  8683. {
  8684. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8685. }
  8686. }
  8687. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8688. {
  8689. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8690. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8691. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8692. }
  8693. 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
  8694. {
  8695. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8696. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8697. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8698. }
  8699. 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
  8700. {
  8701. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8702. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8703. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8704. }
  8705. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8706. {
  8707. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8708. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8709. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8710. }
  8711. } //end of the same index
  8712. }
  8713. }
  8714. else
  8715. {
  8716. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8717. {
  8718. tempIndex = 2;
  8719. }
  8720. else
  8721. {
  8722. tempIndex = gun_index;
  8723. }
  8724. for (int index = 0; index < AC_QUANTITY; index++)
  8725. {
  8726. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  8727. {
  8728. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  8729. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  8730. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  8731. else
  8732. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  8733. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  8734. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  8735. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  8736. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  8737. {
  8738. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8739. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8740. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8741. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8742. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8743. 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))
  8744. {
  8745. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  8746. }
  8747. else
  8748. {
  8749. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  8750. }
  8751. }
  8752. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  8753. {
  8754. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8755. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  8756. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  8757. }
  8758. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8759. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8760. ) //S_PRECHARGE
  8761. {
  8762. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  8763. {
  8764. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  8765. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  8766. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  8767. storeTempStopTransaction(gun_index);
  8768. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8769. }
  8770. else
  8771. {
  8772. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8773. }
  8774. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  8775. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8776. }
  8777. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8778. {
  8779. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8780. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8781. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8782. }
  8783. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8784. {
  8785. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  8786. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  8787. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8788. if((access(TempStopTransaction,F_OK))!=-1)
  8789. {
  8790. remove(TempStopTransaction); // remove file "TempStopTransaction"
  8791. }
  8792. }
  8793. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8794. {
  8795. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8796. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  8797. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  8798. }
  8799. 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
  8800. {
  8801. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8802. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8803. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8804. }
  8805. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8806. {
  8807. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  8808. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8809. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8810. }
  8811. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8812. {
  8813. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  8814. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  8815. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  8816. }
  8817. }//end of the same index
  8818. }//end of for AC_QUANTITY
  8819. }
  8820. // Message
  8821. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8822. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  8823. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  8824. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  8825. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  8826. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  8827. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  8828. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  8829. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  8830. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  8831. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  8832. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  8833. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  8834. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  8835. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  8836. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  8837. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  8838. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  8839. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  8840. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  8841. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  8842. {
  8843. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  8844. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  8845. json_object_object_add(TransactionEvent, "idToken", idToken);
  8846. }
  8847. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  8848. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  8849. json_object_object_add(TransactionEvent, "evse", evse);
  8850. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  8851. {
  8852. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  8853. {
  8854. json_object *meterValue = json_object_new_object();
  8855. json_object *sampledValues = json_object_new_array();
  8856. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  8857. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  8858. {
  8859. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  8860. ((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)))
  8861. {
  8862. json_object *sampledValue = json_object_new_object();
  8863. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  8864. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  8865. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  8866. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  8867. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  8868. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  8869. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  8870. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  8871. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  8872. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  8873. {
  8874. json_object *unitOfMeasure = json_object_new_object();
  8875. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  8876. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  8877. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  8878. }
  8879. json_object_array_add(sampledValues, sampledValue);
  8880. }
  8881. }
  8882. json_object_object_add(meterValue, "sampledValue", sampledValues);
  8883. json_object_array_add(meterValues, meterValue);
  8884. }
  8885. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  8886. }
  8887. random_uuid(guid);
  8888. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  8889. json_object_put(TransactionEvent);
  8890. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  8891. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8892. {
  8893. result = PASS;
  8894. }
  8895. queue_operation(QUEUE_OPERATION_ADD, guid, message);
  8896. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Started]) != NULL)
  8897. OCPP_insert_transaction_msg(YES, message);
  8898. else if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL)
  8899. OCPP_insert_transaction_msg(NO, message);
  8900. return result;
  8901. }
  8902. //==========================================
  8903. // send confirm routine
  8904. //==========================================
  8905. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  8906. {
  8907. mtrace();
  8908. int result = FAIL;
  8909. char message[4096]={0};
  8910. json_object *CancelReservation = json_object_new_object();
  8911. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  8912. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  8913. sprintf(message,"[%d,\"%s\",%s]"
  8914. ,MESSAGE_TYPE_CALLRESULT
  8915. ,uuid
  8916. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  8917. json_object_put(CancelReservation);
  8918. ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf = OFF;
  8919. LWS_Send(message);
  8920. result = TRUE;
  8921. return result;
  8922. }
  8923. int sendCertificateSignedConfirmation(char *uuid)
  8924. {
  8925. mtrace();
  8926. int result = FAIL;
  8927. char message[4096]={0};
  8928. json_object *CertificateSigned = json_object_new_object();
  8929. json_object *statusInfo = json_object_new_object();
  8930. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  8931. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  8932. if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode) > 0)
  8933. {
  8934. json_object_object_add(statusInfo, "reasonCode", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode));
  8935. if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo) > 0)
  8936. json_object_object_add(statusInfo, "statadditionalInfous", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo));
  8937. }
  8938. json_object_object_add(CertificateSigned, "statusInfo", statusInfo);
  8939. sprintf(message,"[%d,\"%s\",%s]"
  8940. ,MESSAGE_TYPE_CALLRESULT
  8941. ,uuid
  8942. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  8943. json_object_put(CertificateSigned);
  8944. LWS_Send(message);
  8945. result = TRUE;
  8946. return result;
  8947. }
  8948. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  8949. {
  8950. mtrace();
  8951. int result = FAIL;
  8952. char message[4096]={0};
  8953. json_object *ChangeAvailability = json_object_new_object();
  8954. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  8955. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  8956. sprintf(message,"[%d,\"%s\",%s]"
  8957. ,MESSAGE_TYPE_CALLRESULT
  8958. ,uuid
  8959. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  8960. json_object_put(ChangeAvailability);
  8961. LWS_Send(message);
  8962. result = TRUE;
  8963. return result;
  8964. }
  8965. int sendClearCacheConfirmation(char *uuid)
  8966. {
  8967. mtrace();
  8968. int result = FAIL;
  8969. char message[4096]={0};
  8970. json_object *ClearCache = json_object_new_object();
  8971. DEBUG_INFO("sendClearCacheConfirmation...\n");
  8972. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  8973. sprintf(message,"[%d,\"%s\",%s]"
  8974. ,MESSAGE_TYPE_CALLRESULT
  8975. ,uuid
  8976. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  8977. json_object_put(ClearCache);
  8978. LWS_Send(message);
  8979. result = TRUE;
  8980. return result;
  8981. }
  8982. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  8983. {
  8984. mtrace();
  8985. int result = FAIL;
  8986. char message[500]={0};
  8987. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  8988. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  8989. LWS_Send(message);
  8990. return result;
  8991. }
  8992. int sendClearDisplayMessageConfirmation(char *uuid)
  8993. {
  8994. mtrace();
  8995. int result = FAIL;
  8996. char message[4096]={0};
  8997. json_object *ClearDisplayMessage = json_object_new_object();
  8998. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  8999. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  9000. sprintf(message,"[%d,\"%s\",%s]"
  9001. ,MESSAGE_TYPE_CALLRESULT
  9002. ,uuid
  9003. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  9004. json_object_put(ClearDisplayMessage);
  9005. LWS_Send(message);
  9006. result = TRUE;
  9007. return result;
  9008. }
  9009. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  9010. {
  9011. mtrace();
  9012. int result = FAIL;
  9013. char message[4096]={0};
  9014. json_object *ClearVariableMonitoring = json_object_new_object();
  9015. json_object *clearMonitoringResults = json_object_new_array();
  9016. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  9017. for(int idx=0;idx<variableQuantity;idx++)
  9018. {
  9019. json_object *clearMonitoringResult = json_object_new_object();
  9020. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  9021. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  9022. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  9023. }
  9024. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  9025. sprintf(message,"[%d,\"%s\",%s]"
  9026. ,MESSAGE_TYPE_CALLRESULT
  9027. ,uuid
  9028. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  9029. json_object_put(ClearVariableMonitoring);
  9030. LWS_Send(message);
  9031. result = TRUE;
  9032. return result;
  9033. }
  9034. int sendCostUpdatedConfirmation(char *uuid)
  9035. {
  9036. mtrace();
  9037. int result = FAIL;
  9038. char message[4096]={0};
  9039. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  9040. sprintf(message,"[%d,\"%s\",{}]"
  9041. ,MESSAGE_TYPE_CALLRESULT
  9042. ,uuid);
  9043. LWS_Send(message);
  9044. result = TRUE;
  9045. return result;
  9046. }
  9047. int sendCustomerInformationConfirmation(char *uuid)
  9048. {
  9049. mtrace();
  9050. int result = FAIL;
  9051. char message[4096]={0};
  9052. json_object *CustomerInformation = json_object_new_object();
  9053. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  9054. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  9055. sprintf(message,"[%d,\"%s\",%s]"
  9056. ,MESSAGE_TYPE_CALLRESULT
  9057. ,uuid
  9058. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  9059. json_object_put(CustomerInformation);
  9060. LWS_Send(message);
  9061. result = TRUE;
  9062. return result;
  9063. }
  9064. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  9065. {
  9066. mtrace();
  9067. int result = FAIL;
  9068. char message[4096]={0};
  9069. json_object *DataTransfer = json_object_new_object();
  9070. DEBUG_INFO("sendDataTransferConfirmation...\n");
  9071. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  9072. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  9073. sprintf(message,"[%d,\"%s\",%s]"
  9074. ,MESSAGE_TYPE_CALLRESULT
  9075. ,uuid
  9076. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  9077. json_object_put(DataTransfer);
  9078. LWS_Send(message);
  9079. result = TRUE;
  9080. return result;
  9081. }
  9082. int sendDeleteCertificateConfirmation(char *uuid)
  9083. {
  9084. mtrace();
  9085. int result = FAIL;
  9086. char message[4096]={0};
  9087. json_object *DeleteCertificate = json_object_new_object();
  9088. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  9089. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  9090. sprintf(message,"[%d,\"%s\",%s]"
  9091. ,MESSAGE_TYPE_CALLRESULT
  9092. ,uuid
  9093. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  9094. json_object_put(DeleteCertificate);
  9095. LWS_Send(message);
  9096. result = TRUE;
  9097. return result;
  9098. }
  9099. int sendGetBaseReportConfirmation(char *uuid)
  9100. {
  9101. mtrace();
  9102. int result = FAIL;
  9103. char message[4096]={0};
  9104. json_object *GetBaseReport = json_object_new_object();
  9105. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  9106. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  9107. sprintf(message,"[%d,\"%s\",%s]"
  9108. ,MESSAGE_TYPE_CALLRESULT
  9109. ,uuid
  9110. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  9111. json_object_put(GetBaseReport);
  9112. LWS_Send(message);
  9113. result = TRUE;
  9114. return result;
  9115. }
  9116. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  9117. {
  9118. mtrace();
  9119. int result = FAIL;
  9120. char message[4096]={0};
  9121. json_object *GetChargingProfiles = json_object_new_object();
  9122. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  9123. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  9124. sprintf(message,"[%d,\"%s\",%s]"
  9125. ,MESSAGE_TYPE_CALLRESULT
  9126. ,uuid
  9127. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  9128. json_object_put(GetChargingProfiles);
  9129. LWS_Send(message);
  9130. result = TRUE;
  9131. return result;
  9132. }
  9133. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  9134. {
  9135. mtrace();
  9136. int result = FAIL;
  9137. char message[4096]={0};
  9138. int CompositeScheduleIndex = 0;
  9139. json_object *GetCompositeSchedule = json_object_new_object();
  9140. json_object *schedule = json_object_new_object();
  9141. json_object *chargingSchedule = json_object_new_object();
  9142. json_object *chargingSchedulePeriod = json_object_new_array();
  9143. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  9144. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  9145. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  9146. if(nPeriod == 0)
  9147. {
  9148. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  9149. {
  9150. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  9151. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  9152. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  9153. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  9154. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  9155. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  9156. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  9157. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  9158. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  9159. {
  9160. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  9161. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  9162. {
  9163. json_object *Period = json_object_new_object();
  9164. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  9165. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  9166. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  9167. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  9168. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  9169. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  9170. json_object_array_add(chargingSchedulePeriod, Period);
  9171. }
  9172. }
  9173. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  9174. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  9175. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  9176. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  9177. }
  9178. }
  9179. else
  9180. {
  9181. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  9182. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  9183. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  9184. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  9185. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  9186. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  9187. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  9188. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  9189. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  9190. {
  9191. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  9192. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  9193. {
  9194. json_object *Period = json_object_new_object();
  9195. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  9196. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  9197. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  9198. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  9199. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  9200. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  9201. json_object_array_add(chargingSchedulePeriod, Period);
  9202. }
  9203. }
  9204. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  9205. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  9206. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  9207. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  9208. }
  9209. sprintf(message,"[%d,\"%s\",%s]"
  9210. ,MESSAGE_TYPE_CALLRESULT
  9211. ,uuid
  9212. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  9213. json_object_put(GetCompositeSchedule);
  9214. LWS_Send(message);
  9215. result = TRUE;
  9216. return result;
  9217. }
  9218. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  9219. {
  9220. mtrace();
  9221. int result = FAIL;
  9222. char message[4096]={0};
  9223. json_object *GetGetDisplayMessages = json_object_new_object();
  9224. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  9225. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  9226. sprintf(message,"[%d,\"%s\",%s]"
  9227. ,MESSAGE_TYPE_CALLRESULT
  9228. ,uuid
  9229. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  9230. json_object_put(GetGetDisplayMessages);
  9231. LWS_Send(message);
  9232. result = TRUE;
  9233. return result;
  9234. }
  9235. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  9236. {
  9237. mtrace();
  9238. int result = FAIL;
  9239. char message[4096]={0};
  9240. json_object *GetInstalledCertificateIds = json_object_new_object();
  9241. json_object *certificateHashDataChains = json_object_new_array();
  9242. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  9243. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  9244. for(int idx=0;idx<certQuantity;idx++)
  9245. {
  9246. json_object *cert = json_object_new_object();
  9247. json_object *certificateHashData = json_object_new_object();
  9248. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  9249. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  9250. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  9251. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  9252. json_object_object_add(cert, "certificateHashData", certificateHashData);
  9253. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  9254. json_object_array_add(certificateHashDataChains, cert);
  9255. }
  9256. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  9257. sprintf(message,"[%d,\"%s\",%s]"
  9258. ,MESSAGE_TYPE_CALLRESULT
  9259. ,uuid
  9260. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  9261. json_object_put(GetInstalledCertificateIds);
  9262. LWS_Send(message);
  9263. result = TRUE;
  9264. return result;
  9265. }
  9266. int sendGetLocalListVersionConfirmation(char *uuid)
  9267. {
  9268. mtrace();
  9269. int result = FAIL;
  9270. char message[4096]={0};
  9271. json_object *GetLocalListVersion = json_object_new_object();
  9272. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  9273. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  9274. sprintf(message,"[%d,\"%s\",%s]"
  9275. ,MESSAGE_TYPE_CALLRESULT
  9276. ,uuid
  9277. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  9278. json_object_put(GetLocalListVersion);
  9279. LWS_Send(message);
  9280. result = TRUE;
  9281. return result;
  9282. }
  9283. int sendGetLogConfirmation(char *uuid)
  9284. {
  9285. mtrace();
  9286. int result = FAIL;
  9287. char message[4096]={0};
  9288. json_object *GetLog = json_object_new_object();
  9289. DEBUG_INFO("sendGetLogConfirmation...\n");
  9290. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  9291. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  9292. sprintf(message,"[%d,\"%s\",%s]"
  9293. ,MESSAGE_TYPE_CALLRESULT
  9294. ,uuid
  9295. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  9296. json_object_put(GetLog);
  9297. LWS_Send(message);
  9298. result = TRUE;
  9299. return result;
  9300. }
  9301. int sendGetMonitoringReportConfirmation(char *uuid)
  9302. {
  9303. mtrace();
  9304. int result = FAIL;
  9305. char message[4096]={0};
  9306. json_object *GetMonitoringReport = json_object_new_object();
  9307. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  9308. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  9309. sprintf(message,"[%d,\"%s\",%s]"
  9310. ,MESSAGE_TYPE_CALLRESULT
  9311. ,uuid
  9312. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  9313. json_object_put(GetMonitoringReport);
  9314. LWS_Send(message);
  9315. result = TRUE;
  9316. return result;
  9317. }
  9318. int sendGetReportConfirmation(char *uuid)
  9319. {
  9320. mtrace();
  9321. int result = FAIL;
  9322. char message[4096]={0};
  9323. json_object *GetReport = json_object_new_object();
  9324. DEBUG_INFO("sendGetReportConfirmation...\n");
  9325. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  9326. sprintf(message,"[%d,\"%s\",%s]"
  9327. ,MESSAGE_TYPE_CALLRESULT
  9328. ,uuid
  9329. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  9330. json_object_put(GetReport);
  9331. LWS_Send(message);
  9332. result = TRUE;
  9333. return result;
  9334. }
  9335. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  9336. {
  9337. mtrace();
  9338. int result = FAIL;
  9339. char message[4096]={0};
  9340. json_object *GetTransactionStatus = json_object_new_object();
  9341. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  9342. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  9343. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  9344. sprintf(message,"[%d,\"%s\",%s]"
  9345. ,MESSAGE_TYPE_CALLRESULT
  9346. ,uuid
  9347. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  9348. json_object_put(GetTransactionStatus);
  9349. LWS_Send(message);
  9350. result = TRUE;
  9351. return result;
  9352. }
  9353. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  9354. {
  9355. mtrace();
  9356. int result = FAIL;
  9357. char message[4096]={0};
  9358. json_object *GetVariables = json_object_new_object();
  9359. json_object *getVariableResults = json_object_new_array();
  9360. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  9361. for(int idx=0;idx<variableQuantity;idx++)
  9362. {
  9363. json_object *variableResult = json_object_new_object();
  9364. json_object *component = json_object_new_object();
  9365. json_object *variable = json_object_new_object();
  9366. json_object *evse = json_object_new_object();
  9367. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  9368. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  9369. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  9370. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  9371. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  9372. json_object_object_add(component, "evse", evse);
  9373. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  9374. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  9375. json_object_object_add(variableResult, "component", component);
  9376. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  9377. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  9378. json_object_object_add(variableResult, "variable", variable);
  9379. json_object_array_add(getVariableResults, variableResult);
  9380. }
  9381. json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
  9382. sprintf(message,"[%d,\"%s\",%s]"
  9383. ,MESSAGE_TYPE_CALLRESULT
  9384. ,uuid
  9385. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  9386. json_object_put(GetVariables);
  9387. LWS_Send(message);
  9388. result = TRUE;
  9389. return result;
  9390. }
  9391. int sendInstallCertificateConfirmation(char *uuid)
  9392. {
  9393. mtrace();
  9394. int result = FAIL;
  9395. char message[4096]={0};
  9396. json_object *InstallCertificate = json_object_new_object();
  9397. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  9398. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  9399. sprintf(message,"[%d,\"%s\",%s]"
  9400. ,MESSAGE_TYPE_CALLRESULT
  9401. ,uuid
  9402. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  9403. json_object_put(InstallCertificate);
  9404. LWS_Send(message);
  9405. result = TRUE;
  9406. return result;
  9407. }
  9408. int sendPublishFirmwareConfirmation(char *uuid)
  9409. {
  9410. mtrace();
  9411. int result = FAIL;
  9412. char message[4096]={0};
  9413. json_object *PublishFirmware = json_object_new_object();
  9414. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  9415. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  9416. sprintf(message,"[%d,\"%s\",%s]"
  9417. ,MESSAGE_TYPE_CALLRESULT
  9418. ,uuid
  9419. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  9420. json_object_put(PublishFirmware);
  9421. LWS_Send(message);
  9422. result = TRUE;
  9423. return result;
  9424. }
  9425. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  9426. {
  9427. mtrace();
  9428. int result = FAIL;
  9429. char message[4096]={0};
  9430. json_object *RemoteStartTransaction = json_object_new_object();
  9431. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  9432. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  9433. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  9434. sprintf(message,"[%d,\"%s\",%s]"
  9435. ,MESSAGE_TYPE_CALLRESULT
  9436. ,uuid
  9437. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  9438. json_object_put(RemoteStartTransaction);
  9439. LWS_Send(message);
  9440. result = TRUE;
  9441. return result;
  9442. }
  9443. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  9444. {
  9445. mtrace();
  9446. int result = FAIL;
  9447. char message[4096]={0};
  9448. json_object *RemoteStopTransaction = json_object_new_object();
  9449. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  9450. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  9451. sprintf(message,"[%d,\"%s\",%s]"
  9452. ,MESSAGE_TYPE_CALLRESULT
  9453. ,uuid
  9454. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  9455. json_object_put(RemoteStopTransaction);
  9456. LWS_Send(message);
  9457. result = TRUE;
  9458. return result;
  9459. }
  9460. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  9461. {
  9462. mtrace();
  9463. int result = FAIL;
  9464. char message[4096]={0};
  9465. json_object *ReserveNow = json_object_new_object();
  9466. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  9467. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  9468. sprintf(message,"[%d,\"%s\",%s]"
  9469. ,MESSAGE_TYPE_CALLRESULT
  9470. ,uuid
  9471. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  9472. json_object_put(ReserveNow);
  9473. LWS_Send(message);
  9474. result = TRUE;
  9475. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  9476. return result;
  9477. }
  9478. int sendResetConfirmation(char *uuid)
  9479. {
  9480. mtrace();
  9481. int result = FAIL;
  9482. char message[4096]={0};
  9483. json_object *Reset = json_object_new_object();
  9484. DEBUG_INFO("sendResetConfirmation...\n");
  9485. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  9486. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  9487. sprintf(message,"[%d,\"%s\",%s]"
  9488. ,MESSAGE_TYPE_CALLRESULT
  9489. ,uuid
  9490. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  9491. json_object_put(Reset);
  9492. LWS_Send(message);
  9493. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  9494. {
  9495. DB_updateBootType(BootReasonEnumType_RemoteReset);
  9496. }
  9497. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  9498. {
  9499. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  9500. }
  9501. result = TRUE;
  9502. return result;
  9503. }
  9504. int sendSendLocalListConfirmation(char *uuid)
  9505. {
  9506. mtrace();
  9507. int result = FAIL;
  9508. char message[4096]={0};
  9509. json_object *SendLocalList = json_object_new_object();
  9510. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  9511. sprintf(message,"[%d,\"%s\",%s]"
  9512. ,MESSAGE_TYPE_CALLRESULT
  9513. ,uuid
  9514. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  9515. json_object_put(SendLocalList);
  9516. LWS_Send(message);
  9517. result = TRUE;
  9518. return result;
  9519. }
  9520. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  9521. {
  9522. mtrace();
  9523. int result = FAIL;
  9524. char message[4096]={0};
  9525. json_object *SetChargingProfile = json_object_new_object();
  9526. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  9527. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  9528. sprintf(message,"[%d,\"%s\",%s]"
  9529. ,MESSAGE_TYPE_CALLRESULT
  9530. ,uuid
  9531. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  9532. json_object_put(SetChargingProfile);
  9533. LWS_Send(message);
  9534. result = TRUE;
  9535. return result;
  9536. }
  9537. int sendSetDisplayMessagesConfirmation(char *uuid)
  9538. {
  9539. mtrace();
  9540. int result = FAIL;
  9541. char message[4096]={0};
  9542. json_object *SetDisplayMessage = json_object_new_object();
  9543. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  9544. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  9545. sprintf(message,"[%d,\"%s\",%s]"
  9546. ,MESSAGE_TYPE_CALLRESULT
  9547. ,uuid
  9548. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  9549. json_object_put(SetDisplayMessage);
  9550. LWS_Send(message);
  9551. result = TRUE;
  9552. return result;
  9553. }
  9554. int sendSetMonitoringBaseConfirmation(char *uuid)
  9555. {
  9556. mtrace();
  9557. int result = FAIL;
  9558. char message[4096]={0};
  9559. json_object *SetMonitoringBase = json_object_new_object();
  9560. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  9561. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  9562. sprintf(message,"[%d,\"%s\",%s]"
  9563. ,MESSAGE_TYPE_CALLRESULT
  9564. ,uuid
  9565. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  9566. json_object_put(SetMonitoringBase);
  9567. LWS_Send(message);
  9568. result = TRUE;
  9569. return result;
  9570. }
  9571. int sendSetMonitoringLevelConfirmation(char *uuid)
  9572. {
  9573. mtrace();
  9574. int result = FAIL;
  9575. char message[4096]={0};
  9576. json_object *SetMonitoringLevel = json_object_new_object();
  9577. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  9578. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  9579. sprintf(message,"[%d,\"%s\",%s]"
  9580. ,MESSAGE_TYPE_CALLRESULT
  9581. ,uuid
  9582. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  9583. json_object_put(SetMonitoringLevel);
  9584. LWS_Send(message);
  9585. result = TRUE;
  9586. return result;
  9587. }
  9588. int sendSetNetworkProfileConfirmation(char *uuid)
  9589. {
  9590. mtrace();
  9591. int result = FAIL;
  9592. char message[4096]={0};
  9593. json_object *SetNetworkProfile = json_object_new_object();
  9594. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  9595. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  9596. sprintf(message,"[%d,\"%s\",%s]"
  9597. ,MESSAGE_TYPE_CALLRESULT
  9598. ,uuid
  9599. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  9600. json_object_put(SetNetworkProfile);
  9601. LWS_Send(message);
  9602. result = TRUE;
  9603. return result;
  9604. }
  9605. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  9606. {
  9607. mtrace();
  9608. int result = FAIL;
  9609. char message[4096]={0};
  9610. json_object *SetVariableMonitoring = json_object_new_object();
  9611. json_object *setMonitoringResults = json_object_new_array();
  9612. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  9613. for(int idx=0;idx<variableQuantity;idx++)
  9614. {
  9615. json_object *variableMonitorResult = json_object_new_object();
  9616. json_object *component = json_object_new_object();
  9617. json_object *variable = json_object_new_object();
  9618. json_object *evse = json_object_new_object();
  9619. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  9620. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  9621. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  9622. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  9623. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  9624. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  9625. json_object_object_add(component, "component", evse);
  9626. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  9627. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  9628. json_object_object_add(variableMonitorResult, "component", component);
  9629. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  9630. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  9631. json_object_object_add(variableMonitorResult, "variable", variable);
  9632. json_object_array_add(setMonitoringResults, variableMonitorResult);
  9633. }
  9634. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  9635. sprintf(message,"[%d,\"%s\",%s]"
  9636. ,MESSAGE_TYPE_CALLRESULT
  9637. ,uuid
  9638. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  9639. json_object_put(SetVariableMonitoring);
  9640. LWS_Send(message);
  9641. result = TRUE;
  9642. return result;
  9643. }
  9644. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  9645. {
  9646. mtrace();
  9647. int result = FAIL;
  9648. char message[4096]={0};
  9649. json_object *SetVariable = json_object_new_object();
  9650. json_object *setVariableResults = json_object_new_array();
  9651. DEBUG_INFO("sendSetVariableConfirmation...\n");
  9652. for(int idx=0;idx<variableQuantity;idx++)
  9653. {
  9654. json_object *variableResult = json_object_new_object();
  9655. json_object *component = json_object_new_object();
  9656. json_object *variable = json_object_new_object();
  9657. json_object *evse = json_object_new_object();
  9658. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  9659. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  9660. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  9661. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  9662. json_object_object_add(component, "component", evse);
  9663. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  9664. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  9665. json_object_object_add(variableResult, "component", component);
  9666. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  9667. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  9668. json_object_object_add(variableResult, "variable", variable);
  9669. json_object_array_add(setVariableResults, variableResult);
  9670. }
  9671. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  9672. sprintf(message,"[%d,\"%s\",%s]"
  9673. ,MESSAGE_TYPE_CALLRESULT
  9674. ,uuid
  9675. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  9676. json_object_put(SetVariable);
  9677. LWS_Send(message);
  9678. result = TRUE;
  9679. return result;
  9680. }
  9681. int sendTriggerMessageConfirmation(char *uuid)
  9682. {
  9683. mtrace();
  9684. int result = FAIL;
  9685. char message[4096]={0};
  9686. json_object *TriggerMessage = json_object_new_object();
  9687. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  9688. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  9689. sprintf(message,"[%d,\"%s\",%s]",
  9690. MESSAGE_TYPE_CALLRESULT,
  9691. uuid,
  9692. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  9693. json_object_put(TriggerMessage);
  9694. LWS_Send(message);
  9695. result = TRUE;
  9696. return result;
  9697. }
  9698. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  9699. {
  9700. mtrace();
  9701. int result = FAIL;
  9702. char message[4096]={0};
  9703. json_object *UnlockConnector = json_object_new_object();
  9704. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  9705. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  9706. sprintf(message,"[%d,\"%s\",%s]",
  9707. MESSAGE_TYPE_CALLRESULT,
  9708. uuid,
  9709. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  9710. json_object_put(UnlockConnector);
  9711. LWS_Send(message);
  9712. result = TRUE;
  9713. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  9714. return result;
  9715. }
  9716. int sendUnpublishFirmwareConfirmation(char *uuid)
  9717. {
  9718. mtrace();
  9719. int result = FAIL;
  9720. char message[4096]={0};
  9721. json_object *UnpublishFirmware = json_object_new_object();
  9722. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  9723. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  9724. sprintf(message,"[%d,\"%s\",%s]"
  9725. ,MESSAGE_TYPE_CALLRESULT
  9726. ,uuid
  9727. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  9728. json_object_put(UnpublishFirmware);
  9729. LWS_Send(message);
  9730. result = TRUE;
  9731. return result;
  9732. }
  9733. int sendUpdateFirmwareConfirmation(char *uuid)
  9734. {
  9735. mtrace();
  9736. int result = FAIL;
  9737. char message[4096]={0};
  9738. json_object *UpdateFirmware = json_object_new_object();
  9739. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  9740. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  9741. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  9742. sprintf(message,"[%d,\"%s\",%s]"
  9743. ,MESSAGE_TYPE_CALLRESULT
  9744. ,uuid
  9745. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  9746. json_object_put(UpdateFirmware);
  9747. LWS_Send(message);
  9748. result = TRUE;
  9749. return result;
  9750. }
  9751. int sendUnknownConfirmation(char *uuid)
  9752. {
  9753. mtrace();
  9754. int result = FAIL;
  9755. char message[256]={0};
  9756. //[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
  9757. DEBUG_INFO("sendUnknownConfirmation...\n");
  9758. sprintf(message,"[%d,\"%s\",\"NotImplemented\",\"Requested Action is not known by receiver\",{}]", MESSAGE_TYPE_CALLERROR, uuid);
  9759. LWS_Send(message);
  9760. result = TRUE;
  9761. return result;
  9762. }
  9763. //==========================================
  9764. // send CallError routine
  9765. //==========================================
  9766. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  9767. {
  9768. mtrace();
  9769. char message[220]={0};
  9770. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  9771. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  9772. LWS_Send(message);
  9773. }
  9774. //==========================================
  9775. // Handle server request routine Start
  9776. //==========================================
  9777. int handleCancelReservationRequest(char *uuid, char *payload)
  9778. {
  9779. mtrace();
  9780. int result = FAIL;
  9781. int gunNO = 0;
  9782. int reservationIdInt = -1;
  9783. DEBUG_INFO("handleCancelReservationRequest...\n");
  9784. json_object *CancelReservation;
  9785. CancelReservation = json_tokener_parse(payload);
  9786. if(!is_error(CancelReservation))
  9787. {
  9788. // Required data
  9789. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  9790. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  9791. }
  9792. json_object_put(CancelReservation);
  9793. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  9794. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  9795. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  9796. if(reservationIdInt != -1)
  9797. {
  9798. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  9799. //check Transaction active
  9800. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  9801. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  9802. {
  9803. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  9804. {
  9805. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  9806. if(gunType[2] == GUN_TYPE_CHAdeMO)
  9807. {
  9808. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  9809. }
  9810. else
  9811. {
  9812. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  9813. }
  9814. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  9815. goto end;
  9816. }
  9817. }
  9818. for (int index = 0; index < CCS_QUANTITY; index++)
  9819. {
  9820. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  9821. {
  9822. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  9823. if(gunType[2] == GUN_TYPE_CCS)
  9824. {
  9825. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  9826. }
  9827. else
  9828. {
  9829. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  9830. }
  9831. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  9832. goto end;
  9833. }
  9834. }
  9835. for (int index = 0; index < GB_QUANTITY; index++)
  9836. {
  9837. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  9838. {
  9839. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  9840. if(gunType[2] == GUN_TYPE_GBT)
  9841. {
  9842. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  9843. }
  9844. else
  9845. {
  9846. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  9847. }
  9848. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  9849. goto end;
  9850. }
  9851. }
  9852. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9853. {
  9854. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId == reservationIdInt)
  9855. {
  9856. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  9857. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  9858. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  9859. goto end;
  9860. }
  9861. }
  9862. for (int index = 0; index < AC_QUANTITY; index++)
  9863. {
  9864. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  9865. {
  9866. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  9867. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  9868. {
  9869. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  9870. }
  9871. else
  9872. {
  9873. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  9874. }
  9875. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  9876. goto end;
  9877. }
  9878. }
  9879. }
  9880. //The reservationId does NOT match the reservationId
  9881. sendCancelReservationConfirmation(uuid, gunNO);
  9882. end:
  9883. // Fill in ocpp packet uuid
  9884. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  9885. return result;
  9886. }
  9887. int handleCertificateSignedRequest(char *uuid, char *payload)
  9888. {
  9889. mtrace();
  9890. int result = FAIL;
  9891. json_object *CertificateSigned;
  9892. DEBUG_INFO("handleCertificateSignedRequest...\n");
  9893. CertificateSigned = json_tokener_parse(payload);
  9894. if(!is_error(CertificateSigned))
  9895. {
  9896. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  9897. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  9898. // Required data
  9899. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateChain, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateChain")));
  9900. // Optional data
  9901. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  9902. {
  9903. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  9904. if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]) == 0)
  9905. {
  9906. FILE *fp = fopen("/Storage/OCPP/certCP.crt", "w");
  9907. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  9908. fclose(fp);
  9909. }
  9910. else if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0)
  9911. {
  9912. FILE *fp = fopen("/Storage/OCPP/certV2G.crt", "w");
  9913. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  9914. fclose(fp);
  9915. }
  9916. }
  9917. else
  9918. {
  9919. FILE *fp = fopen("/Storage/OCPP/certCP.crt", "w");
  9920. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  9921. fclose(fp);
  9922. fp = fopen("/Storage/OCPP/certV2G.crt", "w");
  9923. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  9924. fclose(fp);
  9925. }
  9926. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  9927. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  9928. }
  9929. else
  9930. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  9931. json_object_put(CertificateSigned);
  9932. sendCertificateSignedConfirmation(uuid);
  9933. return result;
  9934. }
  9935. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  9936. {
  9937. mtrace();
  9938. int result = FAIL;
  9939. int evseId = 0, gunIndex = 0;
  9940. char operationalStatus[16]={0};
  9941. char comfirmstr[20];
  9942. int specificId = FALSE;
  9943. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  9944. json_object *ChangeAvailability;
  9945. ChangeAvailability = json_tokener_parse(payload);
  9946. if(!is_error(ChangeAvailability))
  9947. {
  9948. // Required data
  9949. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  9950. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  9951. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  9952. {
  9953. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  9954. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  9955. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  9956. }
  9957. }
  9958. json_object_put(ChangeAvailability);
  9959. if((evseId != 0) && (evseId <= gunTotalNumber))
  9960. {
  9961. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  9962. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  9963. }
  9964. else if(evseId == 0)
  9965. {
  9966. for(int i=0; i < gunTotalNumber; i++)
  9967. {
  9968. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  9969. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  9970. }
  9971. }
  9972. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  9973. {
  9974. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  9975. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  9976. }
  9977. else if(gunIndex == 0)
  9978. {
  9979. for(int i=0; i < gunTotalNumber; i++)
  9980. {
  9981. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  9982. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  9983. }
  9984. }
  9985. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  9986. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  9987. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  9988. {
  9989. specificId = TRUE;
  9990. }
  9991. if(specificId == FALSE)
  9992. goto end;
  9993. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  9994. {
  9995. //----------------------gunIndex is 0 ------------------------------------------------//
  9996. if(gunIndex == 0)
  9997. {
  9998. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  9999. {
  10000. for(int i=0; i < gunTotalNumber; i++)
  10001. {
  10002. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10003. {
  10004. if ((gunType[i] == GUN_TYPE_CHAdeMO)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  10005. {
  10006. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10007. {
  10008. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10009. goto end;
  10010. }
  10011. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10012. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10013. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10014. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10015. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10016. {
  10017. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10018. goto end;
  10019. }
  10020. }
  10021. }//END FOR CHAdeMO_QUANTITY
  10022. for (int index = 0; index < CCS_QUANTITY; index++)
  10023. {
  10024. if ((gunType[i] == GUN_TYPE_CCS)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  10025. {
  10026. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  10027. {
  10028. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10029. goto end;
  10030. }
  10031. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10032. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10033. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10034. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10035. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10036. {
  10037. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10038. goto end;
  10039. }
  10040. }
  10041. }//END FOR CCS_QUANTITY
  10042. for (int index = 0; index < GB_QUANTITY; index++)
  10043. {
  10044. if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  10045. {
  10046. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10047. {
  10048. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10049. goto end;
  10050. }
  10051. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10052. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10053. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10054. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10055. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10056. {
  10057. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10058. goto end;
  10059. }
  10060. }
  10061. }// END FOR GB_QUANTITY
  10062. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10063. {
  10064. if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i))
  10065. {
  10066. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10067. {
  10068. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10069. goto end;
  10070. }
  10071. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  10072. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  10073. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  10074. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  10075. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10076. {
  10077. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10078. goto end;
  10079. }
  10080. }
  10081. }// END FOR DO_QUANTITY
  10082. for (int index = 0; index < AC_QUANTITY; index++)
  10083. {
  10084. if ((gunType[i] == GUN_TYPE_AC)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  10085. {
  10086. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10087. {
  10088. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10089. goto end;
  10090. }
  10091. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10092. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10093. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10094. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10095. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10096. {
  10097. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10098. goto end;
  10099. }
  10100. }
  10101. }//END FOR AC_QUANTITY
  10102. }// END FOR gunTotalNumber
  10103. }
  10104. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  10105. {
  10106. for(int i=0; i < gunTotalNumber; i++)
  10107. {
  10108. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  10109. {
  10110. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10111. goto end;
  10112. }
  10113. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10114. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  10115. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  10116. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  10117. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10118. {
  10119. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10120. goto end;
  10121. }
  10122. }
  10123. }
  10124. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10125. goto end;
  10126. }
  10127. //----------------------gunIndex is not 0 ------------------------------------------------//
  10128. //check Transaction active
  10129. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10130. {
  10131. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO))
  10132. {
  10133. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  10134. {
  10135. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10136. goto end;
  10137. }
  10138. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10139. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10140. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10141. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10142. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10143. {
  10144. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10145. goto end;
  10146. }
  10147. else
  10148. {
  10149. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  10150. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10151. goto end;
  10152. }
  10153. }
  10154. }//END FOR CHAdeMO_QUANTITY
  10155. for (int index = 0; index < CCS_QUANTITY; index++)
  10156. {
  10157. if ((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS))
  10158. {
  10159. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  10160. {
  10161. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10162. goto end;
  10163. }
  10164. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10165. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10166. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10167. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10168. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10169. {
  10170. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10171. goto end;
  10172. }
  10173. else
  10174. {
  10175. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  10176. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10177. goto end;
  10178. }
  10179. }
  10180. }//END FOR CCS_QUANTITY
  10181. for (int index = 0; index < GB_QUANTITY; index++)
  10182. {
  10183. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))
  10184. {
  10185. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  10186. {
  10187. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10188. goto end;
  10189. }
  10190. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10191. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10192. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10193. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10194. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10195. {
  10196. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10197. goto end;
  10198. }
  10199. else
  10200. {
  10201. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  10202. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10203. goto end;
  10204. }
  10205. }
  10206. }// END FOR GB_QUANTITY
  10207. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10208. {
  10209. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))
  10210. {
  10211. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  10212. {
  10213. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10214. goto end;
  10215. }
  10216. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  10217. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  10218. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  10219. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  10220. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10221. {
  10222. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10223. goto end;
  10224. }
  10225. else
  10226. {
  10227. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  10228. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10229. goto end;
  10230. }
  10231. }
  10232. }// END FOR DO_QUANTITY
  10233. for (int index = 0; index < AC_QUANTITY; index++)
  10234. {
  10235. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC))
  10236. {
  10237. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  10238. {
  10239. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10240. goto end;
  10241. }
  10242. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  10243. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  10244. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  10245. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  10246. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  10247. {
  10248. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  10249. goto end;
  10250. }
  10251. else
  10252. {
  10253. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  10254. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10255. goto end;
  10256. }
  10257. }
  10258. }//END FOR AC_QUANTITY
  10259. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  10260. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  10261. {
  10262. //----------------------gunIndex is 0 ------------------------------------------------//
  10263. if(gunIndex == 0)
  10264. {
  10265. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10266. {
  10267. for(int i=0; i < gunTotalNumber; i++)
  10268. {
  10269. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10270. {
  10271. 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
  10272. {
  10273. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10274. goto end;
  10275. }
  10276. }//END FOR CHAdeMO_QUANTITY
  10277. for (int index = 0; index < CCS_QUANTITY; index++)
  10278. {
  10279. 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
  10280. {
  10281. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10282. goto end;
  10283. }
  10284. }//END FOR CCS_QUANTITY
  10285. for (int index = 0; index < GB_QUANTITY; index++)
  10286. {
  10287. 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
  10288. {
  10289. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  10290. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10291. goto end;
  10292. }
  10293. }// END FOR GB_QUANTITY
  10294. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10295. {
  10296. 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
  10297. {
  10298. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  10299. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10300. goto end;
  10301. }
  10302. }// END FOR DO_QUANTITY
  10303. for (int index = 0; index < AC_QUANTITY; index++)
  10304. {
  10305. 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
  10306. {
  10307. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10308. goto end;
  10309. }
  10310. }//END FOR CHAdeMO_QUANTITY
  10311. }// END FOR gunTotalNumber
  10312. }
  10313. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  10314. {
  10315. for(int i=0; i < gunTotalNumber; i++)
  10316. {
  10317. for (int index = 0; index < AC_QUANTITY; index++)
  10318. {
  10319. 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
  10320. {
  10321. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10322. goto end;
  10323. }
  10324. }//END FOR CHAdeMO_QUANTITY
  10325. } // END FOR gunTotalNumber
  10326. }
  10327. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10328. goto end;
  10329. }
  10330. //----------------------gunIndex is not 0 ------------------------------------------------//
  10331. //check Transaction active
  10332. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10333. {
  10334. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10335. {
  10336. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10337. goto end;
  10338. }
  10339. }//END FOR CHAdeMO_QUANTITY
  10340. for (int index = 0; index < CCS_QUANTITY; index++)
  10341. {
  10342. if ((((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS)) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10343. {
  10344. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10345. goto end;
  10346. }
  10347. }//END FOR CCS_QUANTITY
  10348. for (int index = 0; index < GB_QUANTITY; index++)
  10349. {
  10350. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10351. {
  10352. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10353. goto end;
  10354. }
  10355. }// END FOR GB_QUANTITY
  10356. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10357. {
  10358. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10359. {
  10360. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10361. goto end;
  10362. }
  10363. }// END FOR DO_QUANTITY
  10364. for (int index = 0; index < AC_QUANTITY; index++)
  10365. {
  10366. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC)) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  10367. {
  10368. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  10369. goto end;
  10370. }
  10371. }//END FOR AC_QUANTITY
  10372. }//END FOR AvailabilityEnumTypeStr[Operative]
  10373. end:
  10374. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  10375. {
  10376. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  10377. }
  10378. else
  10379. {
  10380. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  10381. }
  10382. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  10383. {
  10384. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  10385. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  10386. }
  10387. else if(gunIndex == 0)
  10388. {
  10389. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  10390. {
  10391. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  10392. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  10393. }
  10394. }
  10395. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  10396. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10397. return result;
  10398. }
  10399. int handleClearCacheRequest(char *uuid, char *payload)
  10400. {
  10401. mtrace();
  10402. int result = FAIL;
  10403. char rmFileCmd[100]={0};
  10404. struct stat stats;
  10405. DEBUG_INFO("handleClearCacheRequest...\n");
  10406. stat("/Storage/OCPP", &stats);
  10407. // Check for directory existence
  10408. if (S_ISDIR(stats.st_mode) == 1)
  10409. {}
  10410. else
  10411. {
  10412. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  10413. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  10414. system(rmFileCmd);
  10415. }
  10416. /*
  10417. * TODO:
  10418. * 1. Clear cache from sqlite db
  10419. */
  10420. if(1)
  10421. {
  10422. DEBUG_INFO("open AuthorizationCache file failed\n");
  10423. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  10424. }
  10425. else
  10426. {
  10427. DEBUG_INFO("open AuthorizationCache file successful\n");
  10428. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  10429. }
  10430. sendClearCacheConfirmation(uuid);
  10431. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10432. return result;
  10433. }
  10434. int handleClearChargingProfileRequest(char *uuid, char *payload)
  10435. {
  10436. mtrace();
  10437. int result = FAIL;
  10438. int resultRename;
  10439. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  10440. char chargingProfilePurposeStr[26]={0};
  10441. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  10442. char tempchargingProfilePurposeStr[26]={0};
  10443. char sstr[160]={0};
  10444. char str[100]={0};
  10445. int c = 0;
  10446. char *loc;
  10447. char fname[200]={0};
  10448. char comfirmstr[20]={0};
  10449. char word[1600]={0};
  10450. int clearflag = FALSE;
  10451. int chargingProfileIdIsNULL = FALSE;
  10452. int connectorIsNULL = FALSE;
  10453. int chargingProfilePurposeIsNULL = FALSE;
  10454. int stackLevelIsNULL = FALSE;
  10455. //int GotoEnd = FALSE;
  10456. FILE *fptr1, *fptr2;
  10457. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  10458. int n_chargingProfile=0;
  10459. int isEmptyFile = FALSE;
  10460. char sLineWord[1600]={0};
  10461. char chargingProfiles[10][100]={0};
  10462. int ChargeProfileCount = 0;
  10463. int ch;
  10464. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  10465. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  10466. json_object *ClearChargingProfile;
  10467. ClearChargingProfile = json_tokener_parse(payload);
  10468. if(!is_error(ClearChargingProfile))
  10469. {
  10470. // Optional data
  10471. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  10472. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  10473. else
  10474. chargingProfileIdIsNULL = TRUE;
  10475. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  10476. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  10477. else
  10478. connectorIsNULL = TRUE;
  10479. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  10480. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  10481. else
  10482. chargingProfilePurposeIsNULL = TRUE;
  10483. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  10484. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  10485. else
  10486. stackLevelIsNULL = TRUE;
  10487. }
  10488. json_object_put(ClearChargingProfile);
  10489. if(connectorIsNULL == FALSE)
  10490. {
  10491. switch(connectorIdInt)
  10492. {
  10493. case 0:
  10494. if(chargingProfilePurposeIsNULL == TRUE)
  10495. {
  10496. int l = 0;
  10497. strcpy(fname, ChargePointMaxProfile_JSON);
  10498. if((access(fname,F_OK))!=-1)
  10499. {
  10500. strcpy(chargingProfiles[l], fname);
  10501. l = l + 1;
  10502. }
  10503. strcpy(fname, TxDefaultProfile_0_JSON);
  10504. if((access(fname,F_OK))!=-1)
  10505. {
  10506. strcpy(chargingProfiles[l], fname);
  10507. l = l + 1;
  10508. }
  10509. ChargeProfileCount = l;
  10510. }
  10511. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  10512. {
  10513. strcpy(fname, ChargePointMaxProfile_JSON);
  10514. if((access(fname,F_OK))!=-1)
  10515. {
  10516. strcpy(chargingProfiles[0], fname);
  10517. ChargeProfileCount = 1;
  10518. }
  10519. }
  10520. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  10521. {
  10522. strcpy(fname, TxDefaultProfile_0_JSON);
  10523. if((access(fname,F_OK))!=-1)
  10524. {
  10525. strcpy(chargingProfiles[0], fname);
  10526. ChargeProfileCount = 1;
  10527. }
  10528. }
  10529. break;
  10530. default:
  10531. if(chargingProfilePurposeIsNULL == TRUE)
  10532. {
  10533. int m = 0;
  10534. memset(fname, 0, ARRAY_SIZE(fname));
  10535. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  10536. if((access(fname,F_OK))!=-1)
  10537. {
  10538. strcpy(chargingProfiles[m], fname);
  10539. m = m + 1;
  10540. }
  10541. memset(fname, 0, ARRAY_SIZE(fname));
  10542. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  10543. if((access(fname,F_OK))!=-1)
  10544. {
  10545. strcpy(chargingProfiles[m], fname);
  10546. m = m + 1;
  10547. }
  10548. ChargeProfileCount = m;
  10549. }
  10550. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  10551. {
  10552. //strcpy(fname, TxDefaultProfile_1_JSON);
  10553. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  10554. if((access(fname,F_OK))!=-1)
  10555. {
  10556. strcpy(chargingProfiles[0], fname);
  10557. ChargeProfileCount = 1;
  10558. }
  10559. }
  10560. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  10561. {
  10562. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  10563. if((access(fname,F_OK))!=-1)
  10564. {
  10565. strcpy(chargingProfiles[0], fname);
  10566. ChargeProfileCount = 1;
  10567. }
  10568. }
  10569. //strcpy(fname, ChargePointMaxProfile_JSON );
  10570. break;
  10571. }
  10572. }
  10573. else // Check all Charging Profiles
  10574. {
  10575. int i = 0;
  10576. char fnametemp[200]={0};
  10577. ChargeProfileCount = 0;
  10578. //Check ChargePointMaxProfile.json exit
  10579. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  10580. {
  10581. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  10582. i = i + 1;
  10583. }
  10584. //Check TxDefaultProfile_0.json exit
  10585. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  10586. {
  10587. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  10588. i = i + 1;
  10589. }
  10590. //Check TxDefaultProfile_%d.json
  10591. for(int j=1; j <= gunTotalNumber; j++)
  10592. {
  10593. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  10594. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  10595. if((access(fnametemp,F_OK))!=-1)
  10596. {
  10597. strcpy(chargingProfiles[i], fnametemp);
  10598. i = i + 1;
  10599. }
  10600. }
  10601. //Check TxProfile_%d.json
  10602. for(int j=1; j <= gunTotalNumber; j++)
  10603. {
  10604. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  10605. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  10606. if((access(fnametemp,F_OK))!=-1)
  10607. {
  10608. strcpy(chargingProfiles[i], fnametemp);
  10609. i = i + 1;
  10610. }
  10611. }
  10612. ChargeProfileCount = i;
  10613. }// End connectorIsNULL is TRUE
  10614. if(ChargeProfileCount == 0)
  10615. {
  10616. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  10617. goto end;
  10618. }
  10619. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  10620. {
  10621. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  10622. goto end;
  10623. }
  10624. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  10625. {
  10626. memset(str, 0, ARRAY_SIZE(str));
  10627. // clear temp file
  10628. sprintf(str,"rm -f %s",temp);
  10629. system(str);
  10630. for(int k=0; k < ChargeProfileCount; k++)
  10631. {
  10632. memset(str, 0, ARRAY_SIZE(str));
  10633. //clear file in C
  10634. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10635. system(str);
  10636. }
  10637. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10638. goto end;
  10639. }
  10640. else if(connectorIsNULL == TRUE)
  10641. {
  10642. for(int k=0; k < ChargeProfileCount; k++)
  10643. {
  10644. fptr1 = fopen(chargingProfiles[k], "r");
  10645. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  10646. //Check Charging Profile Count
  10647. while(fscanf(fptr1, "%s", word) != EOF)
  10648. {
  10649. //DEBUG_INFO("word=%s\n",word);
  10650. if(strstr(word, "chargingProfileId")!= NULL)
  10651. {
  10652. //DEBUG_INFO("test chargingProfileId \n");
  10653. n_chargingProfile = n_chargingProfile + 1;
  10654. //DEBUG_INFO("chargingProfileId Found\n");
  10655. }
  10656. }
  10657. rewind(fptr1);
  10658. //search Charging Profile Element
  10659. //int i= 0;
  10660. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  10661. {
  10662. //------------------------tempconnectorIdInt------------------------//
  10663. loc = strstr(sLineWord, "connectorId");
  10664. c = 0;
  10665. memset(sstr ,0, sizeof(sstr) );
  10666. while (loc[strlen("connectorId")+2+c] != ',')
  10667. {
  10668. sstr[c] = loc[strlen("connectorId")+2+c];
  10669. c++;
  10670. }
  10671. sstr[c] = '\0';
  10672. tempconnectorIdInt = atoi(sstr);
  10673. printf("file's gun number is %d\n", tempconnectorIdInt);
  10674. //--------------------------chargingProfileId--------------------//
  10675. c = 0;
  10676. loc = strstr(sLineWord, "chargingProfileId");
  10677. memset(sstr ,0, ARRAY_SIZE(sstr));
  10678. while (loc[strlen("chargingProfileId")+2+c] != ',')
  10679. {
  10680. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  10681. //printf("i=%d sstr=%c\n",c, sstr[c]);
  10682. c++;
  10683. }
  10684. sstr[c] = '\0';
  10685. tempchargingProfileIdInt = atoi(sstr);
  10686. //stackLevel
  10687. c = 0;
  10688. loc = strstr(sLineWord, "stackLevel");
  10689. memset(sstr ,0, ARRAY_SIZE(sstr));
  10690. while (loc[strlen("stackLevel")+2+c] != ',')
  10691. {
  10692. sstr[c] = loc[strlen("stackLevel")+2+c];
  10693. //printf("i=%d sstr=%c\n",c, sstr[c]);
  10694. c++;
  10695. }
  10696. sstr[c] = '\0';
  10697. tempstackLevelInt = atoi(sstr);
  10698. c = 0;
  10699. loc = strstr(sLineWord, "chargingProfilePurpose");
  10700. memset(sstr ,0, ARRAY_SIZE(sstr));
  10701. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  10702. {
  10703. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  10704. c++;
  10705. }
  10706. sstr[c] = '\0';
  10707. strcpy(tempchargingProfilePurposeStr, sstr);
  10708. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  10709. {
  10710. //------- not write to fptr2-------//
  10711. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10712. //clearflag = TRUE;
  10713. }
  10714. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  10715. {
  10716. //------- not write to fptr2-------//
  10717. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10718. }
  10719. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  10720. {
  10721. //------- not write to fptr2-------//
  10722. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10723. }
  10724. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  10725. {
  10726. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10727. }
  10728. else
  10729. {
  10730. fprintf(fptr2, sLineWord);//writing data into file
  10731. }
  10732. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  10733. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  10734. if(clearflag == TRUE)
  10735. {
  10736. fclose(fptr1);
  10737. fclose(fptr2);
  10738. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10739. system(str);
  10740. // clear temp file
  10741. sprintf(str,"rm -f %s",temp);
  10742. system(str);
  10743. }
  10744. else
  10745. {
  10746. fclose(fptr1);
  10747. fclose(fptr2);
  10748. memset(str, 0, ARRAY_SIZE(str));
  10749. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10750. system(str);
  10751. resultRename = rename(temp, chargingProfiles[k]);
  10752. if(resultRename == 0)
  10753. {
  10754. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  10755. }
  10756. else
  10757. {
  10758. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  10759. }
  10760. if(comfirmstr[0]== 0)
  10761. {
  10762. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  10763. }
  10764. //Check chargingProfile is empty file
  10765. /*------ Read the file ----------------*/
  10766. fptr1=fopen(chargingProfiles[k],"r");
  10767. ch=fgetc(fptr1);
  10768. rewind(fptr1);
  10769. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  10770. if(ch!=EOF)
  10771. {
  10772. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  10773. {
  10774. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  10775. if(sLineWord[0]=='\0')
  10776. {
  10777. isEmptyFile = TRUE;
  10778. break;
  10779. }
  10780. else
  10781. {
  10782. isEmptyFile = FALSE;
  10783. break;
  10784. }
  10785. }
  10786. }
  10787. else
  10788. isEmptyFile = TRUE;
  10789. fclose(fptr1);
  10790. if(isEmptyFile == TRUE)
  10791. {
  10792. memset(str, 0, ARRAY_SIZE(str));
  10793. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10794. system(str);
  10795. }
  10796. }
  10797. }// End of while(int k=0; k < ChargePointCount; k++)
  10798. }
  10799. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  10800. {
  10801. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  10802. for(int k=0; k < ChargeProfileCount; k++)
  10803. {
  10804. fptr1 = fopen(chargingProfiles[k], "r");
  10805. fptr2 = fopen(temp, "w+");
  10806. //Check Charging Profile Count
  10807. while(fscanf(fptr1, "%s", word) != EOF)
  10808. {
  10809. //DEBUG_INFO("word=%s\n",word);
  10810. if(strstr(word, "chargingProfileId")!= NULL)
  10811. {
  10812. n_chargingProfile = n_chargingProfile + 1;
  10813. }
  10814. }
  10815. rewind(fptr1);
  10816. //search Charging Profile Element
  10817. //int i= 0;
  10818. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  10819. {
  10820. //*************************tempconnectorIdInt*********************************/
  10821. loc = strstr(sLineWord, "connectorId");
  10822. c = 0;
  10823. memset(sstr ,0, ARRAY_SIZE(sstr));
  10824. while (loc[strlen("connectorId")+2+c] != ',')
  10825. {
  10826. sstr[c] = loc[strlen("connectorId")+2+c];
  10827. c++;
  10828. }
  10829. sstr[c] = '\0';
  10830. tempconnectorIdInt = atoi(sstr);
  10831. //chargingProfileId
  10832. c = 0;
  10833. loc = strstr(sLineWord, "chargingProfileId");
  10834. memset(sstr ,0, ARRAY_SIZE(sstr));
  10835. while (loc[strlen("chargingProfileId")+2+c] != ',')
  10836. {
  10837. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  10838. //printf("i=%d sstr=%c\n",c, sstr[c]);
  10839. c++;
  10840. }
  10841. sstr[c] = '\0';
  10842. tempchargingProfileIdInt = atoi(sstr);
  10843. //stackLevel
  10844. c = 0;
  10845. loc = strstr(sLineWord, "stackLevel");
  10846. memset(sstr ,0, ARRAY_SIZE(sstr));
  10847. while (loc[strlen("stackLevel")+2+c] != ',')
  10848. {
  10849. sstr[c] = loc[strlen("stackLevel")+2+c];
  10850. //printf("i=%d sstr=%c\n",c, sstr[c]);
  10851. c++;
  10852. }
  10853. sstr[c] = '\0';
  10854. tempstackLevelInt = atoi(sstr);
  10855. c = 0;
  10856. loc = strstr(sLineWord, "chargingProfilePurpose");
  10857. memset(sstr ,0, ARRAY_SIZE(sstr));
  10858. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  10859. {
  10860. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  10861. c++;
  10862. }
  10863. sstr[c] = '\0';
  10864. strcpy(tempchargingProfilePurposeStr, sstr);
  10865. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  10866. {
  10867. //------- not write to fptr2-------//
  10868. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10869. //clearflag = TRUE;
  10870. }
  10871. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  10872. {
  10873. //------- not write to fptr2-------//
  10874. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10875. }
  10876. else if(stackLevelIsNULL == TRUE)
  10877. {
  10878. //Clear Whole File
  10879. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  10880. clearflag = TRUE;
  10881. break;
  10882. }
  10883. else
  10884. {
  10885. fprintf(fptr2, sLineWord);//writing data into file
  10886. }
  10887. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  10888. }
  10889. if(clearflag == TRUE)
  10890. {
  10891. fclose(fptr1);
  10892. fclose(fptr2);
  10893. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10894. system(str);
  10895. // clear temp file
  10896. sprintf(str,"rm -f %s",temp);
  10897. system(str);
  10898. }
  10899. else
  10900. {
  10901. fclose(fptr1);
  10902. fclose(fptr2);
  10903. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10904. system(str);
  10905. resultRename = rename(temp, chargingProfiles[k]);
  10906. if(resultRename == 0)
  10907. {
  10908. DEBUG_INFO("File ChargingProfile renamed successfully");
  10909. }
  10910. else
  10911. {
  10912. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  10913. }
  10914. if(comfirmstr[0]== 0)
  10915. {
  10916. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  10917. }
  10918. //Check chargingProfile is empty file
  10919. /*------ Read the file ----------------*/
  10920. fptr1=fopen(chargingProfiles[k],"r");
  10921. ch=fgetc(fptr1);
  10922. rewind(fptr1);
  10923. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  10924. if(ch!=EOF)
  10925. {
  10926. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  10927. {
  10928. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  10929. if(sLineWord[0]=='\0')
  10930. {
  10931. isEmptyFile = TRUE;
  10932. break;
  10933. }
  10934. else
  10935. {
  10936. isEmptyFile = FALSE;
  10937. break;
  10938. }
  10939. }
  10940. }
  10941. else
  10942. isEmptyFile = TRUE;
  10943. fclose(fptr1);
  10944. if(isEmptyFile == TRUE)
  10945. {
  10946. memset(str, 0, ARRAY_SIZE(str));
  10947. sprintf(str,"rm -f %s",chargingProfiles[k]);
  10948. system(str);
  10949. }
  10950. /*------- End of reading ---------------*/
  10951. }
  10952. } // while(int k=0; k < ChargeProfileCount; k++)
  10953. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  10954. end:
  10955. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  10956. {
  10957. if(connectorIdInt == 0)
  10958. {
  10959. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  10960. {
  10961. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  10962. }
  10963. }
  10964. else
  10965. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1], 0, TRUE);
  10966. }
  10967. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  10968. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10969. return result;
  10970. }
  10971. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  10972. {
  10973. mtrace();
  10974. int result = FAIL;
  10975. json_object *ClearDisplayMessage;
  10976. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  10977. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  10978. ClearDisplayMessage = json_tokener_parse(payload);
  10979. if(!is_error(ClearDisplayMessage))
  10980. {
  10981. // Required data
  10982. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  10983. {
  10984. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  10985. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  10986. }
  10987. }
  10988. json_object_put(ClearDisplayMessage);
  10989. sendCostUpdatedConfirmation(uuid);
  10990. return result;
  10991. }
  10992. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  10993. {
  10994. mtrace();
  10995. int result = FAIL;
  10996. json_object *ClearVariableMonitorin;
  10997. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  10998. ClearVariableMonitorin = json_tokener_parse(payload);
  10999. if(!is_error(ClearVariableMonitorin))
  11000. {
  11001. // Required data
  11002. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  11003. {
  11004. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  11005. {
  11006. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  11007. /*
  11008. * TODO:
  11009. * 1. Check response
  11010. */
  11011. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  11012. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  11013. }
  11014. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  11015. }
  11016. }
  11017. json_object_put(ClearVariableMonitorin);
  11018. return result;
  11019. }
  11020. int handleCostUpdatedRequest(char *uuid, char *payload)
  11021. {
  11022. mtrace();
  11023. int result = FAIL;
  11024. json_object *CostUpdate;
  11025. DEBUG_INFO("handleCostUpdatedRequest...\n");
  11026. CostUpdate = json_tokener_parse(payload);
  11027. if(!is_error(CostUpdate))
  11028. {
  11029. // Required data
  11030. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  11031. {
  11032. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  11033. }
  11034. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  11035. {
  11036. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  11037. }
  11038. }
  11039. json_object_put(CostUpdate);
  11040. sendCostUpdatedConfirmation(uuid);
  11041. return result;
  11042. }
  11043. int handleCustomerInformationRequest(char *uuid, char *payload)
  11044. {
  11045. mtrace();
  11046. int result = FAIL;
  11047. json_object *CustomerInformation;
  11048. DEBUG_INFO("handleCustomerInformationRequest...\n");
  11049. CustomerInformation = json_tokener_parse(payload);
  11050. if(!is_error(CustomerInformation))
  11051. {
  11052. // Required data
  11053. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  11054. {
  11055. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  11056. }
  11057. if(json_object_object_get(CustomerInformation, "report") != NULL)
  11058. {
  11059. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  11060. }
  11061. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  11062. {
  11063. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  11064. }
  11065. // Optional data
  11066. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  11067. {
  11068. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  11069. {
  11070. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  11071. }
  11072. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  11073. {
  11074. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  11075. }
  11076. }
  11077. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  11078. {
  11079. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  11080. {
  11081. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  11082. }
  11083. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  11084. {
  11085. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  11086. }
  11087. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  11088. {
  11089. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  11090. }
  11091. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  11092. {
  11093. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  11094. }
  11095. }
  11096. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  11097. }
  11098. else
  11099. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  11100. json_object_put(CustomerInformation);
  11101. sendCustomerInformationConfirmation(uuid);
  11102. return result;
  11103. }
  11104. void createFirmwareVersionByDataTransfer(void)
  11105. {
  11106. json_object *FirmwareDataTransfer = json_object_new_object();
  11107. // AC & DC model
  11108. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  11109. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  11110. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  11111. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  11112. // DC model
  11113. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  11114. {
  11115. if((gunType[1] != GUN_TYPE_UNKNOWN) ||
  11116. (gunType[2] != GUN_TYPE_UNKNOWN) ||
  11117. (gunType[3] != GUN_TYPE_UNKNOWN))
  11118. {
  11119. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  11120. }
  11121. if((ShmSysConfigAndInfo->SysConfig.ModelName[1]!='B') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='K') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O'))
  11122. {
  11123. // DS DM DW
  11124. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  11125. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  11126. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  11127. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  11128. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  11129. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  11130. }
  11131. else
  11132. {
  11133. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  11134. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  11135. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  11136. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  11137. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  11138. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  11139. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  11140. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  11141. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  11142. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  11143. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  11144. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  11145. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  11146. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  11147. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  11148. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  11149. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  11150. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  11151. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  11152. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  11153. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  11154. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  11155. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  11156. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  11157. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  11158. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  11159. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  11160. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  11161. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  11162. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  11163. json_object_object_add(FirmwareDataTransfer, "D11_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  11164. }
  11165. }
  11166. // 4G model
  11167. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  11168. {
  11169. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  11170. }
  11171. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  11172. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  11173. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
  11174. json_object_put(FirmwareDataTransfer);
  11175. }
  11176. int handleDataTransferRequest(char *uuid, char *payload)
  11177. {
  11178. mtrace();
  11179. int result = PASS;
  11180. DEBUG_INFO("handleDataTransferRequest...\n");
  11181. if((uuid != NULL) && (payload != NULL))
  11182. {
  11183. json_object *DataTransfer;
  11184. DataTransfer = json_tokener_parse(payload);
  11185. if(!is_error(DataTransfer))
  11186. {
  11187. // Required data
  11188. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  11189. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  11190. // Optional data
  11191. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  11192. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  11193. if(json_object_object_get(DataTransfer, "data") != NULL)
  11194. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  11195. result = PASS;
  11196. }
  11197. json_object_put(DataTransfer);
  11198. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  11199. {
  11200. // Send all moudle firmware version on EVSE
  11201. createFirmwareVersionByDataTransfer();
  11202. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11203. }
  11204. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  11205. {
  11206. system("/usr/bin/run_tmate_restart.sh &");
  11207. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11208. }
  11209. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  11210. {
  11211. json_object *data;
  11212. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11213. if(!is_error(data))
  11214. {
  11215. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  11216. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  11217. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  11218. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  11219. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  11220. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  11221. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  11222. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  11223. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  11224. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  11225. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11226. }
  11227. else
  11228. {
  11229. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11230. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11231. }
  11232. json_object_put(data);
  11233. }
  11234. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_ConfigQR") != NULL)
  11235. {
  11236. json_object *data;
  11237. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11238. if(!is_error(data))
  11239. {
  11240. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11241. if(json_object_object_get(data, "Content_Type") != NULL)
  11242. {
  11243. 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))
  11244. {
  11245. ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode = json_object_get_int(json_object_object_get(data, "Content_Type"));
  11246. if(json_object_object_get(data, "Customization_Conent") != NULL)
  11247. {
  11248. sprintf((char*)ShmSysConfigAndInfo->SysConfig.QRCodeContent, "%s", json_object_get_string(json_object_object_get(data, "Customization_Conent")));
  11249. }
  11250. }
  11251. else
  11252. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11253. }
  11254. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  11255. }
  11256. else
  11257. {
  11258. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11259. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11260. }
  11261. json_object_put(data);
  11262. }
  11263. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_DsiplayLcdPage") != NULL)
  11264. {
  11265. json_object *data;
  11266. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11267. if(!is_error(data))
  11268. {
  11269. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11270. if(json_object_object_get(data, "Page_Index") != NULL)
  11271. {
  11272. ShmSysConfigAndInfo->SysConfig.LcdOveride.page_index = json_object_get_int(json_object_object_get(data, "Page_Index"));
  11273. }
  11274. if(json_object_object_get(data, "Duration") != NULL)
  11275. {
  11276. ShmSysConfigAndInfo->SysConfig.LcdOveride.duration = json_object_get_int(json_object_object_get(data, "Duration"));
  11277. }
  11278. ShmSysConfigAndInfo->SysConfig.LcdOveride.isOverideReq = 1;
  11279. }
  11280. else
  11281. {
  11282. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11283. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11284. }
  11285. json_object_put(data);
  11286. }
  11287. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_CpConfiguration") != NULL)
  11288. {
  11289. json_object *data;
  11290. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  11291. if(!is_error(data))
  11292. {
  11293. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  11294. if(json_object_object_get(data, "MaxChargingCurrent") != NULL)
  11295. {
  11296. if(json_object_get_int(json_object_object_get(data, "MaxChargingCurrent")) >= 0)
  11297. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent = json_object_get_int(json_object_object_get(data, "MaxChargingCurrent"));
  11298. else
  11299. {
  11300. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11301. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11302. }
  11303. }
  11304. if(json_object_object_get(data, "MaxChargingDuration") != NULL)
  11305. {
  11306. if(json_object_get_int(json_object_object_get(data, "MaxChargingDuration")) >= 0)
  11307. ShmSysConfigAndInfo->SysConfig.MaxChargingDuration = json_object_get_int(json_object_object_get(data, "MaxChargingDuration"));
  11308. else
  11309. {
  11310. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11311. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11312. }
  11313. }
  11314. if(json_object_object_get(data, "MaxChargingEnergy") != NULL)
  11315. {
  11316. if(json_object_get_int(json_object_object_get(data, "MaxChargingEnergy")) >= 0)
  11317. ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy = json_object_get_int(json_object_object_get(data, "MaxChargingEnergy"));
  11318. else
  11319. {
  11320. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11321. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11322. }
  11323. }
  11324. if(json_object_object_get(data, "MaxChargingPower") != NULL)
  11325. {
  11326. if(json_object_get_int(json_object_object_get(data, "MaxChargingPower")) >= 0)
  11327. ShmSysConfigAndInfo->SysConfig.MaxChargingPower = json_object_get_int(json_object_object_get(data, "MaxChargingPower"));
  11328. else
  11329. {
  11330. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11331. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11332. }
  11333. }
  11334. if(json_object_object_get(data, "OfflineMaxChargeEnergy") != NULL)
  11335. {
  11336. if(json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy")) >= 0)
  11337. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy"));
  11338. else
  11339. {
  11340. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11341. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11342. }
  11343. }
  11344. if(json_object_object_get(data, "OfflinePolicy") != NULL)
  11345. {
  11346. if((json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 0) ||
  11347. (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 2) ||
  11348. (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 3))
  11349. ShmSysConfigAndInfo->SysConfig.OfflinePolicy = json_object_get_int(json_object_object_get(data, "OfflinePolicy"));
  11350. else
  11351. {
  11352. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11353. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11354. }
  11355. }
  11356. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]) != NULL)
  11357. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  11358. }
  11359. else
  11360. {
  11361. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  11362. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  11363. }
  11364. json_object_put(data);
  11365. }
  11366. else
  11367. {
  11368. // Can not find valid message id
  11369. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  11370. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  11371. ,ShmOCPP20Data->DataTransfer[0].vendorId
  11372. ,ShmOCPP20Data->DataTransfer[0].messageId
  11373. ,ShmOCPP20Data->DataTransfer[0].data);
  11374. }
  11375. }
  11376. else
  11377. {
  11378. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  11379. result = FAIL;
  11380. }
  11381. sendDataTransferConfirmation(uuid, 0);
  11382. return result;
  11383. }
  11384. int handleDeleteCertificateRequest(char *uuid, char *payload)
  11385. {
  11386. mtrace();
  11387. int result = FAIL;
  11388. json_object *DeleteCertificate;
  11389. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  11390. DeleteCertificate = json_tokener_parse(payload);
  11391. if(!is_error(DeleteCertificate))
  11392. {
  11393. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  11394. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  11395. // Required data
  11396. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  11397. {
  11398. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  11399. {
  11400. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  11401. }
  11402. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  11403. {
  11404. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  11405. }
  11406. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  11407. {
  11408. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  11409. }
  11410. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  11411. {
  11412. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  11413. }
  11414. /*
  11415. * TODO:
  11416. * 1. Delete certification and response
  11417. */
  11418. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  11419. }
  11420. }
  11421. else
  11422. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  11423. json_object_put(DeleteCertificate);
  11424. sendDeleteCertificateConfirmation(uuid);
  11425. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11426. return result;
  11427. }
  11428. int handleGetBaseReportRequest(char *uuid, char *payload)
  11429. {
  11430. mtrace();
  11431. int result = FAIL;
  11432. json_object *GetBaseRepor;
  11433. DEBUG_INFO("handleGetBaseReportRequest...\n");
  11434. GetBaseRepor = json_tokener_parse(payload);
  11435. if(!is_error(GetBaseRepor))
  11436. {
  11437. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  11438. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  11439. // Required data
  11440. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  11441. {
  11442. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  11443. }
  11444. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  11445. {
  11446. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  11447. }
  11448. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_SummaryInventory]) == 0)
  11449. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  11450. else
  11451. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  11452. }
  11453. else
  11454. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  11455. json_object_put(GetBaseRepor);
  11456. sendGetBaseReportConfirmation(uuid);
  11457. return result;
  11458. }
  11459. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  11460. {
  11461. mtrace();
  11462. int result = FAIL;
  11463. int gun_index = -1;
  11464. json_object *GetChargingProfiles;
  11465. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  11466. GetChargingProfiles = json_tokener_parse(payload);
  11467. if(!is_error(GetChargingProfiles))
  11468. {
  11469. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  11470. {
  11471. 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;
  11472. }
  11473. if(gun_index >-1)
  11474. {
  11475. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  11476. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  11477. // Required data
  11478. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  11479. {
  11480. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  11481. }
  11482. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  11483. {
  11484. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  11485. {
  11486. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  11487. }
  11488. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  11489. {
  11490. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  11491. }
  11492. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  11493. {
  11494. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  11495. {
  11496. 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)));
  11497. }
  11498. }
  11499. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  11500. {
  11501. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  11502. {
  11503. 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));
  11504. }
  11505. }
  11506. }
  11507. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  11508. }
  11509. else
  11510. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  11511. }
  11512. json_object_put(GetChargingProfiles);
  11513. sendGetChargingProfilesConfirmation(uuid, gun_index);
  11514. return result;
  11515. }
  11516. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  11517. {
  11518. mtrace();
  11519. int result = FAIL;
  11520. int connectorIdInt, durationInt;
  11521. char chargingRateUnitStr[4]={0};
  11522. char comfirmstr[20];
  11523. int confirmPeriods = 0;
  11524. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  11525. json_object *GetCompositeSchedule;
  11526. GetCompositeSchedule = json_tokener_parse(payload);
  11527. if(!is_error(GetCompositeSchedule))
  11528. {
  11529. // Required data
  11530. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  11531. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  11532. else
  11533. connectorIdInt = -1;
  11534. if(json_object_object_get(GetCompositeSchedule, "duration"))
  11535. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  11536. else
  11537. durationInt = 86400;
  11538. // Optional data
  11539. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  11540. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  11541. }
  11542. json_object_put(GetCompositeSchedule);
  11543. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  11544. if((connectorIdInt == 0) ||
  11545. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  11546. {
  11547. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  11548. struct ChargingProfileType tmpProfile[1];
  11549. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  11550. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  11551. if(strstr(chargingRateUnitStr, "W") != NULL)
  11552. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, FALSE);
  11553. else
  11554. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, TRUE);
  11555. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  11556. {
  11557. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  11558. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  11559. }
  11560. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  11561. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  11562. {
  11563. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  11564. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  11565. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  11566. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0) &&
  11567. (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))
  11568. {
  11569. confirmPeriods = idx;
  11570. break;
  11571. }
  11572. }
  11573. if((confirmPeriods == 0) && (tmpProfile[0].id > 0))
  11574. {
  11575. confirmPeriods += 1;
  11576. }
  11577. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  11578. }
  11579. else
  11580. {
  11581. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  11582. }
  11583. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  11584. return result;
  11585. }
  11586. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  11587. {
  11588. mtrace();
  11589. int result = FAIL;
  11590. json_object *GetDisplayMessages;
  11591. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  11592. GetDisplayMessages = json_tokener_parse(payload);
  11593. if(!is_error(GetDisplayMessages))
  11594. {
  11595. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  11596. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  11597. // Required data
  11598. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  11599. {
  11600. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  11601. }
  11602. // Optional data
  11603. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  11604. {
  11605. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  11606. }
  11607. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  11608. {
  11609. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  11610. }
  11611. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  11612. {
  11613. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  11614. {
  11615. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  11616. }
  11617. strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  11618. ShmOCPP20Data->MsMsg.bits.GetDisplayMessagesReq = ON;
  11619. }
  11620. else
  11621. strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  11622. }
  11623. json_object_put(GetDisplayMessages);
  11624. return result;
  11625. }
  11626. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  11627. {
  11628. mtrace();
  11629. int result = FAIL;
  11630. json_object *GetInstalledCertificateIds;
  11631. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  11632. GetInstalledCertificateIds = json_tokener_parse(payload);
  11633. if(!is_error(GetInstalledCertificateIds))
  11634. {
  11635. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  11636. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  11637. // Optional data
  11638. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  11639. {
  11640. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  11641. {
  11642. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  11643. /*
  11644. * TODO:
  11645. * 1. Get installed certificate info for response
  11646. */
  11647. }
  11648. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  11649. }
  11650. else
  11651. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  11652. }
  11653. json_object_put(GetInstalledCertificateIds);
  11654. sendInstallCertificateConfirmation(uuid);
  11655. return result;
  11656. }
  11657. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  11658. {
  11659. mtrace();
  11660. int result = FAIL;
  11661. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  11662. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  11663. {
  11664. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  11665. localversion = -1;
  11666. }
  11667. else
  11668. {
  11669. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  11670. DB_getListVerion();
  11671. }
  11672. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  11673. sendGetLocalListVersionConfirmation(uuid);
  11674. return result;
  11675. }
  11676. static char fnamePlusPath[100]={0};
  11677. static char fnamePWithNoPath[60]={0};
  11678. void checkUploadLog(void)
  11679. {
  11680. FILE *fp;
  11681. /* Open the command for reading. */
  11682. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  11683. if (fp == NULL) {
  11684. printf("Failed to run command\n" );
  11685. exit(1);
  11686. }
  11687. int ftppathlen = 0;
  11688. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  11689. int i = 0;
  11690. /* Read the output a line at a time - output it. */
  11691. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  11692. if(i==0)
  11693. {
  11694. ftppathlen = strlen(fnamePlusPath);
  11695. printf("%s\n", fnamePlusPath);
  11696. fnamePlusPath[ftppathlen]='\0';
  11697. break;
  11698. }
  11699. i= i+1;
  11700. }
  11701. /* close */
  11702. pclose(fp);
  11703. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  11704. {
  11705. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  11706. {
  11707. fnamePlusPath[k]='\0';
  11708. }
  11709. }
  11710. i=1;
  11711. //char fname[60]={0};
  11712. while(i < ftppathlen)
  11713. {
  11714. int len=ftppathlen-i;
  11715. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  11716. {
  11717. printf("compare '/' all right\n");
  11718. break;
  11719. }
  11720. i=i+1;
  11721. }
  11722. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  11723. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  11724. fnamePWithNoPath[i+1] = '\0';
  11725. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  11726. {
  11727. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  11728. {
  11729. fnamePWithNoPath[j]='\0';
  11730. }
  11731. }
  11732. FILE* fp1 = fopen(fnamePlusPath, "r");
  11733. if (fp1)
  11734. {
  11735. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  11736. // file exists
  11737. fclose(fp1);
  11738. }
  11739. else
  11740. {
  11741. // file doesn't exist
  11742. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  11743. }
  11744. }
  11745. void* GetLogProcess(void* data)
  11746. {
  11747. pthread_detach(pthread_self());
  11748. mtrace();
  11749. int requestId, retriesInt=0, retryIntervalInt=0;
  11750. char logType[32], remoteLocation[1024]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  11751. 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};
  11752. int port=0;
  11753. int isSuccess = FALSE;
  11754. char ftpbuf[1024]={0};
  11755. char cmdBuf[2048];
  11756. struct tm *tmNow;
  11757. time_t CurrentTime;
  11758. struct tm tmStart;
  11759. struct tm tmStop;
  11760. CurrentTime = time(NULL);
  11761. tmNow=localtime(&CurrentTime);
  11762. uint16_t targetYear, targetMonth;
  11763. json_object *GetLog;
  11764. DEBUG_INFO("GetGetProcess...\n");
  11765. GetLog = json_tokener_parse(data);
  11766. if(!is_error(GetLog))
  11767. {
  11768. // Required data
  11769. if(json_object_object_get(GetLog, "requestId") != NULL)
  11770. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  11771. if(json_object_object_get(GetLog, "logType") != NULL)
  11772. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  11773. if(json_object_object_get(GetLog, "log") != NULL)
  11774. {
  11775. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  11776. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  11777. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  11778. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  11779. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  11780. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  11781. }
  11782. // Optional data
  11783. if(json_object_object_get(GetLog, "retries") != NULL)
  11784. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  11785. else
  11786. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  11787. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  11788. retryIntervalInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  11789. else
  11790. retryIntervalInt = 30;
  11791. }
  11792. json_object_put(GetLog);
  11793. ShmOCPP20Data->GetLog.requestId = requestId;
  11794. // Pack log to compress file
  11795. 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) &&
  11796. (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))
  11797. {
  11798. // Pack system log
  11799. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  11800. sprintf(cmdBuf, "exec zip -9 --password %04d%02d%s /mnt/system.zip", tmNow->tm_year+1900, tmNow->tm_mon+1, ShmSysConfigAndInfo->SysConfig.SerialNumber);
  11801. targetYear = tmStart.tm_year;
  11802. targetMonth = tmStart.tm_mon;
  11803. do
  11804. {
  11805. sprintf(cmdBuf, "%s /Storage/SystemLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  11806. sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  11807. if(targetMonth+1>=13)
  11808. {
  11809. targetYear += 1;
  11810. targetMonth = 1;
  11811. }
  11812. else
  11813. {
  11814. targetMonth += 1;
  11815. }
  11816. }while((targetYear < (tmNow->tm_year+1900)) ||
  11817. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  11818. sprintf(cmdBuf, "%s /Storage/CCS*.zip", cmdBuf);
  11819. system(cmdBuf);
  11820. // Pack charging & event log
  11821. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  11822. sprintf(cmdBuf, "exec zip -9 /mnt/charging_event.zip");
  11823. targetYear = tmStart.tm_year;
  11824. targetMonth = tmStart.tm_mon;
  11825. do
  11826. {
  11827. sprintf(cmdBuf, "%s /Storage/EventLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  11828. if(targetMonth+1>=13)
  11829. {
  11830. targetYear += 1;
  11831. targetMonth = 1;
  11832. }
  11833. else
  11834. {
  11835. targetMonth += 1;
  11836. }
  11837. }while((targetYear < (tmNow->tm_year+1900)) ||
  11838. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  11839. sprintf(cmdBuf, "%s /Storage/ChargeLog/*.db", cmdBuf);
  11840. sprintf(cmdBuf, "%s /Storage/EventLog/*.db", cmdBuf);
  11841. system(cmdBuf);
  11842. // Combine log file
  11843. system("exec zip -9 /mnt/log.zip /mnt/system.zip /mnt/charging_event.zip");
  11844. system("exec rm -f /mnt/system.zip /mnt/charging_event.zip");
  11845. }
  11846. else
  11847. {
  11848. system("exec /root/logPackTools 'log' 6");
  11849. }
  11850. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", ShmOCPP20Data->GetLog.Response_filename);
  11851. system(cmdBuf);
  11852. checkUploadLog();
  11853. //****************location*******************/
  11854. if(strcmp(remoteLocation,"")==0)
  11855. {
  11856. DEBUG_INFO("remoteLocation is <Empty>!\n");
  11857. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  11858. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  11859. goto end;
  11860. }
  11861. memset(protocol, 0, ARRAY_SIZE(protocol));
  11862. memset(user, 0, ARRAY_SIZE(user) );
  11863. memset(password, 0, ARRAY_SIZE(password));
  11864. memset(host, 0, ARRAY_SIZE(host));
  11865. memset(path, 0, ARRAY_SIZE(path));
  11866. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  11867. memset(host1, 0, ARRAY_SIZE(host1));
  11868. memset(path1, 0, ARRAY_SIZE(path1));
  11869. /*location: ftp://user:password@host:port/path*/
  11870. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  11871. if((access(fnamePlusPath,F_OK))!=-1)
  11872. {
  11873. DEBUG_INFO("fnamePlusPath exist.\n");
  11874. }
  11875. else
  11876. {
  11877. DEBUG_INFO("fnamePlusPath not exist!\n");
  11878. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  11879. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  11880. goto end;
  11881. }
  11882. if(strchr(remoteLocation,'@')==NULL)
  11883. {
  11884. sscanf(remoteLocation,
  11885. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  11886. protocol, host, &port, path);
  11887. strcpy(user,"anonymous");
  11888. strcpy(password,"");
  11889. }
  11890. else
  11891. {
  11892. //DEBUG_INFO("pch=%s\n", pch);
  11893. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  11894. protocol, user, password, host, &port, path);
  11895. }
  11896. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0)&&(strcmp(protocol,"https")!=0))
  11897. {
  11898. DEBUG_INFO("protocol is not ftp/http ! \n");
  11899. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  11900. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  11901. goto end;
  11902. }
  11903. if(strncmp(remoteLocation,"http", 4) == 0)
  11904. {
  11905. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  11906. sprintf(ftppath,"/%s", path);
  11907. do
  11908. {
  11909. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  11910. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  11911. sleep(3);
  11912. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  11913. if(!isSuccess)
  11914. {
  11915. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  11916. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  11917. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  11918. sleep(retryIntervalInt);
  11919. }
  11920. else
  11921. {
  11922. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  11923. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  11924. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  11925. }
  11926. retriesInt--;
  11927. }while((isSuccess == 0)&&(retriesInt >= 0));
  11928. }
  11929. else
  11930. {
  11931. sscanf(host,"%[^/]%s",host1, path1);
  11932. if(strlen(path) > 0)
  11933. sprintf(ftppath,"/%s", path);
  11934. else
  11935. sprintf(ftppath,"/%s", path1);
  11936. int ftppathlen=strlen(ftppath);
  11937. int i=1;
  11938. char filenametemp[50];
  11939. while(i < ftppathlen)
  11940. {
  11941. int len=ftppathlen-i;
  11942. if(ftppath[len]== 47) // '/' ascll code: 47
  11943. {
  11944. DEBUG_INFO("find '/' all right\n");
  11945. break;
  11946. }
  11947. i=i+1;
  11948. }
  11949. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  11950. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  11951. filenametemp[i+1] = 0;
  11952. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  11953. if(port == 0)
  11954. port = 21;
  11955. do
  11956. {
  11957. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  11958. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  11959. sleep(3);
  11960. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  11961. if(!isSuccess)
  11962. {
  11963. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  11964. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  11965. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  11966. sleep(retryIntervalInt);
  11967. }
  11968. else
  11969. {
  11970. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  11971. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  11972. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  11973. }
  11974. retriesInt--;
  11975. }while((!isSuccess)&&(retriesInt >= 0));
  11976. }
  11977. end:
  11978. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  11979. pthread_exit(NULL);
  11980. }
  11981. int handleGetLogRequest(char *uuid, char *payload)
  11982. {
  11983. mtrace();
  11984. int result = FAIL;
  11985. char fName[258];
  11986. time_t CurrentTime;
  11987. struct tm *tm;
  11988. pthread_t th_Status;
  11989. CurrentTime = time(NULL);
  11990. tm = localtime(&CurrentTime);
  11991. 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);
  11992. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  11993. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  11994. sendGetLogConfirmation(uuid);
  11995. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  11996. return result;
  11997. }
  11998. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  11999. {
  12000. mtrace();
  12001. int result = FAIL;
  12002. json_object *GetMonitoringReport;
  12003. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  12004. GetMonitoringReport = json_tokener_parse(payload);
  12005. if(!is_error(GetMonitoringReport))
  12006. {
  12007. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  12008. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  12009. // Required data
  12010. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  12011. {
  12012. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  12013. }
  12014. // Optional data
  12015. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  12016. {
  12017. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  12018. }
  12019. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  12020. {
  12021. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  12022. {
  12023. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  12024. {
  12025. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  12026. {
  12027. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  12028. {
  12029. 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")));
  12030. }
  12031. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  12032. {
  12033. 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")));
  12034. }
  12035. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  12036. {
  12037. 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)
  12038. {
  12039. 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"));
  12040. }
  12041. 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)
  12042. {
  12043. 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"));
  12044. }
  12045. }
  12046. }
  12047. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  12048. {
  12049. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  12050. {
  12051. 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")));
  12052. }
  12053. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  12054. {
  12055. 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")));
  12056. }
  12057. }
  12058. }
  12059. }
  12060. }
  12061. }
  12062. json_object_put(GetMonitoringReport);
  12063. /*
  12064. * TODO:
  12065. * 1. Response result
  12066. */
  12067. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12068. sendGetMonitoringReportConfirmation(uuid);
  12069. return result;
  12070. }
  12071. int handleGetReportRequest(char *uuid, char *payload)
  12072. {
  12073. mtrace();
  12074. int result = FAIL;
  12075. json_object *GetReport;
  12076. DEBUG_INFO("handleGetReportRequest...\n");
  12077. GetReport = json_tokener_parse(payload);
  12078. if(!is_error(GetReport))
  12079. {
  12080. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  12081. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  12082. // Required data
  12083. if(json_object_object_get(GetReport, "requestId") != NULL)
  12084. {
  12085. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  12086. }
  12087. // Optional data
  12088. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  12089. {
  12090. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  12091. }
  12092. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  12093. {
  12094. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  12095. {
  12096. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  12097. {
  12098. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  12099. {
  12100. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  12101. {
  12102. 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")));
  12103. }
  12104. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  12105. {
  12106. 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")));
  12107. }
  12108. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  12109. {
  12110. 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)
  12111. {
  12112. ShmOCPP20Data->GetReport.componentVariable[idx].component.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance"), "id"));
  12113. }
  12114. 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)
  12115. {
  12116. ShmOCPP20Data->GetReport.componentVariable[idx].component.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance"), "connectorId"));
  12117. }
  12118. }
  12119. }
  12120. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  12121. {
  12122. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  12123. {
  12124. 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")));
  12125. }
  12126. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  12127. {
  12128. 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")));
  12129. }
  12130. }
  12131. }
  12132. }
  12133. }
  12134. }
  12135. json_object_put(GetReport);
  12136. /*
  12137. * TODO:
  12138. * 1. Response result
  12139. */
  12140. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12141. sendGetReportConfirmation(uuid);
  12142. return result;
  12143. }
  12144. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  12145. {
  12146. mtrace();
  12147. int result = FAIL;
  12148. int8_t gun_index = -1;
  12149. json_object *GetTransactionStatus;
  12150. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  12151. GetTransactionStatus = json_tokener_parse(payload);
  12152. if(!is_error(GetTransactionStatus))
  12153. {
  12154. /*
  12155. * TODO:
  12156. * 1. Check transaction locate which connector
  12157. */
  12158. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  12159. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  12160. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  12161. {
  12162. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  12163. }
  12164. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  12165. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  12166. }
  12167. json_object_put(GetTransactionStatus);
  12168. sendGetTransactionStatusConfirmation(uuid, gun_index);
  12169. return result;
  12170. }
  12171. int handleGetVariablesRequest(char *uuid, char *payload)
  12172. {
  12173. mtrace();
  12174. int result = FAIL;
  12175. json_object *GetVariables;
  12176. DEBUG_INFO("handleGetVariablesRequest...\n");
  12177. GetVariables = json_tokener_parse(payload);
  12178. if(!is_error(GetVariables))
  12179. {
  12180. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  12181. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  12182. // Required data
  12183. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  12184. {
  12185. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  12186. {
  12187. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  12188. {
  12189. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  12190. {
  12191. 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")));
  12192. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  12193. }
  12194. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  12195. {
  12196. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  12197. {
  12198. 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")));
  12199. }
  12200. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  12201. {
  12202. 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")));
  12203. }
  12204. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  12205. {
  12206. 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)
  12207. {
  12208. 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"));
  12209. }
  12210. 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)
  12211. {
  12212. 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"));
  12213. }
  12214. }
  12215. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  12216. }
  12217. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  12218. {
  12219. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  12220. {
  12221. 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")));
  12222. }
  12223. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  12224. {
  12225. 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")));
  12226. }
  12227. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  12228. }
  12229. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  12230. {
  12231. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
  12232. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance) == 0) &&
  12233. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
  12234. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance) == 0))
  12235. {
  12236. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  12237. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  12238. break;
  12239. }
  12240. else
  12241. {
  12242. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  12243. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  12244. }
  12245. }
  12246. }
  12247. }
  12248. }
  12249. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  12250. }
  12251. json_object_put(GetVariables);
  12252. return result;
  12253. }
  12254. int handleInstallCertificateRequest(char *uuid, char *payload)
  12255. {
  12256. mtrace();
  12257. int result = FAIL;
  12258. json_object *InstallCertificate;
  12259. DEBUG_INFO("handleInstallCertificateRequest...\n");
  12260. InstallCertificate = json_tokener_parse(payload);
  12261. if(!is_error(InstallCertificate))
  12262. {
  12263. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  12264. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  12265. // Required data
  12266. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  12267. {
  12268. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  12269. }
  12270. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  12271. {
  12272. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  12273. }
  12274. }
  12275. json_object_put(InstallCertificate);
  12276. /*
  12277. * TODO:
  12278. * 1. Install certification preocess and response
  12279. */
  12280. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12281. sendInstallCertificateConfirmation(uuid);
  12282. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  12283. return result;
  12284. }
  12285. int handlePublishFirmwareRequest(char *uuid, char *payload)
  12286. {
  12287. mtrace();
  12288. int result = FAIL;
  12289. json_object *PublishFirmware;
  12290. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  12291. PublishFirmware = json_tokener_parse(payload);
  12292. if(!is_error(PublishFirmware))
  12293. {
  12294. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  12295. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  12296. // Required data
  12297. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  12298. {
  12299. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  12300. }
  12301. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  12302. {
  12303. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  12304. }
  12305. // Optional data
  12306. if(json_object_object_get(PublishFirmware, "location") != NULL)
  12307. {
  12308. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  12309. }
  12310. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  12311. {
  12312. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  12313. }
  12314. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  12315. {
  12316. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  12317. }
  12318. }
  12319. json_object_put(PublishFirmware);
  12320. /*
  12321. * TODO:
  12322. * 1. Publish firmware preocess and response
  12323. */
  12324. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12325. sendPublishFirmwareConfirmation(uuid);
  12326. return result;
  12327. }
  12328. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  12329. {
  12330. mtrace();
  12331. int result = FAIL;
  12332. int8_t gun_index = -1;
  12333. uint8_t isPeriodOverMax = FALSE;
  12334. uint8_t isProfileOverMax = FALSE;
  12335. uint8_t isConnectorMismatch = FALSE;
  12336. uint8_t isTxProfile = TRUE;
  12337. uint8_t existProfileQuantity = 0;
  12338. uint8_t filename[128]={0};
  12339. uint8_t word[2048]={0};
  12340. FILE *filePtr;
  12341. json_object *RemoteStartTransaction;
  12342. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  12343. RemoteStartTransaction = json_tokener_parse(payload);
  12344. if(!is_error(RemoteStartTransaction))
  12345. {
  12346. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  12347. {
  12348. gun_index = (json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))>0)?(json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))-1):-1;
  12349. }
  12350. else
  12351. {
  12352. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  12353. {
  12354. if(!cpinitateMsg.bits[idx].isOnCharging && (strstr((char*)ShmOCPP20Data->StatusNotification[idx].connectorStatus, ConnectorStatusEnumTypeStr[ConnectorStatusEnumType_Occupied]) != NULL))
  12355. {
  12356. gun_index = idx;
  12357. DEBUG_INFO("Remote start without connectorId but detect connector-%02d connected ready to start.\n", (gun_index+1));
  12358. break;
  12359. }
  12360. }
  12361. }
  12362. if(gun_index >= 0)
  12363. {
  12364. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  12365. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  12366. // Required data
  12367. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  12368. {
  12369. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  12370. }
  12371. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  12372. {
  12373. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  12374. {
  12375. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  12376. }
  12377. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  12378. {
  12379. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  12380. }
  12381. }
  12382. // Optional data
  12383. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  12384. {
  12385. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  12386. {
  12387. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  12388. }
  12389. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  12390. {
  12391. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  12392. }
  12393. }
  12394. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  12395. {
  12396. // Check periods is over max configuration
  12397. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  12398. {
  12399. isPeriodOverMax = TRUE;
  12400. }
  12401. // Check periods is over max configuration
  12402. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  12403. {
  12404. if(gun_index >= 0)
  12405. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", (gun_index+1));
  12406. else
  12407. isConnectorMismatch = TRUE;
  12408. if(!isConnectorMismatch)
  12409. {
  12410. filePtr = fopen((char*)filename, "r");
  12411. if (!filePtr)
  12412. {
  12413. DEBUG_INFO("%s not exist, create it.\n", filename);
  12414. filePtr = fopen((char*)filename, "w+");
  12415. }
  12416. else
  12417. {
  12418. //Check Charging Profile Count
  12419. while(fscanf(filePtr, "%s", word) != EOF)
  12420. {
  12421. //DEBUG_INFO("word=%s\n",word);
  12422. if(strstr((char*)word, "chargingProfileId")!= NULL)
  12423. {
  12424. existProfileQuantity += 1;
  12425. }
  12426. }
  12427. }
  12428. fclose(filePtr);
  12429. }
  12430. }
  12431. else
  12432. {
  12433. isTxProfile = FALSE;
  12434. }
  12435. if(existProfileQuantity > 3)
  12436. isProfileOverMax = TRUE;
  12437. }
  12438. }
  12439. // Profile replace or add info
  12440. if((gun_index >= 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && isTxProfile)
  12441. {
  12442. FILE *infile;
  12443. FILE *outfile;
  12444. char tmpProfileName[32];
  12445. char rmFileCmd[128];
  12446. char tempchargingProfilePurposeStr[30]={0};
  12447. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  12448. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  12449. infile = fopen ((char*)filename, "r");
  12450. outfile = fopen ((char*)tmpProfileName, "w");
  12451. int d = fgetc(infile);
  12452. rewind(infile);
  12453. if(d == EOF)
  12454. {
  12455. // Profile is empty
  12456. fprintf(outfile,"%s\n", payload);
  12457. fclose(infile);
  12458. fclose(outfile);
  12459. sprintf(rmFileCmd,"rm -f %s",filename);
  12460. system(rmFileCmd);
  12461. rename((char*)tmpProfileName, (char*)filename);
  12462. }
  12463. else
  12464. {
  12465. // Profile is not empty
  12466. char buf[2048]={0};
  12467. int ChargingProfileAdded = FALSE;
  12468. while (fgets(buf, sizeof(buf), infile) != NULL)
  12469. {
  12470. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  12471. json_object *tmpChargingProfile;
  12472. tmpChargingProfile = json_tokener_parse(buf);
  12473. if(!is_error(tmpChargingProfile))
  12474. {
  12475. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  12476. {
  12477. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  12478. }
  12479. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  12480. {
  12481. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  12482. {
  12483. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  12484. }
  12485. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  12486. {
  12487. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  12488. }
  12489. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  12490. {
  12491. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  12492. }
  12493. }
  12494. }
  12495. json_object_put(tmpChargingProfile);
  12496. if((tempconnectorIdInt == (gun_index+1)) &&
  12497. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  12498. {
  12499. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  12500. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  12501. {
  12502. if(ChargingProfileAdded == FALSE)
  12503. {
  12504. fprintf(outfile,"%s\n",payload);
  12505. ChargingProfileAdded = TRUE;
  12506. }
  12507. }
  12508. else
  12509. {
  12510. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  12511. {
  12512. if(ChargingProfileAdded == FALSE)
  12513. {
  12514. fprintf(outfile,"%s\n",buf);
  12515. fprintf(outfile,"%s\n",payload);
  12516. ChargingProfileAdded = TRUE;
  12517. }
  12518. else
  12519. {
  12520. fprintf(outfile,"%s\n",buf);
  12521. }
  12522. }
  12523. else
  12524. {
  12525. if(ChargingProfileAdded == FALSE)
  12526. {
  12527. fprintf(outfile,"%s\n",buf);
  12528. fprintf(outfile,"%s\n",payload);
  12529. ChargingProfileAdded = TRUE;
  12530. }
  12531. else
  12532. {
  12533. fprintf(outfile,"%s\n",buf);
  12534. }
  12535. }
  12536. }
  12537. }
  12538. else
  12539. {
  12540. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  12541. {
  12542. if(ChargingProfileAdded == FALSE)
  12543. {
  12544. fprintf(outfile,"%s\n",buf);
  12545. fprintf(outfile,"%s\n",payload);
  12546. ChargingProfileAdded = TRUE;
  12547. }
  12548. else
  12549. {
  12550. fprintf(outfile,"%s\n",buf);
  12551. }
  12552. }
  12553. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  12554. {
  12555. if(ChargingProfileAdded == FALSE)
  12556. {
  12557. fprintf(outfile,"%s\n",buf);
  12558. fprintf(outfile,"%s\n",payload);
  12559. ChargingProfileAdded = TRUE;
  12560. }
  12561. else
  12562. {
  12563. fprintf(outfile,"%s\n",buf);
  12564. }
  12565. }
  12566. else
  12567. {
  12568. if(ChargingProfileAdded == FALSE)
  12569. {
  12570. fprintf(outfile,"%s\n",buf);
  12571. fprintf(outfile,"%s\n",payload);
  12572. ChargingProfileAdded = TRUE;
  12573. }
  12574. else
  12575. {
  12576. fprintf(outfile,"%s\n",buf);
  12577. }
  12578. }
  12579. }
  12580. } // end of while loop
  12581. fclose(infile);
  12582. fclose(outfile);
  12583. sprintf(rmFileCmd,"rm -f %s",filename);
  12584. system(rmFileCmd);
  12585. rename((char*)tmpProfileName, (char*)filename);
  12586. }
  12587. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  12588. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId);
  12589. result = PASS;
  12590. }
  12591. else
  12592. {
  12593. if(gun_index < 0)
  12594. DEBUG_WARN("Connector id is wrong.\n");
  12595. if(isConnectorMismatch)
  12596. DEBUG_WARN("Connector id is mismatch.\n");
  12597. if(isPeriodOverMax)
  12598. DEBUG_WARN("Profile periods quantity is over spec.\n");
  12599. if(isProfileOverMax)
  12600. DEBUG_WARN("Profile quantity is over spec.\n");
  12601. if(!isTxProfile)
  12602. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  12603. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index<0?0:gun_index)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  12604. }
  12605. }
  12606. json_object_put(RemoteStartTransaction);
  12607. sendRemoteStartTransactionConfirmation(uuid, (gun_index<0?0:gun_index));
  12608. return result;
  12609. }
  12610. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  12611. {
  12612. mtrace();
  12613. int result = FAIL;
  12614. int match = FALSE;
  12615. int GunNO = 0;
  12616. int tempIndex = 0;
  12617. char transactionIdStr[37];
  12618. int transactionIdIsNULL= TRUE;
  12619. json_object *RemoteStopTransaction;
  12620. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  12621. if(server_pending == TRUE)
  12622. {
  12623. return 0;
  12624. }
  12625. RemoteStopTransaction = json_tokener_parse(payload);
  12626. if(!is_error(RemoteStopTransaction))
  12627. {
  12628. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  12629. {
  12630. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  12631. transactionIdIsNULL = FALSE;
  12632. }
  12633. }
  12634. json_object_put(RemoteStopTransaction);
  12635. if(transactionIdIsNULL == FALSE)
  12636. {
  12637. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  12638. {
  12639. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  12640. {
  12641. //check Transaction active
  12642. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  12643. {
  12644. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12645. {
  12646. tempIndex = ((gun_index==2) ? 1: 0);
  12647. }
  12648. else
  12649. {
  12650. tempIndex = gun_index;
  12651. }
  12652. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12653. {
  12654. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  12655. {
  12656. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  12657. {
  12658. match = TRUE;
  12659. GunNO = gun_index;
  12660. }
  12661. }
  12662. }// END FOR CHAdeMO_QUANTITY
  12663. }
  12664. else if(gunType[gun_index] == GUN_TYPE_CCS)
  12665. {
  12666. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12667. {
  12668. tempIndex = ((gun_index==2) ? 1: 0);
  12669. }
  12670. else
  12671. {
  12672. tempIndex = gun_index;
  12673. }
  12674. for (int index = 0; index < CCS_QUANTITY; index++)
  12675. {
  12676. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  12677. {
  12678. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  12679. {
  12680. match = TRUE;
  12681. GunNO = gun_index;
  12682. }
  12683. }
  12684. }// END FOR CCS_QUANTITY
  12685. }
  12686. else if(gunType[gun_index] == GUN_TYPE_GBT)
  12687. {
  12688. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12689. {
  12690. tempIndex = ((gun_index==2) ? 1: 0);
  12691. }
  12692. else
  12693. {
  12694. tempIndex = gun_index;
  12695. }
  12696. for (int index = 0; index < GB_QUANTITY; index++)
  12697. {
  12698. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  12699. {
  12700. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  12701. {
  12702. match = TRUE;
  12703. GunNO = gun_index;
  12704. }
  12705. }
  12706. }// END FOR GB_QUANTITY
  12707. }
  12708. else if(gunType[gun_index] == GUN_TYPE_DO)
  12709. {
  12710. tempIndex = gun_index;
  12711. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  12712. {
  12713. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  12714. {
  12715. 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
  12716. {
  12717. match = TRUE;
  12718. GunNO = gun_index;
  12719. }
  12720. }
  12721. }// END FOR GB_QUANTITY
  12722. }
  12723. else
  12724. {
  12725. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  12726. {
  12727. tempIndex = 2;
  12728. }
  12729. else
  12730. {
  12731. tempIndex = gun_index;
  12732. }
  12733. for (int index = 0; index < AC_QUANTITY; index++)
  12734. {
  12735. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  12736. {
  12737. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  12738. {
  12739. match = TRUE;
  12740. GunNO = gun_index;
  12741. }
  12742. }
  12743. }// END FOR CHAdeMO_QUANTITY
  12744. } // END FOR AC ELSE
  12745. }// CHECK IF ResponseTransactionId == transactionIdInt
  12746. }//END FOR
  12747. if( match == TRUE)
  12748. {
  12749. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  12750. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  12751. }
  12752. else
  12753. {
  12754. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  12755. }
  12756. }
  12757. else
  12758. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  12759. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  12760. return result;
  12761. }
  12762. int handleReserveNowRequest(char *uuid, char *payload)
  12763. {
  12764. mtrace();
  12765. int result = FAIL;
  12766. int connectorIdInt=0, reservationIdInt=0;
  12767. int tempIndex = 0;
  12768. json_object *ReserveNow;
  12769. DEBUG_INFO("handleReserveNowRequest ...\n");
  12770. ReserveNow = json_tokener_parse(payload);
  12771. if(!is_error(ReserveNow))
  12772. {
  12773. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  12774. {
  12775. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  12776. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  12777. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  12778. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  12779. }
  12780. // Required data
  12781. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  12782. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  12783. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  12784. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  12785. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  12786. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  12787. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  12788. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  12789. // Optional data
  12790. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  12791. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  12792. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  12793. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  12794. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  12795. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  12796. result = PASS;
  12797. }
  12798. json_object_put(ReserveNow);
  12799. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  12800. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  12801. {
  12802. //check Transaction active
  12803. if(gunType[connectorIdInt -1] == GUN_TYPE_CHAdeMO)
  12804. {
  12805. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12806. {
  12807. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12808. }
  12809. else
  12810. {
  12811. tempIndex = connectorIdInt -1;
  12812. }
  12813. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12814. {
  12815. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  12816. {
  12817. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  12818. {
  12819. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  12820. {
  12821. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  12822. {
  12823. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  12824. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  12825. }
  12826. 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'))
  12827. {
  12828. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  12829. }
  12830. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  12831. {
  12832. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  12833. }
  12834. else
  12835. {
  12836. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  12837. }
  12838. }
  12839. 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
  12840. {
  12841. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  12842. }
  12843. }
  12844. else
  12845. {
  12846. //replace reservation
  12847. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  12848. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  12849. }
  12850. }
  12851. } // END FOR CHAdeMO_QUANTITY
  12852. }
  12853. else if(gunType[connectorIdInt -1] == GUN_TYPE_CCS)
  12854. {
  12855. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12856. {
  12857. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12858. }
  12859. else
  12860. {
  12861. tempIndex = connectorIdInt -1;
  12862. }
  12863. for (int index = 0; index < CCS_QUANTITY; index++)
  12864. {
  12865. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  12866. {
  12867. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  12868. {
  12869. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  12870. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  12871. {
  12872. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  12873. {
  12874. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  12875. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  12876. }
  12877. 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'))
  12878. {
  12879. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  12880. }
  12881. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  12882. {
  12883. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  12884. }
  12885. else
  12886. {
  12887. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  12888. }
  12889. }
  12890. 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
  12891. {
  12892. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  12893. }
  12894. }
  12895. else
  12896. {
  12897. //replace reservation
  12898. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  12899. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  12900. }
  12901. }
  12902. } // END FOR CCS_QUANTITY
  12903. }
  12904. else if(gunType[connectorIdInt -1] == GUN_TYPE_GBT)
  12905. {
  12906. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12907. {
  12908. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12909. }
  12910. else
  12911. {
  12912. tempIndex = connectorIdInt -1;
  12913. }
  12914. for (int index = 0; index < GB_QUANTITY; index++)
  12915. {
  12916. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  12917. {
  12918. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  12919. {
  12920. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  12921. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  12922. {
  12923. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  12924. {
  12925. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  12926. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  12927. }
  12928. 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'))
  12929. {
  12930. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  12931. }
  12932. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  12933. {
  12934. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  12935. }
  12936. else
  12937. {
  12938. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  12939. }
  12940. }
  12941. 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
  12942. {
  12943. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  12944. }
  12945. }
  12946. else
  12947. {
  12948. //replace reservation
  12949. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  12950. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  12951. }
  12952. }
  12953. }// END FOR GB_QUANTITY
  12954. }
  12955. else if(gunType[connectorIdInt -1] == GUN_TYPE_DO)
  12956. {
  12957. tempIndex = connectorIdInt -1;
  12958. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  12959. {
  12960. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  12961. {
  12962. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId)
  12963. {
  12964. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  12965. 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
  12966. {
  12967. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  12968. {
  12969. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  12970. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  12971. }
  12972. 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'))
  12973. {
  12974. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  12975. }
  12976. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  12977. {
  12978. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  12979. }
  12980. else
  12981. {
  12982. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  12983. }
  12984. }
  12985. 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
  12986. {
  12987. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  12988. }
  12989. }
  12990. else
  12991. {
  12992. //replace reservation
  12993. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  12994. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  12995. }
  12996. }
  12997. }// END FOR DO_QUANTITY
  12998. }
  12999. else
  13000. {
  13001. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13002. {
  13003. tempIndex = 2;
  13004. }
  13005. else
  13006. {
  13007. tempIndex = (connectorIdInt -1);
  13008. }
  13009. for (int index = 0; index < AC_QUANTITY; index++)
  13010. {
  13011. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  13012. {
  13013. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  13014. {
  13015. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  13016. {
  13017. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13018. {
  13019. 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))
  13020. {
  13021. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13022. }
  13023. else
  13024. {
  13025. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13026. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13027. }
  13028. }
  13029. 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'))
  13030. {
  13031. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13032. }
  13033. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  13034. {
  13035. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13036. }
  13037. else
  13038. {
  13039. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13040. }
  13041. }
  13042. 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
  13043. {
  13044. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13045. }
  13046. }
  13047. else
  13048. {
  13049. //replace reservation
  13050. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  13051. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13052. }
  13053. }
  13054. } // END FOR AC_QUANTITY
  13055. }
  13056. }
  13057. else if(connectorIdInt == 0)
  13058. {
  13059. //check Transaction active
  13060. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13061. {
  13062. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  13063. {
  13064. 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'))
  13065. {
  13066. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13067. goto end;
  13068. }
  13069. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  13070. {
  13071. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13072. goto end;
  13073. }
  13074. 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
  13075. {
  13076. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13077. goto end;
  13078. }
  13079. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13080. {
  13081. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13082. goto end;
  13083. }
  13084. }
  13085. }// END FOR CHAdeMO_QUANTITY
  13086. for (int index = 0; index < CCS_QUANTITY; index++)
  13087. {
  13088. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  13089. {
  13090. 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'))
  13091. {
  13092. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13093. goto end;
  13094. }
  13095. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  13096. {
  13097. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13098. goto end;
  13099. }
  13100. 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
  13101. {
  13102. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13103. goto end;
  13104. }
  13105. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13106. {
  13107. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13108. goto end;
  13109. }
  13110. }
  13111. } // END FOR CCS_QUANTITY
  13112. for (int index = 0; index < GB_QUANTITY; index++)
  13113. {
  13114. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  13115. {
  13116. 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'))
  13117. {
  13118. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13119. goto end;
  13120. }
  13121. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  13122. {
  13123. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13124. goto end;
  13125. }
  13126. 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
  13127. {
  13128. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13129. goto end;
  13130. }
  13131. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13132. {
  13133. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13134. goto end;
  13135. }
  13136. }
  13137. } // END FOR GB_QUANTITY
  13138. for (int index = 0; index < AC_QUANTITY; index++)
  13139. {
  13140. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  13141. {
  13142. 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'))
  13143. {
  13144. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  13145. goto end;
  13146. }
  13147. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  13148. {
  13149. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13150. goto end;
  13151. }
  13152. 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
  13153. {
  13154. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  13155. goto end;
  13156. }
  13157. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  13158. {
  13159. 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))
  13160. {
  13161. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  13162. goto end;
  13163. }
  13164. }
  13165. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13166. {
  13167. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13168. goto end;
  13169. }
  13170. }
  13171. }// END FOR AC_QUANTITY
  13172. //The connectorId is 0
  13173. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  13174. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  13175. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  13176. result = TRUE;
  13177. return result;
  13178. }
  13179. else
  13180. {
  13181. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  13182. }
  13183. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  13184. {
  13185. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  13186. result = TRUE;
  13187. return result;
  13188. }
  13189. end:
  13190. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  13191. return result;
  13192. }
  13193. int handleResetRequest(char *uuid, char *payload)
  13194. {
  13195. mtrace();
  13196. int result = FAIL;
  13197. json_object *Reset = json_object_new_object();
  13198. DEBUG_INFO("handleResetRequest...\n");
  13199. Reset = json_tokener_parse(payload);
  13200. if(!is_error(Reset))
  13201. {
  13202. // Required data
  13203. if(json_object_object_get(Reset, "type") != NULL)
  13204. {
  13205. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  13206. }
  13207. if(json_object_object_get(Reset, "evseId") != NULL)
  13208. {
  13209. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  13210. }
  13211. }
  13212. json_object_put(Reset);
  13213. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  13214. {
  13215. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  13216. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]);
  13217. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  13218. result = PASS;
  13219. }
  13220. else
  13221. {
  13222. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  13223. }
  13224. if(strlen((char*)ShmOCPP20Data->Reset.Response_status) > 0)
  13225. sendResetConfirmation(uuid);
  13226. return result;
  13227. }
  13228. int handleSendLocalListRequest(char *uuid, char *payload)
  13229. {
  13230. mtrace();
  13231. int result = FAIL;
  13232. char updateTypestr[15]={0};
  13233. int checkState_Faulted = FALSE;
  13234. json_object *SendLocalList;
  13235. DEBUG_INFO("handleSendLocalListRequest...\n");
  13236. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  13237. {
  13238. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  13239. goto end;
  13240. }
  13241. SendLocalList = json_tokener_parse(payload);
  13242. if(!is_error(SendLocalList))
  13243. {
  13244. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  13245. // Required data
  13246. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  13247. {
  13248. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  13249. }
  13250. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  13251. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  13252. // Optional data
  13253. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  13254. {
  13255. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  13256. {
  13257. // Required data
  13258. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  13259. {
  13260. 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")));
  13261. 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")));
  13262. }
  13263. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  13264. {
  13265. 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")));
  13266. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  13267. 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")));
  13268. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  13269. 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"));
  13270. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  13271. {
  13272. 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")));
  13273. 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")));
  13274. }
  13275. }
  13276. }
  13277. }
  13278. }
  13279. json_object_put(SendLocalList);
  13280. //check Charge Point state
  13281. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13282. {
  13283. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  13284. {
  13285. checkState_Faulted = TRUE; //OCPP Status: Faulted
  13286. }
  13287. }
  13288. for (int index = 0; index < CCS_QUANTITY; index++)
  13289. {
  13290. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  13291. {
  13292. checkState_Faulted = TRUE; //OCPP Status
  13293. }
  13294. }
  13295. for (int index = 0; index < GB_QUANTITY; index++)
  13296. {
  13297. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  13298. {
  13299. checkState_Faulted = TRUE; //OCPP Status: Faulted
  13300. }
  13301. }
  13302. for (int index = 0; index < AC_QUANTITY; index++)
  13303. {
  13304. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  13305. {
  13306. checkState_Faulted = TRUE; //OCPP Status: Faulted
  13307. }
  13308. }
  13309. if(checkState_Faulted == TRUE)
  13310. {
  13311. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  13312. goto end;
  13313. }
  13314. // Check update type
  13315. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  13316. {
  13317. //Local list full update
  13318. DEBUG_INFO("Local list full update.\n");
  13319. DB_getListVerion();
  13320. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  13321. {
  13322. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  13323. goto end;
  13324. }
  13325. DB_cleanLocalList();
  13326. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  13327. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  13328. }
  13329. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  13330. {
  13331. //Local list different update
  13332. DEBUG_INFO("Local list different update.\n");
  13333. DB_getListVerion();
  13334. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  13335. {
  13336. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  13337. goto end;
  13338. }
  13339. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  13340. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  13341. }
  13342. else
  13343. {
  13344. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  13345. goto end;
  13346. }
  13347. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  13348. end:
  13349. sendSendLocalListConfirmation(uuid);
  13350. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  13351. return result;
  13352. }
  13353. int handleSetChargingProfileRequest(char *uuid, char *payload)
  13354. {
  13355. mtrace();
  13356. int result = FAIL;
  13357. int8_t gun_index = -1;
  13358. uint8_t isPeriodOverMax = FALSE;
  13359. uint8_t isProfileOverMax = FALSE;
  13360. uint8_t isConnectorMismatch = FALSE;
  13361. uint8_t existProfileQuantity = 0;
  13362. uint8_t filename[128]={0};
  13363. uint8_t word[2048]={0};
  13364. FILE *filePtr;
  13365. json_object *SetChargingProfile;
  13366. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  13367. SetChargingProfile = json_tokener_parse(payload);
  13368. if(!is_error(SetChargingProfile))
  13369. {
  13370. // Required data
  13371. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  13372. {
  13373. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  13374. }
  13375. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  13376. {
  13377. // Check periods is over max configuration
  13378. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  13379. {
  13380. isPeriodOverMax = TRUE;
  13381. }
  13382. // Check periods is over max configuration
  13383. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  13384. {
  13385. if(gun_index == 0)
  13386. {
  13387. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  13388. filePtr = fopen((char*)filename, "r");
  13389. if (!filePtr)
  13390. {
  13391. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  13392. filePtr = fopen((char*)filename, "w+");
  13393. }
  13394. else
  13395. {
  13396. //Check Charging Profile Count
  13397. while(fscanf(filePtr, "%s", word) != EOF)
  13398. {
  13399. //DEBUG_INFO("word=%s\n",word);
  13400. if(strstr((char*)word, "chargingProfileId")!= NULL)
  13401. {
  13402. existProfileQuantity += 1;
  13403. }
  13404. }
  13405. }
  13406. fclose(filePtr);
  13407. }
  13408. else
  13409. isConnectorMismatch = TRUE;
  13410. }
  13411. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  13412. {
  13413. if(gun_index < 5)
  13414. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  13415. else
  13416. isConnectorMismatch = TRUE;
  13417. if(!isConnectorMismatch)
  13418. {
  13419. filePtr = fopen((char*)filename, "r");
  13420. if (!filePtr)
  13421. {
  13422. DEBUG_INFO("%s not exist, create it.\n", filename);
  13423. filePtr = fopen((char*)filename, "w+");
  13424. }
  13425. else
  13426. {
  13427. //Check Charging Profile Count
  13428. while(fscanf(filePtr, "%s", word) != EOF)
  13429. {
  13430. //DEBUG_INFO("word=%s\n",word);
  13431. if(strstr((char*)word, "chargingProfileId")!= NULL)
  13432. {
  13433. existProfileQuantity += 1;
  13434. }
  13435. }
  13436. }
  13437. fclose(filePtr);
  13438. }
  13439. }
  13440. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  13441. {
  13442. if(gun_index>0)
  13443. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  13444. else
  13445. isConnectorMismatch = TRUE;
  13446. if(!isConnectorMismatch)
  13447. {
  13448. filePtr = fopen((char*)filename, "r");
  13449. if (!filePtr)
  13450. {
  13451. DEBUG_INFO("%s not exist, create it.\n", filename);
  13452. filePtr = fopen((char*)filename, "w+");
  13453. }
  13454. else
  13455. {
  13456. //Check Charging Profile Count
  13457. while(fscanf(filePtr, "%s", word) != EOF)
  13458. {
  13459. //DEBUG_INFO("word=%s\n",word);
  13460. if(strstr((char*)word, "chargingProfileId")!= NULL)
  13461. {
  13462. existProfileQuantity += 1;
  13463. }
  13464. }
  13465. }
  13466. fclose(filePtr);
  13467. }
  13468. }
  13469. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  13470. {
  13471. }
  13472. else
  13473. {
  13474. }
  13475. if(existProfileQuantity > 3)
  13476. isProfileOverMax = TRUE;
  13477. }
  13478. // Profile replace or add info
  13479. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  13480. {
  13481. FILE *infile;
  13482. FILE *outfile;
  13483. char tmpProfileName[32];
  13484. char rmFileCmd[128];
  13485. char tempchargingProfilePurposeStr[30]={0};
  13486. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  13487. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  13488. infile = fopen ((char*)filename, "r");
  13489. outfile = fopen ((char*)tmpProfileName, "w");
  13490. int d = fgetc(infile);
  13491. rewind(infile);
  13492. if(d == EOF)
  13493. {
  13494. // Profile is empty
  13495. fprintf(outfile,"%s\n", payload);
  13496. fclose(infile);
  13497. fclose(outfile);
  13498. sprintf(rmFileCmd,"rm -f %s",filename);
  13499. system(rmFileCmd);
  13500. rename((char*)tmpProfileName, (char*)filename);
  13501. }
  13502. else
  13503. {
  13504. // Profile is not empty
  13505. char buf[2048]={0};
  13506. int ChargingProfileAdded = FALSE;
  13507. while (fgets(buf, sizeof(buf), infile) != NULL)
  13508. {
  13509. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  13510. json_object *tmpChargingProfile;
  13511. tmpChargingProfile = json_tokener_parse(buf);
  13512. if(!is_error(tmpChargingProfile))
  13513. {
  13514. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  13515. {
  13516. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  13517. }
  13518. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  13519. {
  13520. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  13521. {
  13522. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  13523. }
  13524. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  13525. {
  13526. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  13527. }
  13528. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  13529. {
  13530. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  13531. }
  13532. }
  13533. }
  13534. json_object_put(tmpChargingProfile);
  13535. if((tempconnectorIdInt == gun_index) &&
  13536. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  13537. {
  13538. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  13539. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  13540. {
  13541. //DEBUG_INFO("update set chargingProfile to file -0\n");
  13542. if(ChargingProfileAdded == FALSE)
  13543. {
  13544. fprintf(outfile,"%s\n",payload);
  13545. ChargingProfileAdded = TRUE;
  13546. }
  13547. }
  13548. else
  13549. {
  13550. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  13551. {
  13552. if(ChargingProfileAdded == FALSE)
  13553. {
  13554. fprintf(outfile,"%s\n",buf);
  13555. fprintf(outfile,"%s\n",payload);
  13556. ChargingProfileAdded = TRUE;
  13557. }
  13558. else
  13559. {
  13560. fprintf(outfile,"%s\n",buf);
  13561. }
  13562. }
  13563. else
  13564. {
  13565. if(ChargingProfileAdded == FALSE)
  13566. {
  13567. fprintf(outfile,"%s\n",buf);
  13568. fprintf(outfile,"%s\n",payload);
  13569. ChargingProfileAdded = TRUE;
  13570. }
  13571. else
  13572. {
  13573. fprintf(outfile,"%s\n",buf);
  13574. }
  13575. }
  13576. }
  13577. }
  13578. else
  13579. {
  13580. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
  13581. {
  13582. if(ChargingProfileAdded == FALSE)
  13583. {
  13584. fprintf(outfile,"%s\n",buf);
  13585. fprintf(outfile,"%s\n",payload);
  13586. ChargingProfileAdded = TRUE;
  13587. }
  13588. else
  13589. {
  13590. fprintf(outfile,"%s\n",buf);
  13591. }
  13592. }
  13593. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  13594. {
  13595. if(ChargingProfileAdded == FALSE)
  13596. {
  13597. fprintf(outfile,"%s\n",buf);
  13598. fprintf(outfile,"%s\n",payload);
  13599. ChargingProfileAdded = TRUE;
  13600. }
  13601. else
  13602. {
  13603. fprintf(outfile,"%s\n",buf);
  13604. }
  13605. }
  13606. else
  13607. {
  13608. if(ChargingProfileAdded == FALSE)
  13609. {
  13610. fprintf(outfile,"%s\n",buf);
  13611. fprintf(outfile,"%s\n",payload);
  13612. ChargingProfileAdded = TRUE;
  13613. }
  13614. else
  13615. {
  13616. fprintf(outfile,"%s\n",buf);
  13617. }
  13618. }
  13619. }
  13620. } // end of while loop
  13621. fclose(infile);
  13622. fclose(outfile);
  13623. sprintf(rmFileCmd,"rm -f %s",filename);
  13624. system(rmFileCmd);
  13625. rename((char*)tmpProfileName, (char*)filename);
  13626. }
  13627. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  13628. result = PASS;
  13629. }
  13630. else
  13631. {
  13632. if(gun_index == -1)
  13633. DEBUG_WARN("Connector id is wrong.\n");
  13634. if(isConnectorMismatch)
  13635. DEBUG_WARN("Connector id is mismatch.\n");
  13636. if(isPeriodOverMax)
  13637. DEBUG_WARN("Profile periods quantity is over spec.\n");
  13638. if(isProfileOverMax)
  13639. DEBUG_WARN("Profile quantity is over spec.\n");
  13640. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  13641. }
  13642. }
  13643. json_object_put(SetChargingProfile);
  13644. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  13645. {
  13646. if(gun_index == 0)
  13647. {
  13648. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  13649. {
  13650. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  13651. }
  13652. }
  13653. else
  13654. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1], 0, TRUE);
  13655. }
  13656. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  13657. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  13658. return result;
  13659. }
  13660. int handleSetDisplayMessagesRequest(char *uuid, char *payload)
  13661. {
  13662. mtrace();
  13663. int result = FAIL;
  13664. json_object *SetDisplayMessage;
  13665. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  13666. SetDisplayMessage = json_tokener_parse(payload);
  13667. if(!is_error(SetDisplayMessage))
  13668. {
  13669. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  13670. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  13671. // Required data
  13672. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  13673. {
  13674. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  13675. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  13676. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  13677. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  13678. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  13679. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  13680. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  13681. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  13682. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  13683. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  13684. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  13685. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  13686. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  13687. {
  13688. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  13689. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.format, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId"), "format")));
  13690. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  13691. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.language, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId"), "language")));
  13692. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  13693. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.content, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId"), "content")));
  13694. }
  13695. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  13696. {
  13697. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  13698. 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")));
  13699. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  13700. 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")));
  13701. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  13702. {
  13703. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  13704. 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"));
  13705. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  13706. 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"));
  13707. }
  13708. }
  13709. }
  13710. }
  13711. json_object_put(SetDisplayMessage);
  13712. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  13713. sendSetDisplayMessagesConfirmation(uuid);
  13714. // Announce CSU there is display request come from server
  13715. ShmOCPP20Data->MsMsg.bits.SetDisplayMessageReq = ON;
  13716. return result;
  13717. }
  13718. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  13719. {
  13720. mtrace();
  13721. int result = FAIL;
  13722. json_object *SetMonitoringBase;
  13723. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  13724. SetMonitoringBase = json_tokener_parse(payload);
  13725. if(!is_error(SetMonitoringBase))
  13726. {
  13727. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  13728. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  13729. // Required data
  13730. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  13731. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  13732. }
  13733. json_object_put(SetMonitoringBase);
  13734. /*
  13735. * TODO:
  13736. * 1. Configure monitor base and response
  13737. */
  13738. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  13739. sendSetMonitoringBaseConfirmation(uuid);
  13740. return result;
  13741. }
  13742. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  13743. {
  13744. mtrace();
  13745. int result = FAIL;
  13746. json_object *SetMonitoringLevel;
  13747. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  13748. SetMonitoringLevel = json_tokener_parse(payload);
  13749. if(!is_error(SetMonitoringLevel))
  13750. {
  13751. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  13752. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  13753. // Required data
  13754. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  13755. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  13756. }
  13757. json_object_put(SetMonitoringLevel);
  13758. /*
  13759. * TODO:
  13760. * Configure monitor status and response
  13761. */
  13762. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  13763. sendSetMonitoringLevelConfirmation(uuid);
  13764. return result;
  13765. }
  13766. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  13767. {
  13768. mtrace();
  13769. int result = FAIL;
  13770. json_object *SetNetworkProfile;
  13771. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  13772. SetNetworkProfile = json_tokener_parse(payload);
  13773. if(!is_error(SetNetworkProfile))
  13774. {
  13775. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  13776. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  13777. // Required data
  13778. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  13779. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  13780. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  13781. {
  13782. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  13783. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  13784. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  13785. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  13786. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  13787. {
  13788. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  13789. memcpy((char*)ShmOCPP20Data->OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  13790. }
  13791. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  13792. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  13793. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  13794. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  13795. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  13796. {
  13797. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  13798. 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")));
  13799. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  13800. 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")));
  13801. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  13802. 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")));
  13803. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  13804. 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")));
  13805. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  13806. 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")));
  13807. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  13808. 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")));
  13809. }
  13810. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  13811. {
  13812. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  13813. {
  13814. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  13815. 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")));
  13816. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  13817. }
  13818. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  13819. {
  13820. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  13821. 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")));
  13822. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  13823. }
  13824. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  13825. {
  13826. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  13827. 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")));
  13828. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  13829. }
  13830. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  13831. 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"));
  13832. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  13833. 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")));
  13834. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  13835. 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"));
  13836. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  13837. 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")));
  13838. }
  13839. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  13840. }
  13841. }
  13842. json_object_put(SetNetworkProfile);
  13843. /*
  13844. * TODO:
  13845. * 1. Process network configuration and response
  13846. */
  13847. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  13848. {
  13849. }
  13850. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  13851. {
  13852. }
  13853. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  13854. {
  13855. }
  13856. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  13857. {
  13858. }
  13859. else
  13860. {
  13861. }
  13862. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  13863. {
  13864. }
  13865. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  13866. {
  13867. }
  13868. else
  13869. {
  13870. }
  13871. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  13872. {
  13873. }
  13874. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  13875. {
  13876. }
  13877. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  13878. {
  13879. }
  13880. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  13881. {
  13882. }
  13883. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  13884. {
  13885. }
  13886. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  13887. {
  13888. }
  13889. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  13890. {
  13891. }
  13892. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  13893. {
  13894. }
  13895. else
  13896. {
  13897. }
  13898. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  13899. {
  13900. }
  13901. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  13902. {
  13903. }
  13904. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  13905. {
  13906. }
  13907. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  13908. {
  13909. }
  13910. else
  13911. {
  13912. }
  13913. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  13914. {
  13915. }
  13916. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  13917. {
  13918. }
  13919. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  13920. {
  13921. }
  13922. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  13923. {
  13924. }
  13925. else
  13926. {
  13927. }
  13928. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  13929. sendSetNetworkProfileConfirmation(uuid);
  13930. return result;
  13931. }
  13932. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  13933. {
  13934. mtrace();
  13935. int result = FAIL;
  13936. json_object *SetVariableMonitoring;
  13937. uint8_t variableQuantity = 0;
  13938. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  13939. SetVariableMonitoring = json_tokener_parse(payload);
  13940. if(!is_error(SetVariableMonitoring))
  13941. {
  13942. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  13943. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  13944. // Required data
  13945. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  13946. {
  13947. variableQuantity++;
  13948. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  13949. {
  13950. 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"));
  13951. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  13952. }
  13953. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  13954. {
  13955. 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"));
  13956. }
  13957. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  13958. {
  13959. 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")));
  13960. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  13961. }
  13962. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  13963. {
  13964. 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"));
  13965. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  13966. }
  13967. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  13968. {
  13969. 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"));
  13970. }
  13971. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  13972. {
  13973. 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)
  13974. {
  13975. 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")));
  13976. }
  13977. 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)
  13978. {
  13979. 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")));
  13980. }
  13981. 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)
  13982. {
  13983. 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)
  13984. {
  13985. 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"));
  13986. }
  13987. 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)
  13988. {
  13989. 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"));
  13990. }
  13991. }
  13992. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  13993. }
  13994. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  13995. {
  13996. 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)
  13997. {
  13998. 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")));
  13999. }
  14000. 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)
  14001. {
  14002. 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")));
  14003. }
  14004. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  14005. }
  14006. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, SetMonitoringStatusEnumTypeStr[SetMonitoringStatusEnumType_Accepted]);
  14007. }
  14008. }
  14009. json_object_put(SetVariableMonitoring);
  14010. sendSetVariableMonitoringConfirmation(uuid, variableQuantity);
  14011. return result;
  14012. }
  14013. int handleSetVariablesRequest(char *uuid, char *payload)
  14014. {
  14015. mtrace();
  14016. int result = FAIL;
  14017. json_object *SetVariables;
  14018. DEBUG_INFO("handleSetVariablesRequest...\n");
  14019. SetVariables = json_tokener_parse(payload);
  14020. if(!is_error(SetVariables))
  14021. {
  14022. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  14023. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  14024. // Required data
  14025. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  14026. {
  14027. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  14028. {
  14029. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  14030. {
  14031. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  14032. {
  14033. 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")));
  14034. }
  14035. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  14036. {
  14037. 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")));
  14038. }
  14039. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  14040. {
  14041. 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)
  14042. {
  14043. ShmOCPP20Data->SetVariables.setVariableData[idx].component.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance"), "id"));
  14044. }
  14045. 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)
  14046. {
  14047. ShmOCPP20Data->SetVariables.setVariableData[idx].component.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance"), "connectorId"));
  14048. }
  14049. }
  14050. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  14051. }
  14052. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  14053. {
  14054. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  14055. {
  14056. 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")));
  14057. }
  14058. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  14059. {
  14060. 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")));
  14061. }
  14062. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  14063. }
  14064. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  14065. {
  14066. 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")));
  14067. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  14068. }
  14069. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  14070. {
  14071. 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")));
  14072. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  14073. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  14074. {
  14075. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  14076. (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) &&
  14077. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  14078. (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))
  14079. {
  14080. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  14081. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  14082. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  14083. {
  14084. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  14085. }
  14086. else
  14087. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  14088. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "WebSocketPingInterval") != NULL))
  14089. {
  14090. ChageWebSocketPingInterval(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value));
  14091. }
  14092. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SecurityCtrlr") != NULL) &&
  14093. ((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "SecurityProfile") != NULL) || (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "BasicAuthPassword") != NULL)))
  14094. {
  14095. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  14096. SetOcppConnStatus(FALSE);
  14097. }
  14098. }
  14099. }
  14100. }
  14101. }
  14102. }
  14103. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  14104. }
  14105. json_object_put(SetVariables);
  14106. return result;
  14107. }
  14108. int handleTriggerMessageRequest(char *uuid, char *payload)
  14109. {
  14110. mtrace();
  14111. int result = FAIL;
  14112. int connectorIdIsNULL = FALSE;
  14113. int connectorIdInt =0;
  14114. json_object *TriggerMessage;
  14115. DEBUG_INFO("handleTriggerMessageRequest\n");
  14116. TriggerMessage = json_tokener_parse(payload);
  14117. if(!is_error(TriggerMessage))
  14118. {
  14119. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  14120. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  14121. // Required data
  14122. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  14123. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  14124. // Optional data
  14125. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  14126. {
  14127. // Required data
  14128. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  14129. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  14130. // Optional data
  14131. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  14132. {
  14133. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  14134. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  14135. }
  14136. else
  14137. connectorIdIsNULL = TRUE;
  14138. }
  14139. }
  14140. json_object_put(TriggerMessage);
  14141. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  14142. {
  14143. if((strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  14144. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  14145. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  14146. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  14147. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  14148. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  14149. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  14150. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  14151. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  14152. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  14153. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  14154. {
  14155. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  14156. sendTriggerMessageConfirmation(uuid);
  14157. return TRUE;
  14158. }
  14159. else
  14160. {
  14161. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  14162. sendTriggerMessageConfirmation(uuid);
  14163. }
  14164. }
  14165. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  14166. {
  14167. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  14168. sendTriggerMessageConfirmation(uuid);
  14169. return TRUE;
  14170. }
  14171. //==========================
  14172. // Trigger message
  14173. //==========================
  14174. if( strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  14175. {
  14176. if((strlen((char*)ShmOCPP20Data->FirmwareStatusNotification.status) == 0) ||
  14177. ((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing)))
  14178. {
  14179. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  14180. }
  14181. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14182. }
  14183. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  14184. {
  14185. if(strlen((char*)ShmOCPP20Data->LogStatusNotification.status) == 0)
  14186. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Idle]);
  14187. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  14188. }
  14189. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  14190. {
  14191. if(DB_updateBootType(BootReasonEnumType_Triggered))
  14192. server_sign = FALSE;
  14193. }
  14194. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  14195. {
  14196. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  14197. }
  14198. else if (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  14199. {
  14200. if(connectorIdIsNULL == FALSE)
  14201. {
  14202. if((connectorIdInt > 0) && ((connectorIdInt-1) < gunTotalNumber))
  14203. {
  14204. cpinitateMsg.bits[connectorIdInt-1].TriggerMeterValueReq = ON;
  14205. }
  14206. }
  14207. else
  14208. {
  14209. for(int idx=0;idx< gunTotalNumber;idx++)
  14210. {
  14211. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  14212. }
  14213. }
  14214. }
  14215. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  14216. {
  14217. if(connectorIdIsNULL == FALSE)
  14218. {
  14219. if((connectorIdInt > 0) && ((connectorIdInt-1) < gunTotalNumber))
  14220. {
  14221. cpinitateMsg.bits[connectorIdInt-1].TriggerStatusNotificationReq = ON;
  14222. //clientTime.StatusNotification[connectorIdInt-1] = time((time_t*)NULL);
  14223. }
  14224. }
  14225. else
  14226. {
  14227. for(int idx=0;idx< gunTotalNumber;idx++)
  14228. {
  14229. cpinitateMsg.bits[idx].TriggerStatusNotificationReq = ON;
  14230. //clientTime.StatusNotification[idx] = time((time_t*)NULL);
  14231. }
  14232. }
  14233. }
  14234. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0 )
  14235. {
  14236. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  14237. if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
  14238. {
  14239. 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\" &");
  14240. }
  14241. }
  14242. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) == 0 )
  14243. {
  14244. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  14245. if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
  14246. {
  14247. 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\" &");
  14248. }
  14249. }
  14250. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) == 0 )
  14251. {
  14252. if(connectorIdIsNULL == FALSE)
  14253. {
  14254. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  14255. {
  14256. cpinitateMsg.bits[connectorIdInt -1].TransactionEventReq = ON;
  14257. }
  14258. }
  14259. else
  14260. {
  14261. for(int idx=0;idx< gunTotalNumber;idx++)
  14262. cpinitateMsg.bits[idx].TransactionEventReq = ON;
  14263. }
  14264. }
  14265. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) == 0 )
  14266. {
  14267. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  14268. if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
  14269. {
  14270. 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\" &");
  14271. }
  14272. if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
  14273. {
  14274. 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\" &");
  14275. }
  14276. }
  14277. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) == 0 )
  14278. {
  14279. ShmOCPP20Data->MsMsg.bits.PublishFirmwareReq = ON;
  14280. }
  14281. return result;
  14282. }
  14283. int handleUnlockConnectorRequest(char *uuid, char *payload)
  14284. {
  14285. mtrace();
  14286. int result = FAIL;
  14287. int connectorIdInt =0;
  14288. int tempIndex = 0;
  14289. json_object *UnlockConnector;
  14290. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  14291. UnlockConnector = json_tokener_parse(payload);
  14292. if(!is_error(UnlockConnector))
  14293. {
  14294. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  14295. {
  14296. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  14297. }
  14298. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  14299. {
  14300. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  14301. }
  14302. }
  14303. json_object_put(UnlockConnector);
  14304. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  14305. if(gunTotalNumber == 0)
  14306. {
  14307. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  14308. goto end;
  14309. }
  14310. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  14311. {
  14312. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  14313. goto end;
  14314. }
  14315. else
  14316. {
  14317. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  14318. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  14319. //check Transaction active
  14320. if(gunType[connectorIdInt-1] == GUN_TYPE_CHAdeMO)
  14321. {
  14322. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14323. {
  14324. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14325. }
  14326. else
  14327. {
  14328. tempIndex = connectorIdInt -1;
  14329. }
  14330. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14331. {
  14332. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  14333. {
  14334. //stop Transaction
  14335. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  14336. }
  14337. }
  14338. }
  14339. else if(gunType[connectorIdInt-1] == GUN_TYPE_CCS)
  14340. {
  14341. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14342. {
  14343. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14344. }
  14345. else
  14346. {
  14347. tempIndex = connectorIdInt -1;
  14348. }
  14349. for (int index = 0; index < CCS_QUANTITY; index++)
  14350. {
  14351. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  14352. {
  14353. //stop Transaction
  14354. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  14355. }
  14356. }
  14357. }
  14358. else if(gunType[connectorIdInt-1] == GUN_TYPE_GBT)
  14359. {
  14360. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14361. {
  14362. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14363. }
  14364. else
  14365. {
  14366. tempIndex = connectorIdInt -1;
  14367. }
  14368. for (int index = 0; index < GB_QUANTITY; index++)
  14369. {
  14370. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  14371. {
  14372. //stop Transaction
  14373. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  14374. }
  14375. }
  14376. }
  14377. else if(gunType[connectorIdInt-1] == GUN_TYPE_DO)
  14378. {
  14379. tempIndex = connectorIdInt -1;
  14380. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  14381. {
  14382. if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)))
  14383. {
  14384. //stop Transaction
  14385. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  14386. }
  14387. }
  14388. }
  14389. else
  14390. {
  14391. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  14392. {
  14393. tempIndex = 2;
  14394. }
  14395. else
  14396. {
  14397. tempIndex = connectorIdInt-1;
  14398. }
  14399. for (int index = 0; index < AC_QUANTITY; index++)
  14400. {
  14401. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  14402. {
  14403. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  14404. }
  14405. }
  14406. }
  14407. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  14408. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  14409. result = TRUE;
  14410. return result;
  14411. }
  14412. end:
  14413. //json_object_put(obj); --- remove temporally
  14414. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  14415. return result;
  14416. }
  14417. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  14418. {
  14419. mtrace();
  14420. int result = FAIL;
  14421. json_object *UnpublishFirmware;
  14422. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  14423. UnpublishFirmware = json_tokener_parse(payload);
  14424. if(!is_error(UnpublishFirmware))
  14425. {
  14426. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  14427. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  14428. // Required data
  14429. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  14430. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  14431. }
  14432. json_object_put(UnpublishFirmware);
  14433. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  14434. /*
  14435. * TODO:
  14436. * 1. Check unpublished status
  14437. */
  14438. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  14439. sendUnpublishFirmwareConfirmation(uuid);
  14440. return result;
  14441. }
  14442. static char UpdateFirmwarepayloadData[512]={0};
  14443. void *UpdateFirmwareProcess(void *data)
  14444. {
  14445. pthread_detach(pthread_self());
  14446. mtrace();
  14447. int retriesInt =0, retryIntervalInt=0;
  14448. char protocol[10], user[64],password[64],host[128], path[512], ftppath[512],host1[128],path1[512];
  14449. int port=0;
  14450. char locationstr[1024]={0}, retrieveDatestr[36]={0};
  14451. int isSuccess = 0;
  14452. char ftpbuf[1024];
  14453. char temp[1024];
  14454. char * pch;
  14455. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  14456. json_object *UpdateFirmware;
  14457. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  14458. if(!is_error(UpdateFirmware))
  14459. {
  14460. // Required data
  14461. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  14462. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  14463. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  14464. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  14465. // Optional data
  14466. if(json_object_object_get(UpdateFirmware, "retries"))
  14467. {
  14468. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  14469. }
  14470. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  14471. {
  14472. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  14473. }
  14474. }
  14475. json_object_put(UpdateFirmware);
  14476. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  14477. memset(path, 0, ARRAY_SIZE(path));
  14478. // Wait retrieveData
  14479. if(strlen(retrieveDatestr) > 10)
  14480. {
  14481. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled]);
  14482. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14483. do
  14484. {
  14485. sleep(1);
  14486. }while(!isOvertNow((uint8_t*)retrieveDatestr));
  14487. }
  14488. system("rm -f /mnt/*");
  14489. if(strncmp(locationstr,"http", 4) == 0)
  14490. {
  14491. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  14492. sprintf(ftppath,"/%s", path);
  14493. DEBUG_INFO("locationstr: %s\n", locationstr);
  14494. DEBUG_INFO("protocol: %s\n",protocol);
  14495. DEBUG_INFO("host: %s\n",host);
  14496. DEBUG_INFO("path: %s\n",path);
  14497. DEBUG_INFO("ftppath: %s\n",ftppath);
  14498. int ftppathlen=strlen(ftppath);
  14499. int i=1;
  14500. char filenametemp[50];
  14501. while(i < ftppathlen)
  14502. {
  14503. int len=ftppathlen-i;
  14504. if(ftppath[len]== 47) // '/' ascll code: 47
  14505. {
  14506. DEBUG_INFO("compare '/' all right\n");
  14507. break;
  14508. }
  14509. i=i+1;
  14510. }
  14511. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  14512. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  14513. filenametemp[i+1] = 0;
  14514. do
  14515. {
  14516. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  14517. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14518. sleep(3);
  14519. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  14520. if(!isSuccess)
  14521. {
  14522. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  14523. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14524. if(retriesInt>0)sleep(retryIntervalInt);else sleep(1);
  14525. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  14526. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14527. }
  14528. else
  14529. {
  14530. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  14531. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14532. }
  14533. retriesInt--;
  14534. }while((isSuccess == 0)&&(retriesInt >= 0));
  14535. }
  14536. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  14537. {
  14538. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  14539. memset(temp, 0, ARRAY_SIZE(temp));
  14540. strcpy(ftpbuf, locationstr);
  14541. int ftppathlen=strlen(ftpbuf);
  14542. int i=1;
  14543. char filenametemp[50];
  14544. while(i < ftppathlen)
  14545. {
  14546. int len=ftppathlen-i;
  14547. if(ftpbuf[len]== 47) // '/' ascll code: 47
  14548. {
  14549. DEBUG_INFO(" compare '/' all right\n");
  14550. break;
  14551. }
  14552. i=i+1;
  14553. }
  14554. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  14555. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  14556. filenametemp[i+1] = 0;
  14557. strncpy(temp, ftpbuf, ftppathlen-i+1);
  14558. pch=strchr(temp,'@');
  14559. if(pch==NULL)
  14560. {
  14561. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  14562. protocol, host, &port, path);
  14563. strcpy(user,"anonymous");
  14564. strcpy(password,"");
  14565. }
  14566. else
  14567. {
  14568. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  14569. protocol, user, password, host, &port, path);
  14570. }
  14571. sscanf(host,"%[^/]%s",host1, path1);
  14572. sprintf(ftppath,"%s", path1);
  14573. if(port == 0)
  14574. {
  14575. port = 21;
  14576. }
  14577. do
  14578. {
  14579. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  14580. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14581. sleep(3);
  14582. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  14583. if(!isSuccess)
  14584. {
  14585. //BulldogUtil.sleepMs(interval*1000);
  14586. DEBUG_INFO("Update firmware request and download file fail.\n");
  14587. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  14588. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14589. if(retriesInt>0)sleep(retryIntervalInt);else sleep(1);
  14590. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  14591. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14592. }
  14593. else
  14594. {
  14595. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  14596. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14597. }
  14598. retriesInt--;
  14599. }while((!isSuccess)&&(retriesInt >= 0));
  14600. }
  14601. else
  14602. {
  14603. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  14604. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14605. sleep(1);
  14606. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  14607. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  14608. }
  14609. if(strstr((char*)ShmOCPP20Data->FirmwareStatusNotification.status, FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]) != NULL)ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  14610. pthread_exit(NULL);
  14611. }
  14612. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  14613. {
  14614. mtrace();
  14615. int result = FAIL;
  14616. pthread_t t;
  14617. sendUpdateFirmwareConfirmation(uuid);
  14618. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  14619. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  14620. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  14621. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  14622. ////pthread_join(t, NULL); //
  14623. //pthread_detach(t);
  14624. //sendUpdateFirmwareConfirmation(uuid);
  14625. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  14626. return result;
  14627. }
  14628. int handleUnknownRequest(char *uuid, char *payload)
  14629. {
  14630. mtrace();
  14631. int result = FAIL;
  14632. DEBUG_INFO("handleUnknownRequest...\n");
  14633. sendUnknownConfirmation(uuid);
  14634. result = PASS;
  14635. return result;
  14636. }
  14637. //==========================================
  14638. // Handle server response routine
  14639. //==========================================
  14640. void handleAuthorizeResponse(char *payload, int gun_index)
  14641. {
  14642. mtrace();
  14643. DEBUG_INFO("handleAuthorizeResponse...\n");
  14644. json_object *Authorize;
  14645. Authorize = json_tokener_parse(payload);
  14646. if(!is_error(Authorize))
  14647. {
  14648. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  14649. {
  14650. // Required data
  14651. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  14652. // Optional data
  14653. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  14654. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  14655. else
  14656. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  14657. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  14658. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  14659. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  14660. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  14661. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  14662. {
  14663. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  14664. {
  14665. 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));
  14666. }
  14667. }
  14668. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  14669. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  14670. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  14671. {
  14672. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  14673. 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")));
  14674. else
  14675. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  14676. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  14677. 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")));
  14678. }
  14679. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  14680. {
  14681. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  14682. 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")));
  14683. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  14684. 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")));
  14685. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  14686. 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")));
  14687. }
  14688. }
  14689. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  14690. {
  14691. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  14692. }
  14693. }
  14694. json_object_put(Authorize);
  14695. //Update idTag information to authorization cache if supported
  14696. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  14697. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  14698. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  14699. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  14700. {
  14701. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  14702. }
  14703. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  14704. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  14705. authorizeRetryTimes = 0;
  14706. }
  14707. void handleBootNotificationResponse(char *payload, int gun_index)
  14708. {
  14709. mtrace();
  14710. char statusStr[12]={0};
  14711. char currentTimeStr[30]={0};
  14712. int intervalInt = 0;
  14713. DEBUG_INFO("handleBootNotificationResponse...\n");
  14714. json_object *BootNotification;
  14715. BootNotification = json_tokener_parse(payload);
  14716. if(!is_error(BootNotification))
  14717. {
  14718. // Required data
  14719. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  14720. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  14721. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  14722. }
  14723. json_object_put(BootNotification);
  14724. DEBUG_INFO("statusStr: %s\n", statusStr);
  14725. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  14726. BootNotificationInterval = intervalInt;
  14727. HeartBeatWaitTime = intervalInt;
  14728. //write back to ShmOCPP20Data->BootNotification
  14729. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  14730. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  14731. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  14732. {
  14733. server_sign = TRUE;
  14734. server_pending =FALSE;
  14735. DB_updateBootType(BootReasonEnumType_PowerUp);
  14736. }
  14737. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  14738. {
  14739. server_pending = TRUE;
  14740. }
  14741. syncDateTimeRTC(ShmOCPP20Data->BootNotification.Response_currentTime);
  14742. srand(time(NULL));
  14743. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  14744. SetOcppConnStatus(TRUE);
  14745. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  14746. }
  14747. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  14748. {
  14749. mtrace();
  14750. json_object *ClearedChargingLimit;
  14751. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  14752. ClearedChargingLimit = json_tokener_parse(payload);
  14753. if(!is_error(ClearedChargingLimit))
  14754. {
  14755. // Required data
  14756. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  14757. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  14758. }
  14759. json_object_put(ClearedChargingLimit);
  14760. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  14761. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitConf = ON;
  14762. }
  14763. void handleDataTransferResponse(char *payload, int gun_index)
  14764. {
  14765. mtrace();
  14766. json_object *DataTrans;
  14767. DEBUG_INFO("handleDataTransferResponse...\n");
  14768. DataTrans = json_tokener_parse(payload);
  14769. if(!is_error(DataTrans))
  14770. {
  14771. // Required data
  14772. if(json_object_object_get(DataTrans,"status") != NULL)
  14773. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  14774. // Optional data
  14775. if(json_object_object_get(DataTrans,"data") != NULL)
  14776. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  14777. }
  14778. json_object_put(DataTrans);
  14779. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  14780. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  14781. }
  14782. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  14783. {
  14784. mtrace();
  14785. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  14786. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  14787. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  14788. }
  14789. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  14790. {
  14791. mtrace();
  14792. json_object *Get15118EVCertificate;
  14793. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  14794. Get15118EVCertificate = json_tokener_parse(payload);
  14795. if(!is_error(Get15118EVCertificate))
  14796. {
  14797. // Required data
  14798. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  14799. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  14800. // Optional data
  14801. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  14802. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  14803. }
  14804. json_object_put(Get15118EVCertificate);
  14805. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  14806. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  14807. }
  14808. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  14809. {
  14810. mtrace();
  14811. json_object *GetCertificateStatus;
  14812. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  14813. GetCertificateStatus = json_tokener_parse(payload);
  14814. if(!is_error(GetCertificateStatus))
  14815. {
  14816. // Required data
  14817. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  14818. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  14819. // Optional data
  14820. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  14821. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  14822. }
  14823. json_object_put(GetCertificateStatus);
  14824. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  14825. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  14826. }
  14827. void handleHeartbeatResponse(char *payload, int gun_index)
  14828. {
  14829. mtrace();
  14830. DEBUG_INFO("handleHeartbeatResponse...\n");
  14831. json_object *Heartbeat;
  14832. Heartbeat = json_tokener_parse(payload);
  14833. if(!is_error(Heartbeat))
  14834. {
  14835. // Required data
  14836. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  14837. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  14838. }
  14839. json_object_put(Heartbeat);
  14840. if(FirstHeartBeat == OFF)
  14841. {
  14842. FirstHeartBeat = ON;
  14843. DEBUG_INFO("FirstHeartBeat \n");
  14844. }
  14845. HeartBeatWithNOResponse = 0;
  14846. clientTime.Heartbeat=time((time_t*)NULL);
  14847. syncDateTimeRTC(ShmOCPP20Data->Heartbeat.Response_currentTime);
  14848. }
  14849. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  14850. {
  14851. mtrace();
  14852. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  14853. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  14854. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  14855. }
  14856. void handleMeterValuesResponse(char *payload, int gun_index)
  14857. {
  14858. mtrace();
  14859. DEBUG_INFO("handleMeterValuesResponse...\n");
  14860. }
  14861. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  14862. {
  14863. mtrace();
  14864. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  14865. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  14866. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  14867. }
  14868. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  14869. {
  14870. mtrace();
  14871. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  14872. }
  14873. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  14874. {
  14875. mtrace();
  14876. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  14877. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  14878. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  14879. }
  14880. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  14881. {
  14882. mtrace();
  14883. json_object *NotifyEVChargingNeeds;
  14884. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  14885. NotifyEVChargingNeeds = json_tokener_parse(payload);
  14886. if(!is_error(NotifyEVChargingNeeds))
  14887. {
  14888. // Required data
  14889. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  14890. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  14891. }
  14892. json_object_put(NotifyEVChargingNeeds);
  14893. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  14894. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  14895. }
  14896. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  14897. {
  14898. mtrace();
  14899. json_object *NotifyEVChargingSchedule;
  14900. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  14901. NotifyEVChargingSchedule = json_tokener_parse(payload);
  14902. if(!is_error(NotifyEVChargingSchedule))
  14903. {
  14904. // Required data
  14905. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  14906. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  14907. }
  14908. json_object_put(NotifyEVChargingSchedule);
  14909. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  14910. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  14911. }
  14912. void hanldeNotifyEventResponse(char *payload, int gun_index)
  14913. {
  14914. mtrace();
  14915. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  14916. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  14917. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  14918. }
  14919. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  14920. {
  14921. mtrace();
  14922. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  14923. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  14924. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  14925. }
  14926. void hanldeNotifyReportResponse(char *payload, int gun_index)
  14927. {
  14928. mtrace();
  14929. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  14930. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  14931. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  14932. }
  14933. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  14934. {
  14935. mtrace();
  14936. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  14937. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  14938. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  14939. }
  14940. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  14941. {
  14942. mtrace();
  14943. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  14944. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  14945. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  14946. }
  14947. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  14948. {
  14949. mtrace();
  14950. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  14951. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  14952. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  14953. }
  14954. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  14955. {
  14956. mtrace();
  14957. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  14958. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  14959. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  14960. }
  14961. void hanldeSignCertificateResponse(char *payload, int gun_index)
  14962. {
  14963. mtrace();
  14964. json_object *SignCertificate;
  14965. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  14966. SignCertificate = json_tokener_parse(payload);
  14967. if(!is_error(SignCertificate))
  14968. {
  14969. // Required data
  14970. if(json_object_object_get(SignCertificate,"status") != NULL)
  14971. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  14972. // Optional data
  14973. if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode") != NULL)
  14974. {
  14975. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode")));
  14976. if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo") != NULL)
  14977. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo")));
  14978. }
  14979. }
  14980. json_object_put(SignCertificate);
  14981. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  14982. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  14983. }
  14984. void handleStatusNotificationResponse(char *payload, int gun_index)
  14985. {
  14986. mtrace();
  14987. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  14988. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  14989. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  14990. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  14991. }
  14992. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  14993. {
  14994. mtrace();
  14995. json_object *TransactionEven;
  14996. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  14997. TransactionEven = json_tokener_parse(payload);
  14998. if(!is_error(TransactionEven))
  14999. {
  15000. // Required data
  15001. // Optional data
  15002. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  15003. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  15004. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  15005. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  15006. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  15007. {
  15008. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  15009. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  15010. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  15011. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  15012. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  15013. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  15014. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  15015. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  15016. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  15017. {
  15018. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  15019. 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")));
  15020. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  15021. 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")));
  15022. }
  15023. }
  15024. }
  15025. json_object_put(TransactionEven);
  15026. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  15027. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  15028. }
  15029. //==========================================
  15030. // Handle Error routine
  15031. //==========================================
  15032. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  15033. {
  15034. mtrace();
  15035. #ifdef SystemLogMessage
  15036. DEBUG_INFO("errorCode: %s\n", errorCode);
  15037. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  15038. DEBUG_INFO("errorDetails: %s\n", payload);
  15039. #endif
  15040. }
  15041. //===============================================
  15042. // Common routine
  15043. //===============================================
  15044. int initialConfigurationTable(void)
  15045. {
  15046. DEBUG_INFO("initialConfigurationTable...\n");
  15047. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  15048. DB_variableIsCreate();
  15049. DB_variableLoadFromDb();
  15050. DB_getNetworkProfileFromDb();
  15051. return 0;
  15052. }
  15053. int TransactionMessageAttemptsGet(void)
  15054. {
  15055. return TransactionMessageAttemptsValue;
  15056. }
  15057. int FirstHeartBeatResponse(void)
  15058. {
  15059. return FirstHeartBeat;
  15060. }
  15061. int TransactionMessageRetryIntervalGet(void)
  15062. {
  15063. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  15064. }
  15065. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  15066. {
  15067. int result = TRUE;
  15068. char rmFileCmd[100]={0};
  15069. char FilePath[100]={0};
  15070. char ftpbuf[200];
  15071. int systemresult;
  15072. //DEBUG_INFO("filename=%s\n",filename);
  15073. //DEBUG_INFO("url=%s\n",url);
  15074. sprintf(FilePath,"/mnt/%s",filename);
  15075. system("ping 8.8.8.8 &");
  15076. if((access(FilePath,F_OK))!=-1)
  15077. {
  15078. DEBUG_INFO("filename=%s exist.\n",FilePath);
  15079. sprintf(rmFileCmd,"rm -f %s",FilePath);
  15080. system(rmFileCmd);
  15081. }
  15082. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  15083. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  15084. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  15085. systemresult = system(ftpbuf);
  15086. //DEBUG_INFO("systemresult=%d\n",systemresult);
  15087. if(systemresult != 0)
  15088. {
  15089. DEBUG_INFO("http DownLoad error!\n");
  15090. result = FALSE;
  15091. }
  15092. system("pkill ping");
  15093. return result;
  15094. }
  15095. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  15096. {
  15097. int result = TRUE;
  15098. char rmFileCmd[100]={0};
  15099. char FilePath[100]={0};
  15100. char ftpbuf[200];
  15101. int systemresult;
  15102. //char temp[100];
  15103. sprintf(FilePath,"/mnt/%s",filename);
  15104. system("ping 8.8.8.8 &");
  15105. if((access(FilePath,F_OK))!=-1)
  15106. {
  15107. DEBUG_INFO("filename=%s exist.\n",FilePath);
  15108. sprintf(rmFileCmd,"rm -f %s",FilePath);
  15109. system(rmFileCmd);
  15110. }
  15111. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  15112. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  15113. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  15114. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  15115. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  15116. systemresult = system(ftpbuf);
  15117. //DEBUG_INFO("systemresult=%d\n",systemresult);
  15118. if(systemresult != 0)
  15119. {
  15120. printf("wget error!\n");
  15121. result = FALSE;
  15122. }
  15123. system("pkill ping");
  15124. return result;
  15125. }
  15126. int httpUploadFile(char *location, char *path, char *filename,char *url)
  15127. {
  15128. char rmFileCmd[100]={0};
  15129. char FilePath[100]={0};
  15130. char buf[512];
  15131. int systemresult = 0;
  15132. //DEBUG_INFO("filename=%s\n",filename);
  15133. //DEBUG_INFO("url=%s\n",url);
  15134. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  15135. if((access(FilePath,F_OK))!=-1)
  15136. {
  15137. DEBUG_INFO("filename=%s exist.\n",FilePath);
  15138. sprintf(rmFileCmd,"rm -f %s",FilePath);
  15139. system(rmFileCmd);
  15140. }
  15141. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  15142. if(fp == NULL)
  15143. {
  15144. DEBUG_INFO("log is NULL\n");
  15145. return FALSE;
  15146. }
  15147. else
  15148. {
  15149. fprintf(fp, "%s\n", url);
  15150. fprintf(fp, "%s\n", filename);
  15151. fclose(fp);
  15152. }
  15153. FILE *phpFP = popen("/bin/php-cgi /var/www/ocpp_upload.php", "r");
  15154. if(phpFP == NULL)
  15155. {
  15156. DEBUG_INFO("PHP upload fail.\n");
  15157. return FALSE;
  15158. }
  15159. else
  15160. {
  15161. while(fgets(buf, sizeof(buf), phpFP) != NULL)
  15162. {
  15163. if(strstr(buf, "result") != NULL)
  15164. {
  15165. sscanf(buf, "result: %d", &systemresult);
  15166. DEBUG_INFO("PHP HTTP upload result: %d\n", systemresult);
  15167. }
  15168. }
  15169. pclose(phpFP);
  15170. }
  15171. if(systemresult != 1)
  15172. {
  15173. DEBUG_INFO("HTTP upload error!\n");
  15174. return FALSE;
  15175. }
  15176. return TRUE;
  15177. }
  15178. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  15179. {
  15180. struct hostent* server;
  15181. char *IPbuffer;
  15182. char ftpbuf[200];
  15183. int systemresult;
  15184. // To retrieve host information
  15185. server = gethostbyname(location);
  15186. // To convert an Internet network
  15187. // address into ASCII string
  15188. IPbuffer = inet_ntoa(*((struct in_addr*)
  15189. server->h_addr_list[0]));
  15190. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  15191. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  15192. /* format : ftpput -u username -p passwd IP target source*/
  15193. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  15194. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  15195. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  15196. systemresult = system(ftpbuf);
  15197. DEBUG_INFO("systemresult=%d\n",systemresult);
  15198. if(systemresult != 0)
  15199. {
  15200. DEBUG_INFO("ftpput error!\n");
  15201. return FALSE;
  15202. }
  15203. return TRUE;
  15204. }
  15205. //=========================================
  15206. // Routine
  15207. //=========================================
  15208. int GetOcppServerURL()
  15209. {
  15210. int result = FALSE;
  15211. struct yuarel url;
  15212. char urlStr[512];
  15213. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  15214. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  15215. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  15216. if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  15217. {
  15218. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  15219. if(yuarel_parse(&url, urlStr) != -1)
  15220. {
  15221. sprintf(OcppProtocol, "%s", url.scheme);
  15222. sprintf(OcppHost, "%s", url.host);
  15223. if(url.path == NULL)
  15224. OcppTempPath[0] = '\0';
  15225. else
  15226. sprintf(OcppTempPath, "%s", url.path);
  15227. if(url.port == 0)
  15228. {
  15229. if(strcmp(OcppProtocol, "wss") == 0)
  15230. OcppPort = 443;
  15231. else
  15232. OcppPort = 80;
  15233. }
  15234. else
  15235. OcppPort = url.port;
  15236. result = TRUE;
  15237. }
  15238. }
  15239. else
  15240. {
  15241. strcpy(OcppHost,"");
  15242. }
  15243. return result;
  15244. }
  15245. int GetOcppPath()
  15246. {
  15247. int result = FALSE;
  15248. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  15249. {
  15250. if(OcppTempPath == NULL)
  15251. {
  15252. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  15253. }
  15254. else
  15255. {
  15256. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  15257. }
  15258. result = TRUE;
  15259. }
  15260. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  15261. {
  15262. if(OcppTempPath == NULL)
  15263. {
  15264. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  15265. }
  15266. else
  15267. {
  15268. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  15269. }
  15270. result = TRUE;
  15271. }
  15272. else
  15273. {
  15274. strcpy(OcppPath,"");
  15275. }
  15276. return result;
  15277. }
  15278. int GetOcppPort()
  15279. {
  15280. return OcppPort;
  15281. }
  15282. int GetOcppConnStatus(void)
  15283. {
  15284. return ShmOCPP20Data->OcppConnStatus;
  15285. }
  15286. void SetOcppConnStatus(uint8_t status)
  15287. {
  15288. ShmOCPP20Data->OcppConnStatus = status;
  15289. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  15290. }
  15291. int GetHeartBeatWithNOResponse(void)
  15292. {
  15293. return HeartBeatWithNOResponse;
  15294. }
  15295. void SetHeartBeatWithNOResponse(void)
  15296. {
  15297. HeartBeatWithNOResponse = 0;
  15298. }
  15299. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  15300. void storeTempStopTransaction(int gun_index)
  15301. {
  15302. char TempStopTransaction[256];
  15303. char message[1024*20]={0};
  15304. char guid[37]={0};
  15305. uint8_t tempIndex;
  15306. json_object *TransactionEvent = json_object_new_object();
  15307. json_object *transactionInfo = json_object_new_object();
  15308. json_object *idToken = json_object_new_object();
  15309. json_object *evse = json_object_new_object();
  15310. json_object *meterValues = json_object_new_array();
  15311. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  15312. DEBUG_INFO("storeTempStopTransaction...\n");
  15313. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  15314. {
  15315. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15316. {
  15317. tempIndex = ((gun_index==2) ? 1: 0);
  15318. }
  15319. else
  15320. {
  15321. tempIndex = gun_index;
  15322. }
  15323. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  15324. {
  15325. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  15326. {
  15327. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  15328. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  15329. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  15330. else
  15331. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  15332. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  15333. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  15334. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  15335. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  15336. {
  15337. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  15338. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  15339. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  15340. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  15341. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  15342. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  15343. {
  15344. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  15345. }
  15346. else
  15347. {
  15348. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  15349. }
  15350. }
  15351. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  15352. {
  15353. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  15354. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  15355. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  15356. }
  15357. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  15358. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  15359. ) //S_PRECHARGE
  15360. {
  15361. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  15362. {
  15363. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  15364. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  15365. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  15366. }
  15367. if(ShmOCPP20Data->TransactionEvent[gun_index].eventType[0] == '\0')
  15368. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  15369. else
  15370. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  15371. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  15372. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15373. }
  15374. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  15375. {
  15376. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  15377. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  15378. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15379. }
  15380. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  15381. {
  15382. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  15383. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  15384. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15385. }
  15386. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  15387. {
  15388. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  15389. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  15390. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15391. }
  15392. 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
  15393. {
  15394. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  15395. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  15396. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  15397. }
  15398. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  15399. {
  15400. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  15401. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  15402. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  15403. }
  15404. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  15405. {
  15406. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  15407. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  15408. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  15409. }
  15410. } //end of the same index
  15411. }//end of for CHAdeMO_QUANTITY
  15412. }
  15413. else if(gunType[gun_index] == GUN_TYPE_CCS)
  15414. {
  15415. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15416. {
  15417. tempIndex = ((gun_index==2) ? 1: 0);
  15418. }
  15419. else
  15420. {
  15421. tempIndex = gun_index;
  15422. }
  15423. for (int index = 0; index < CCS_QUANTITY; index++)
  15424. {
  15425. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  15426. {
  15427. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  15428. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  15429. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  15430. else
  15431. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  15432. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  15433. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  15434. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  15435. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  15436. {
  15437. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  15438. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  15439. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  15440. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  15441. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  15442. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  15443. {
  15444. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  15445. }
  15446. else
  15447. {
  15448. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  15449. }
  15450. }
  15451. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  15452. {
  15453. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  15454. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  15455. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  15456. }
  15457. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  15458. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  15459. ) //S_PRECHARGE
  15460. {
  15461. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  15462. {
  15463. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  15464. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  15465. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  15466. }
  15467. if(ShmOCPP20Data->TransactionEvent[gun_index].eventType[0] == '\0')
  15468. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  15469. else
  15470. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  15471. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  15472. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15473. }
  15474. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  15475. {
  15476. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  15477. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  15478. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15479. }
  15480. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  15481. {
  15482. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  15483. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  15484. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15485. }
  15486. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  15487. {
  15488. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  15489. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  15490. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15491. }
  15492. 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
  15493. {
  15494. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  15495. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  15496. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  15497. }
  15498. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  15499. {
  15500. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  15501. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  15502. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  15503. }
  15504. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  15505. {
  15506. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  15507. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  15508. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  15509. }
  15510. } //end of the same index
  15511. } // end of for CCS_QUANTITY
  15512. }
  15513. else if(gunType[gun_index] == GUN_TYPE_GBT)
  15514. {
  15515. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15516. {
  15517. tempIndex = ((gun_index==2) ? 1: 0);
  15518. }
  15519. else
  15520. {
  15521. tempIndex = gun_index;
  15522. }
  15523. for (int index = 0; index < GB_QUANTITY; index++)
  15524. {
  15525. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  15526. {
  15527. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  15528. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  15529. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  15530. else
  15531. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  15532. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  15533. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  15534. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  15535. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  15536. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  15537. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15538. } //end of the same index
  15539. } // end of for GB_QUANTITY
  15540. }
  15541. else if(gunType[gun_index] == GUN_TYPE_DO)
  15542. {
  15543. tempIndex = gun_index;
  15544. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  15545. {
  15546. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  15547. {
  15548. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  15549. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  15550. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  15551. else
  15552. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  15553. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  15554. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  15555. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  15556. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  15557. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  15558. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15559. } //end of the same index
  15560. }
  15561. }
  15562. else
  15563. {
  15564. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  15565. {
  15566. tempIndex = 2;
  15567. }
  15568. else
  15569. {
  15570. tempIndex = gun_index;
  15571. }
  15572. for (int index = 0; index < AC_QUANTITY; index++)
  15573. {
  15574. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  15575. {
  15576. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  15577. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  15578. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  15579. else
  15580. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  15581. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  15582. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  15583. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  15584. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  15585. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  15586. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  15587. }//end of the same index
  15588. }//end of for AC_QUANTITY
  15589. }
  15590. // Message
  15591. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  15592. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  15593. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  15594. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  15595. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  15596. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  15597. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  15598. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  15599. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  15600. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  15601. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  15602. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  15603. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  15604. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  15605. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  15606. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  15607. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  15608. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  15609. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  15610. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  15611. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  15612. {
  15613. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  15614. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  15615. json_object_object_add(TransactionEvent, "idToken", idToken);
  15616. }
  15617. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  15618. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  15619. json_object_object_add(TransactionEvent, "evse", evse);
  15620. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  15621. {
  15622. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  15623. {
  15624. json_object *meterValue = json_object_new_object();
  15625. json_object *sampledValues = json_object_new_array();
  15626. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  15627. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  15628. {
  15629. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  15630. ((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)))
  15631. {
  15632. json_object *sampledValue = json_object_new_object();
  15633. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  15634. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  15635. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  15636. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  15637. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  15638. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  15639. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  15640. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  15641. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  15642. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  15643. {
  15644. json_object *unitOfMeasure = json_object_new_object();
  15645. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  15646. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  15647. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  15648. }
  15649. json_object_array_add(sampledValues, sampledValue);
  15650. }
  15651. }
  15652. json_object_object_add(meterValue, "sampledValue", sampledValues);
  15653. json_object_array_add(meterValues, meterValue);
  15654. }
  15655. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  15656. }
  15657. random_uuid(guid);
  15658. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL
  15659. , guid
  15660. , "TransactionEvent"
  15661. , json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  15662. json_object_put(TransactionEvent);
  15663. // open file for writing
  15664. FILE *outfile;
  15665. outfile = fopen (TempStopTransaction, "w+");
  15666. //DEBUG_INFO("data = %s\n", queuedata);
  15667. fputs(message, outfile);
  15668. fputs("\n", outfile);
  15669. fclose (outfile);
  15670. }
  15671. void checkTempStopTransaction(int gun_index)
  15672. {
  15673. FILE *fptr1;
  15674. char ch;
  15675. char str[QUEUE_MESSAGE_LENGTH]={0};
  15676. char guid[37]={0};
  15677. char tempdata[65]={0};
  15678. char TempStopTransaction[256];
  15679. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  15680. fptr1 = fopen(TempStopTransaction, "r");
  15681. if (!fptr1)
  15682. {
  15683. //DEBUG_INFO("TempStopTransaction_%d not found or unable to open the input file!\n", (gun_index+1));
  15684. return ;
  15685. }
  15686. ch=fgetc(fptr1);
  15687. rewind(fptr1);
  15688. if(ch!=EOF)
  15689. {
  15690. // copy all contents to the temporary file except the specific line
  15691. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  15692. {
  15693. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  15694. if(str[0]=='\0')
  15695. {
  15696. break;
  15697. }
  15698. strncpy(guid, str+4, 36); //copy guid
  15699. sprintf(tempdata, "TransactionEvent,%d", (gun_index));
  15700. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  15701. {
  15702. //DEBUG_INFO("StopTransaction mapitem pass\n");
  15703. }
  15704. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  15705. memset(str,0,ARRAY_SIZE(str));
  15706. }
  15707. }
  15708. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  15709. fclose(fptr1);
  15710. remove(TempStopTransaction); // remove the original file
  15711. }
  15712. int GetWebSocketPingInterval(void)
  15713. {
  15714. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  15715. }
  15716. int GetServerSign(void)
  15717. {
  15718. return server_sign;
  15719. }
  15720. uint8_t GetOcppSecurityProfile()
  15721. {
  15722. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  15723. }
  15724. void GetOcppChargerBoxId(uint8_t *data)
  15725. {
  15726. sprintf((char*)data, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  15727. }
  15728. void GetOcppSecurityPassword(uint8_t *data)
  15729. {
  15730. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  15731. }
  15732. void SetServerSign(int value)
  15733. {
  15734. server_sign = value;
  15735. }
  15736. int GetBootNotificationInterval(void)
  15737. {
  15738. return BootNotificationInterval;
  15739. }
  15740. int GetInternetConn(void)
  15741. {
  15742. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  15743. }
  15744. int GetBackendConnectionTimeout(void)
  15745. {
  15746. return ShmSysConfigAndInfo->SysConfig.BackendConnTimeout>=0?ShmSysConfigAndInfo->SysConfig.BackendConnTimeout:300;
  15747. }
  15748. int isConnectorInitMode(int gun_index)
  15749. {
  15750. int tempIndex = 0;
  15751. int result = TRUE;
  15752. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  15753. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  15754. {
  15755. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15756. {
  15757. tempIndex = ((gun_index==2) ? 1: 0);
  15758. }
  15759. else
  15760. {
  15761. tempIndex = gun_index;
  15762. }
  15763. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  15764. {
  15765. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  15766. {
  15767. result = (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  15768. } //end of the same index
  15769. }//end of for CHAdeMO_QUANTITY
  15770. }
  15771. else if(gunType[gun_index] == GUN_TYPE_CCS)
  15772. {
  15773. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15774. {
  15775. tempIndex = ((gun_index==2) ? 1: 0);
  15776. }
  15777. else
  15778. {
  15779. tempIndex = gun_index;
  15780. }
  15781. for (int index = 0; index < CCS_QUANTITY; index++)
  15782. {
  15783. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  15784. {
  15785. result = (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  15786. } //end of the same index
  15787. } // end of for CCS_QUANTITY
  15788. }
  15789. else if(gunType[gun_index] == GUN_TYPE_GBT)
  15790. {
  15791. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  15792. {
  15793. tempIndex = ((gun_index==2) ? 1: 0);
  15794. }
  15795. else
  15796. {
  15797. tempIndex = gun_index;
  15798. }
  15799. for (int index = 0; index < GB_QUANTITY; index++)
  15800. {
  15801. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  15802. {
  15803. result = (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  15804. } //end of the same index
  15805. } // end of for GB_QUANTITY
  15806. }
  15807. else if(gunType[gun_index] == GUN_TYPE_DO)
  15808. {
  15809. tempIndex = gun_index;
  15810. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  15811. {
  15812. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  15813. {
  15814. result = (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  15815. } //end of the same index
  15816. }
  15817. }
  15818. else
  15819. {
  15820. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  15821. {
  15822. tempIndex = 2;
  15823. }
  15824. else
  15825. {
  15826. tempIndex = gun_index;
  15827. }
  15828. for (int index = 0; index < AC_QUANTITY; index++)
  15829. {
  15830. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  15831. {
  15832. result = (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  15833. }//end of the same index
  15834. }//end of for AC_QUANTITY
  15835. }
  15836. return result;
  15837. }
  15838. void refreshProcDogTimer()
  15839. {
  15840. ShmOCPP20Data->procDogTime = time((time_t*)NULL);
  15841. }
  15842. void InitialSystemValue(void)
  15843. {
  15844. int connectorIndex = 0;
  15845. gunTotalNumber=0;
  15846. SystemInitial = 0;
  15847. localversion=0;
  15848. BootNotificationInterval = 10;
  15849. authorizeRetryTimes = 0;
  15850. GunStatusInterval = 10;
  15851. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  15852. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  15853. //Hear Beat
  15854. HeartBeatWithNOResponse = 0;
  15855. HeartBeatCountPerHour = 0;
  15856. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  15857. FirstHeartBeat = 0;
  15858. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  15859. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  15860. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  15861. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  15862. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  15863. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  15864. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  15865. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  15866. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  15867. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  15868. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  15869. memset(gunType, 0, ARRAY_SIZE(gunType));
  15870. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  15871. {
  15872. if((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
  15873. (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
  15874. (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
  15875. {
  15876. // DO series
  15877. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  15878. {
  15879. SystemInitial = SystemInitial + 1;
  15880. gunTotalNumber = gunTotalNumber + 1;
  15881. gunType[connectorIndex] = GUN_TYPE_DO;
  15882. connectorIndex = connectorIndex + 1;
  15883. }
  15884. }
  15885. else
  15886. {
  15887. // DM, DW, DS series
  15888. //check connector / socket type (index: 8, 9, 10)
  15889. for(int index=7; index <10 ; index++)
  15890. {
  15891. if(index != 8)
  15892. {
  15893. // DC Connector
  15894. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'J'))
  15895. {
  15896. SystemInitial = SystemInitial + 1;
  15897. gunTotalNumber = gunTotalNumber + 1;
  15898. gunType[connectorIndex] = GUN_TYPE_CHAdeMO;
  15899. connectorIndex = connectorIndex + 1;
  15900. }
  15901. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'D') ||
  15902. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'E') ||
  15903. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'F') ||
  15904. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'U') ||
  15905. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'T') ||
  15906. (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'V'))
  15907. {
  15908. SystemInitial = SystemInitial + 1;
  15909. gunTotalNumber = gunTotalNumber + 1;
  15910. gunType[connectorIndex] = GUN_TYPE_CCS;
  15911. connectorIndex = connectorIndex + 1;
  15912. }
  15913. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'G'))
  15914. {
  15915. SystemInitial = SystemInitial + 1;
  15916. gunTotalNumber = gunTotalNumber + 1;
  15917. gunType[connectorIndex] = GUN_TYPE_GBT;
  15918. connectorIndex = connectorIndex + 1;
  15919. }
  15920. else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'O'))
  15921. {
  15922. SystemInitial = SystemInitial + 1;
  15923. gunTotalNumber = gunTotalNumber + 1;
  15924. gunType[connectorIndex] = GUN_TYPE_DO;
  15925. connectorIndex = connectorIndex + 1;
  15926. }
  15927. }
  15928. else
  15929. {
  15930. // AC Connector
  15931. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  15932. {
  15933. SystemInitial = SystemInitial + 1;
  15934. gunTotalNumber = gunTotalNumber + 1;
  15935. gunType[connectorIndex] = GUN_TYPE_AC;
  15936. connectorIndex = connectorIndex + 1;
  15937. }
  15938. }
  15939. }
  15940. }
  15941. //DEBUG_INFO("DC ...\n");
  15942. }
  15943. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  15944. {
  15945. //check connector / socket type (index: 8, 9, 10)
  15946. for(int index=7; index <10 ; index++)
  15947. {
  15948. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  15949. {
  15950. SystemInitial = SystemInitial + 1;
  15951. gunTotalNumber = gunTotalNumber + 1;
  15952. gunType[connectorIndex] = GUN_TYPE_AC;
  15953. connectorIndex = connectorIndex + 1;
  15954. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  15955. }
  15956. }
  15957. }
  15958. //Status && ConnectorPlugIn Setting
  15959. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  15960. {
  15961. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  15962. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  15963. }
  15964. for (int index = 0; index < CCS_QUANTITY; index++)
  15965. {
  15966. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  15967. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  15968. }
  15969. for (int index = 0; index < GB_QUANTITY; index++)
  15970. {
  15971. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  15972. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  15973. }
  15974. for (int index = 0; index < AC_QUANTITY; index++)
  15975. {
  15976. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  15977. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  15978. }
  15979. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  15980. {
  15981. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  15982. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  15983. }
  15984. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  15985. {
  15986. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  15987. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  15988. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  15989. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  15990. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  15991. memset(&ShmOCPP20Data->StatusNotification[gun_index], 0x00, sizeof(struct StatusNotification_20));
  15992. }
  15993. clientTime.Heartbeat=time((time_t*)NULL);
  15994. sleep(1);
  15995. }
  15996. void LWS_Send(char *str)
  15997. {
  15998. //=====================================================
  15999. // Check InternetConn 0: disconnected, 1: connected
  16000. //====================================================
  16001. if(GetOcppConnStatus() == 0)
  16002. {
  16003. DEBUG_INFO("offline now !!!\n");
  16004. return;
  16005. }
  16006. // Only disable isWebsocketSendable operation initiated by charger
  16007. if((strstr((char*)str, "\"Authorize\"") != NULL)
  16008. || (strstr((char*)str, "\"BootNotification\"") != NULL)
  16009. || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
  16010. || (strstr((char*)str, "\"DataTransfer\"") != NULL)
  16011. || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
  16012. || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
  16013. || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
  16014. || (strstr((char*)str, "\"Heartbeat\"") != NULL)
  16015. || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
  16016. || (strstr((char*)str, "\"MeterValues\"") != NULL)
  16017. || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
  16018. || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
  16019. || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
  16020. || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
  16021. || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
  16022. || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
  16023. || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
  16024. || (strstr((char*)str, "\"NotifyReport\"") != NULL)
  16025. || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
  16026. || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
  16027. || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
  16028. || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
  16029. || (strstr((char*)str, "\"SignCertificate\"") != NULL)
  16030. || (strstr((char*)str, "\"StatusNotification\"") != NULL)
  16031. || (strstr((char*)str, "\"TransactionEven\"") != NULL))
  16032. {
  16033. isWebsocketSendable = OFF;
  16034. }
  16035. pthread_mutex_lock(&lock_send);
  16036. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  16037. sprintf((char *)SendBuffer, "%s", str);
  16038. SendBufLen = strlen(str);
  16039. pthread_mutex_unlock(&lock_send);
  16040. lws_callback_on_writable(wsi_client);
  16041. //lws_service(context, 0);
  16042. //sleep(1);
  16043. }
  16044. void LWS_SendNow(char *str)
  16045. {
  16046. //=====================================================
  16047. // Check InternetConn 0: disconnected, 1: connected
  16048. //====================================================
  16049. if(GetOcppConnStatus() == 0)
  16050. {
  16051. DEBUG_INFO("offline now !!!\n");
  16052. return;
  16053. }
  16054. // Only disable isWebsocketSendable operation initiated by charger
  16055. if((strstr((char*)str, "\"Authorize\"") != NULL)
  16056. || (strstr((char*)str, "\"BootNotification\"") != NULL)
  16057. || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
  16058. || (strstr((char*)str, "\"DataTransfer\"") != NULL)
  16059. || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
  16060. || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
  16061. || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
  16062. || (strstr((char*)str, "\"Heartbeat\"") != NULL)
  16063. || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
  16064. || (strstr((char*)str, "\"MeterValues\"") != NULL)
  16065. || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
  16066. || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
  16067. || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
  16068. || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
  16069. || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
  16070. || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
  16071. || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
  16072. || (strstr((char*)str, "\"NotifyReport\"") != NULL)
  16073. || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
  16074. || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
  16075. || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
  16076. || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
  16077. || (strstr((char*)str, "\"SignCertificate\"") != NULL)
  16078. || (strstr((char*)str, "\"StatusNotification\"") != NULL)
  16079. || (strstr((char*)str, "\"TransactionEven\"") != NULL))
  16080. {
  16081. isWebsocketSendable = OFF;
  16082. }
  16083. pthread_mutex_lock(&lock_send);
  16084. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  16085. sprintf((char *)SendBuffer, "%s", str);
  16086. SendBufLen = strlen(str);
  16087. pthread_mutex_unlock(&lock_send);
  16088. lws_callback_on_writable(wsi_client);
  16089. lws_service(context, 0);
  16090. //sleep(1);
  16091. }