1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292 |
- #include "Module_OcppBackend20.h"
- #include "define.h"
- static char *APNAuthenticationEnumTypeStr[] = {
- MACROSTR(CHAP),
- MACROSTR(NONE),
- MACROSTR(PAP),
- MACROSTR(AUTO)
- };
- static char *AttributeEnumTypeStr[] = {
- MACROSTR(Actual),
- MACROSTR(Target),
- MACROSTR(MinSet),
- MACROSTR(MaxSet)
- };
- static char *AuthorizationStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Blocked),
- MACROSTR(ConcurrentTx),
- MACROSTR(Expired),
- MACROSTR(Invalid),
- MACROSTR(NoCredit),
- MACROSTR(NotAllowedTypeEVSE),
- MACROSTR(NotAtThisLocation),
- MACROSTR(NotAtThisTime),
- MACROSTR(Unknown)
- };
- #if 0
- static char *AuthorizeCertificateStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(SignatureError),
- MACROSTR(CertificateExpired),
- MACROSTR(CertificateRevoked),
- MACROSTR(NoCertificateAvailable),
- MACROSTR(CertChainError),
- MACROSTR(ContractCancelled)
- };
- #endif
- static char *BootReasonEnumTypeStr[] = {
- MACROSTR(ApplicationReset),
- MACROSTR(FirmwareUpdate),
- MACROSTR(LocalReset),
- MACROSTR(PowerUp),
- MACROSTR(RemoteReset),
- MACROSTR(ScheduledReset),
- MACROSTR(Triggered),
- MACROSTR(Unknown),
- MACROSTR(Watchdog)
- };
- static char *SecurityEventEnumTypeStr[] = {
- MACROSTR(FirmwareUpdated),
- MACROSTR(FailedToAuthenticateAtCsms),
- MACROSTR(CsmsFailedToAuthenticate),
- MACROSTR(SettingSystemTime),
- MACROSTR(StartupOfTheDevice),
- MACROSTR(ResetOrReboot),
- MACROSTR(SecurityLogWasCleared),
- MACROSTR(ReconfigurationOfSecurityParameters),
- MACROSTR(MemoryExhaustion),
- MACROSTR(InvalidMessages),
- MACROSTR(AttemptedReplayAttacks),
- MACROSTR(TamperDetectionActivated),
- MACROSTR(InvalidFirmwareSignature),
- MACROSTR(InvalidFirmwareSigningCertificate),
- MACROSTR(InvalidCsmsCertificate),
- MACROSTR(InvalidChargingStationCertificate),
- MACROSTR(InvalidTLSVersion),
- MACROSTR(InvalidTLSCipherSuite)
- };
- static char *CancelReservationStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- static char *CertificateActionEnumTypeStr[] = {
- MACROSTR(Install),
- MACROSTR(Update)
- };
- static char *CertificateSignedStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- static char *CertificateSigningUseEnumTypeStr[] = {
- MACROSTR(ChargingStationCertificate),
- MACROSTR(V2GCertificate)
- };
- static char *ChangeAvailabilityStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(Scheduled)
- };
- #if 0
- static char *ChargingLimitSourceEnumTypeStr[] = {
- MACROSTR(EMS),
- MACROSTR(Other),
- MACROSTR(SO),
- MACROSTR(CSO)
- };
- #endif
- static char *ChargingProfileKindEnumTypeStr[] = {
- MACROSTR(Absolute),
- MACROSTR(Recurring),
- MACROSTR(Relative)
- };
- static char *ChargingProfilePurposeEnumTypeStr[] = {
- MACROSTR(ChargingStationExternalConstraints),
- MACROSTR(ChargingStationMaxProfile),
- MACROSTR(TxDefaultProfile),
- MACROSTR(TxProfile)
- };
- static char *ChargingProfileStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- static char *ChargingRateUnitEnumTypeStr[] = {
- MACROSTR(W),
- MACROSTR(A)
- };
- static char *ChargingStateEnumTypeStr[] = {
- MACROSTR(Charging),
- MACROSTR(EVConnected),
- MACROSTR(SuspendedEV),
- MACROSTR(SuspendedEVSE),
- MACROSTR(Idle)
- };
- static char *ClearCacheStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- static char *ClearChargingProfileStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Unknown)
- };
- static char *ClearMessageStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Unknown)
- };
- static char *ClearMonitoringStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(NotFound)
- };
- static char *ComponentCriterionEnumTypeStr[] = {
- MACROSTR(Active),
- MACROSTR(Available),
- MACROSTR(Enabled),
- MACROSTR(Problem)
- };
- #if 0
- static char *ConnectorEnumTypeStr[] = {
- MACROSTR(cCCS1),
- MACROSTR(cCCS2),
- MACROSTR(cG105),
- MACROSTR(cTesla),
- MACROSTR(cType1),
- MACROSTR(cType2),
- MACROSTR(s309-1P-16A),
- MACROSTR(s309-1P-32A),
- MACROSTR(s309-3P-16A),
- MACROSTR(s309-3P-32A),
- MACROSTR(sBS1361),
- MACROSTR(sCEE-7-7),
- MACROSTR(sType2),
- MACROSTR(sType3),
- MACROSTR(Other1PhMax16A),
- MACROSTR(Other1PhOver16A),
- MACROSTR(Other3Ph),
- MACROSTR(Pan),
- MACROSTR(wInductive),
- MACROSTR(wResonant),
- MACROSTR(Undetermined),
- MACROSTR(Unknown)
- };
- #endif
- static char *ConnectorStatusEnumTypeStr[] = {
- MACROSTR(Available),
- MACROSTR(Occupied),
- MACROSTR(Reserved),
- MACROSTR(Unavailable),
- MACROSTR(Faulted)
- };
- #if 0
- static char *CostKindEnumTypeStr[] = {
- MACROSTR(CarbonDioxideEmission),
- MACROSTR(RelativePricePercentage),
- MACROSTR(RenewableGenerationPercentage)
- };
- #endif
- static char *CustomerInformationStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(Invalid)
- };
- static char *DataEnumTypeStr[] = {
- MACROSTR(string),
- MACROSTR(decimal),
- MACROSTR(integer),
- MACROSTR(dateTime),
- MACROSTR(boolean),
- MACROSTR(OptionList),
- MACROSTR(SequenceList),
- MACROSTR(MemberList)
- };
- static char *DataTransferStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(UnknownMessageId),
- MACROSTR(UnknownVendorId)
- };
- static char *DeleteCertificateStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Failed),
- MACROSTR(NotFound)
- };
- static char *DisplayMessageStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(NotSupportedMessageFormat),
- MACROSTR(Rejected),
- MACROSTR(NotSupportedPriority),
- MACROSTR(NotSupportedState),
- MACROSTR(UnknownTransaction)
- };
- #if 0
- static char *EnergyTransferModeEnumTypeStr[] = {
- MACROSTR(DC),
- MACROSTR(AC_single_phase),
- MACROSTR(AC_two_phase),
- MACROSTR(AC_three_phase)
- };
- #endif
- static char *EventNotificationEnumTypeStr[] = {
- MACROSTR(HardWiredNotification),
- MACROSTR(HardWiredMonitor),
- MACROSTR(PreconfiguredMonitor),
- MACROSTR(CustomMonitor)
- };
- static char *EventTriggerEnumTypeStr[] = {
- MACROSTR(Alerting),
- MACROSTR(Delta),
- MACROSTR(Periodic)
- };
- static char *FirmwareStatusEnumTypeStr[] = {
- MACROSTR(Downloaded),
- MACROSTR(DownloadFailed),
- MACROSTR(Downloading),
- MACROSTR(DownloadScheduled),
- MACROSTR(DownloadPaused),
- MACROSTR(Idle),
- MACROSTR(InstallationFailed),
- MACROSTR(Installing),
- MACROSTR(Installed),
- MACROSTR(InstallRebooting),
- MACROSTR(InstallScheduled),
- MACROSTR(InstallVerificationFailed),
- MACROSTR(InvalidSignature),
- MACROSTR(SignatureVerified)
- };
- static char *GenericDeviceModelStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(NotSupported),
- MACROSTR(EmptyResultSet)
- };
- static char *GenericStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- static char *GetCertificateIdUseEnumTypeStr[] = {
- MACROSTR(V2GRootCertificate),
- MACROSTR(MORootCertificate),
- MACROSTR(CSMSRootCertificate),
- MACROSTR(V2GCertificateChain),
- MACROSTR(ManufacturerRootCertificate)
- };
- static char *GetCertificateStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Failed)
- };
- static char *GetChargingProfileStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(NoProfiles)
- };
- static char *GetDisplayMessagesStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Unknown)
- };
- static char *GetInstalledCertificateStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(NotFound)
- };
- static char *GetVariableStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(UnknownComponent),
- MACROSTR(UnknownVariable),
- MACROSTR(NotSupportedAttributeType)
- };
- static char *HashAlgorithmEnumTypeStr[] = {
- MACROSTR(SHA256),
- MACROSTR(SHA384),
- MACROSTR(SHA512)
- };
- static char *IdTokenEnumTypeStr[] = {
- MACROSTR(Central),
- MACROSTR(eMAID),
- MACROSTR(ISO14443),
- MACROSTR(ISO15693),
- MACROSTR(KeyCode),
- MACROSTR(Local),
- MACROSTR(MacAddress),
- MACROSTR(NoAuthorization),
- };
- static char *InstallCertificateUseEnumTypeStr[] = {
- MACROSTR(V2GRootCertificate),
- MACROSTR(MORootCertificate),
- MACROSTR(CSMSRootCertificate),
- MACROSTR(ManufacturerRootCertificate)
- };
- static char *InstallCertificateStatusEnumTypeStr[]={
- MACROSTR(Accepted),
- MACROSTR(Failed),
- MACROSTR(Rejected)
- };
- static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Failed)
- };
- static char *LocationEnumTypeStr[] = {
- MACROSTR(Body),
- MACROSTR(Cable),
- MACROSTR(EV),
- MACROSTR(Inlet),
- MACROSTR(Outlet)
- };
- static char *LogEnumTypeStr[] = {
- MACROSTR(DiagnosticsLog),
- MACROSTR(SecurityLog)
- };
- static char *LogStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(AcceptedCanceled)
- };
- static char *MeasurandEnumTypeStr[] = {
- MACROSTR(Current.Export),
- MACROSTR(Current.Import),
- MACROSTR(Current.Offered),
- MACROSTR(Energy.Active.Export.Register),
- MACROSTR(Energy.Active.Import.Register),
- MACROSTR(Energy.Reactive.Export.Register),
- MACROSTR(Energy.Reactive.Import.Register),
- MACROSTR(Energy.Active.Export.Interval),
- MACROSTR(Energy.Active.Import.Interval),
- MACROSTR(Energy.Active.Net),
- MACROSTR(Energy.Reactive.Export.Interval),
- MACROSTR(Energy.Reactive.Import.Interval),
- MACROSTR(Energy.Reactive.Net),
- MACROSTR(Energy.Apparent.Net),
- MACROSTR(Energy.Apparent.Import),
- MACROSTR(Energy.Apparent.Export),
- MACROSTR(Frequency),
- MACROSTR(Power.Active.Export),
- MACROSTR(Power.Active.Import),
- MACROSTR(Power.Factor),
- MACROSTR(Power.Offered),
- MACROSTR(Power.Reactive.Export),
- MACROSTR(Power.Reactive.Import),
- MACROSTR(SoC),
- MACROSTR(Voltage)
- };
- static char *MessageFormatEnumTypeStr[] = {
- MACROSTR(ASCII),
- MACROSTR(HTML),
- MACROSTR(URI),
- MACROSTR(UTF8)
- };
- static char *MessagePriorityEnumTypeStr[] = {
- MACROSTR(AlwaysFront),
- MACROSTR(InFront),
- MACROSTR(NormalCycle)
- };
- static char *MessageStateEnumTypeStr[] = {
- MACROSTR(Charging),
- MACROSTR(Faulted),
- MACROSTR(Idle),
- MACROSTR(Unavailable)
- };
- static char *MessageTriggerEnumTypeStr[] = {
- MACROSTR(BootNotification),
- MACROSTR(LogStatusNotification),
- MACROSTR(FirmwareStatusNotification),
- MACROSTR(Heartbeat),
- MACROSTR(MeterValues),
- MACROSTR(SignChargingStationCertificate),
- MACROSTR(SignV2GCertificate),
- MACROSTR(StatusNotification),
- MACROSTR(TransactionEvent),
- MACROSTR(SignCombinedCertificate),
- MACROSTR(PublishFirmwareStatusNotification)
- };
- static char *MonitorEnumTypeStr[] = {
- MACROSTR(UpperThreshold),
- MACROSTR(LowerThreshold),
- MACROSTR(Delta),
- MACROSTR(Periodic),
- MACROSTR(PeriodicClockAligned)
- };
- static char *MonitoringBaseEnumTypeStr[] = {
- MACROSTR(All),
- MACROSTR(FactoryDefault),
- MACROSTR(HardWiredOnly)
- };
- static char *MonitoringCriterionEnumTypeStr[] = {
- MACROSTR(ThresholdMonitoring),
- MACROSTR(DeltaMonitoring),
- MACROSTR(PeriodicMonitoring)
- };
- static char *MutabilityEnumTypeStr[] = {
- MACROSTR(ReadOnly),
- MACROSTR(WriteOnly),
- MACROSTR(ReadWrite)
- };
- static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(Processing)
- };
- static char *OCPPInterfaceEnumTypeStr[] = {
- MACROSTR(Wired0),
- MACROSTR(Wired1),
- MACROSTR(Wired2),
- MACROSTR(Wired3),
- MACROSTR(Wireless0),
- MACROSTR(Wireless1),
- MACROSTR(Wireless2),
- MACROSTR(Wireless3)
- };
- static char *OCPPTransportEnumTypeStr[] = {
- MACROSTR(JSON),
- MACROSTR(SOAP)
- };
- static char *OCPPVersionEnumTypeStr[] = {
- MACROSTR(OCPP12),
- MACROSTR(OCPP15),
- MACROSTR(OCPP16),
- MACROSTR(OCPP20)
- };
- static char *OperationalStatusEnumTypeStr[] = {
- MACROSTR(Inoperative),
- MACROSTR(Operative)
- };
- static char *PhaseEnumTypeStr[] = {
- MACROSTR(L1),
- MACROSTR(L2),
- MACROSTR(L3),
- MACROSTR(N),
- MACROSTR(L1-N),
- MACROSTR(L2-N),
- MACROSTR(L3-N),
- MACROSTR(L1-L2),
- MACROSTR(L2-L3),
- MACROSTR(L3-L1)
- };
- static char *PublishFirmwareStatusEnumTypeStr[] = {
- MACROSTR(Downloaded),
- MACROSTR(DownloadFailed),
- MACROSTR(Downloading),
- MACROSTR(DownloadScheduled),
- MACROSTR(DownloadPaused),
- MACROSTR(PublishFailed),
- MACROSTR(Published),
- MACROSTR(InvalidChecksum),
- MACROSTR(ChecksumVerified)
- };
- static char *ReadingContextEnumTypeStr[] = {
- MACROSTR(Interruption.Begin),
- MACROSTR(Interruption.End),
- MACROSTR(Other),
- MACROSTR(Sample.Clock),
- MACROSTR(Sample.Periodic),
- MACROSTR(Transaction.Begin),
- MACROSTR(Transaction.End),
- MACROSTR(Trigger)
- };
- #if 0
- static char *ReasonEnumTypeStr[] = {
- MACROSTR(DeAuthorized),
- MACROSTR(EmergencyStop),
- MACROSTR(EnergyLimitReached),
- MACROSTR(EVDisconnected),
- MACROSTR(GroundFault),
- MACROSTR(ImmediateReset),
- MACROSTR(Local),
- MACROSTR(LocalOutOfCredit),
- MACROSTR(MasterPass),
- MACROSTR(Other),
- MACROSTR(OvercurrentFault),
- MACROSTR(PowerLoss),
- MACROSTR(PowerQuality),
- MACROSTR(Reboot),
- MACROSTR(Remote),
- MACROSTR(SOCLimitReached),
- MACROSTR(StoppedByEV),
- MACROSTR(TimeLimitReached),
- MACROSTR(TimeLimitReached)
- };
- #endif
- static char *RecurrencyKindEnumTypeStr[] = {
- MACROSTR(Daily),
- MACROSTR(Weekly)
- };
- static char *RegistrationStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Pending),
- MACROSTR(Rejected)
- };
- static char *ReportBaseEnumTypeStr[] = {
- MACROSTR(ConfigurationInventory),
- MACROSTR(FullInventory),
- MACROSTR(SummaryInventory)
- };
- static char *RequestStartStopStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- static char *ReservationUpdateStatusEnumTypeStr[] = {
- MACROSTR(Expired),
- MACROSTR(Removed)
- };
- static char *ReserveNowStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Faulted),
- MACROSTR(Occupied),
- MACROSTR(Rejected),
- MACROSTR(Unavailable)
- };
- static char *ResetEnumTypeStr[] = {
- MACROSTR(Immediate),
- MACROSTR(OnIdle)
- };
- static char *ResetStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(Scheduled)
- };
- static char *SetMonitoringStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(UnknownComponent),
- MACROSTR(UnknownVariable),
- MACROSTR(UnsupportedMonitorType),
- MACROSTR(Rejected),
- MACROSTR(OutOfRange),
- MACROSTR(Duplicate)
- };
- static char *SetNetworkProfileStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(Failed)
- };
- static char *SetVariableStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(InvalidValue),
- MACROSTR(UnknownComponent),
- MACROSTR(UnknownVariable),
- MACROSTR(NotSupportedAttributeType),
- MACROSTR(OutOfRange),
- MACROSTR(RebootRequired)
- };
- static char *TransactionEventEnumTypeStr[] = {
- MACROSTR(Ended),
- MACROSTR(Started),
- MACROSTR(Updated)
- };
- static char *TriggerMessageStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(NotImplemented)
- };
- static char *TriggerReasonEnumTypeStr[] = {
- MACROSTR(Authorized),
- MACROSTR(CablePluggedIn),
- MACROSTR(ChargingRateChanged),
- MACROSTR(ChargingStateChanged),
- MACROSTR(Deauthorized),
- MACROSTR(EnergyLimitReached),
- MACROSTR(EVCommunicationLost),
- MACROSTR(EVConnectTimeout),
- MACROSTR(MeterValueClock),
- MACROSTR(MeterValuePeriodic),
- MACROSTR(TimeLimitReached),
- MACROSTR(Trigger),
- MACROSTR(UnlockCommand),
- MACROSTR(StopAuthorized),
- MACROSTR(EVDeparted),
- MACROSTR(EVDetected),
- MACROSTR(RemoteStop),
- MACROSTR(RemoteStart),
- MACROSTR(AbnormalCondition),
- MACROSTR(SignedDataReceived),
- MACROSTR(ResetCommand)
- };
- static char *UnlockStatusEnumTypeStr[] = {
- MACROSTR(Unlocked),
- MACROSTR(UnlockFailed),
- MACROSTR(OngoingAuthorizedTransaction),
- MACROSTR(UnknownConnector)
- };
- static char *UnpublishFirmwareStatusEnumTypeStr[] = {
- MACROSTR(DownloadOngoing),
- MACROSTR(NoFirmware),
- MACROSTR(Unpublished)
- };
- static char *UpdateEnumTypeStr[] = {
- MACROSTR(Differential),
- MACROSTR(Full)
- };
- static char *UpdateFirmwareStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(AcceptedCanceled),
- MACROSTR(InvalidCertificate),
- MACROSTR(RevokedCertificate)
- };
- static char *UpdateStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Failed),
- MACROSTR(VersionMismatch)
- };
- static char *UploadLogStatusEnumTypeStr[] = {
- MACROSTR(BadMessage),
- MACROSTR(Idle),
- MACROSTR(NotSupportedOperation),
- MACROSTR(PermissionDenied),
- MACROSTR(Uploaded),
- MACROSTR(UploadFailure),
- MACROSTR(Uploading),
- MACROSTR(AcceptedCanceled)
- };
- static char *VPNEnumTypeStr[] = {
- MACROSTR(IKEv2),
- MACROSTR(IPSec),
- MACROSTR(L2TP),
- MACROSTR(PPTP)
- };
- #if 0
- static char *ChargePointErrorCodeEnumTypeStr[] = {
- MACROSTR(ConnectorLockFailure),
- MACROSTR(EVCommunicationError),
- MACROSTR(GroundFailure),
- MACROSTR(HighTemperature),
- MACROSTR(InternalError),
- MACROSTR(LocalListConflict),
- MACROSTR(NoError),
- MACROSTR(OtherError),
- MACROSTR(OverCurrentFailure),
- MACROSTR(OverVoltage),
- MACROSTR(PowerMeterFailure),
- MACROSTR(PowerSwitchFailure),
- MACROSTR(ReaderFailure),
- MACROSTR(ResetFailure),
- MACROSTR(UnderVoltage),
- MACROSTR(WeakSignal)
- };
- #endif
- static char *GetCompositeScheduleStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- static char *RemoteStartStopStatusEnumTypeStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- #if 0
- static char * StopTransactionReasonEnumTypeStr[] = {
- MACROSTR(EmergencyStop),
- MACROSTR(EVDisconnected),
- MACROSTR(HardReset),
- MACROSTR(Local),
- MACROSTR(Other),
- MACROSTR(PowerLoss),
- MACROSTR(Reboot),
- MACROSTR(Remote),
- MACROSTR(SoftReset),
- MACROSTR(UnlockCommand),
- MACROSTR(DeAuthorized)
- };
- #endif
- //ChargePointMaxProfile
- #define ChargingStationMaxProfile_JSON "/Storage/OCPP/ChargingStationMaxProfile_OCPP20.json"
- //TxDefaultProfile
- #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
- struct SysConfigAndInfo *ShmSysConfigAndInfo;
- struct StatusCodeData *ShmStatusCodeData;
- struct PsuData *ShmPsuData ;
- struct OCPP20Data *ShmOCPP20Data;
- pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
- char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
- //===============================
- // Gun Total Numbers
- //===============================
- static ParsingRatedCur modelnameInfo = {0};
- static int gunTotalNumber = 0;
- static uint8_t gunType[4] = {0};
- //===============================
- // Local List Version
- //===============================
- static int localversion=0;
- //===============================
- // Variable Version
- //===============================
- static int variableVersion=11;
- //===============================
- // OCPP sign variable
- //===============================
- static int server_sign = FALSE;
- int server_pending = FALSE;
- static int BootNotificationInterval = 10;
- //===============================
- // OCPP auth variable
- //===============================
- static int authorizeRetryTimes = 0; //number of Retry times
- //===============================
- // OCPP other variables
- //===============================
- static int HeartBeatWaitTime = 10;
- static int FirstHeartBeat = 0;
- static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
- static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
- static char CurrentChargingProfileScheduleStr[30] = {0};
- static int isCancelUploadLog = FALSE;
- pthread_t th_GetLog;
- //========================================
- // OCPP status/previous related variables
- //========================================
- static int GunStatusInterval = 10;
- static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
- static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
- static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
- static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
- static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
- static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
- static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
- static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
- static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
- static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
- static int TransactionMessageAttemptsValue = 0;
- static int TransactionMessageRetryIntervalValue = 0;
- static struct AuthorizationData idTagQuery;
- static float periousPeriodicPowerConsumption[CONNECTOR_QUANTITY] = {0};
- static float periousClockPowerConsumption[CONNECTOR_QUANTITY] = {0};
- //=============================================
- // OCPP HeartBeat Response Not Receive Counts
- //============================================
- static int HeartBeatWithNOResponse = 0;
- static int HeartBeatCountPerHour = 0;
- sqlite3 *db;
- int TransactionMessageAttemptsGet(void);
- int TransactionMessageRetryIntervalGet(void);
- int GetOcppConnStatus(void);
- void SetOcppConnStatus(uint8_t status);
- int setKeyValue(char *key, char *value);
- void OCPP_get_TableAuthlocalAllData(void);
- void processUnkownKey(void);
- struct InterLock
- {
- unsigned char isGetLogGoing:1;
- unsigned char isUpdateFirmwareGoing:1;
- }interLock;
- struct ClientTime
- {
- struct timespec Heartbeat;
- struct timespec StatusNotification[CONNECTOR_QUANTITY];
- struct timespec StartTransaction;
- struct timespec StopTransaction;
- struct timespec MeterValues[CONNECTOR_QUANTITY];
- struct timespec SampledDataTxEnded[CONNECTOR_QUANTITY];
- struct timespec RemoteStartWait;
- struct timespec CharingProfileRefresh[CONNECTOR_QUANTITY];
- }clientTime;
- typedef union
- {
- //Operations Initiated by Central System
- unsigned char CsMsgValue[CONNECTOR_QUANTITY];
- struct
- {
- //CsMsgValue[0]
- unsigned char StatusNotificationReq:1; //bit 0,
- unsigned char StatusNotificationConf:1; //bit 1,
- unsigned char TriggerMeterValueReq:1; //bit 2,
- unsigned char SampleMeterReq:1; //bit 3,
- unsigned char ClockAlignMeterReq:1; //bit 4,
- unsigned char TriggerStatusNotificationReq:1; //bit 5,
- unsigned char isOnCharging:1; //bit 6,
- unsigned char TriggerTransactionEventReq:1; //bit 7
- }bits[CONNECTOR_QUANTITY];
- }CpinitiateMsg;
- CpinitiateMsg cpinitateMsg;
- //=========================================
- // Meter buffer process
- //=========================================
- int meterValueBufferDataQuantity(uint8_t gun_index, ReadingContextEnumType dataType)
- {
- uint32_t result = 0;
- char sqlCmd[8192];
- char zErrMsg[200];
- int rows, cols;
- char **resultData;
- sprintf(sqlCmd, "select count(idx) as dataQuantity from meterValuesBuffer where gun_index='%d' and ReadingContext='%d' order by ReadingContext, idx", gun_index, (dataType==ReadingContextEnumType_Sample_Periodic?0:1));
- if( sqlite3_get_table(db, sqlCmd, &resultData, &rows, &cols, (char **)&zErrMsg) != SQLITE_OK)
- {
- DEBUG_WARN("SQL error: %s\n", zErrMsg);
- }
- else
- {
- if(rows >= 1)
- {
- result = atoi(resultData[1]);
- }
- }
- return result;
- }
- int meterValueBufferClear(uint8_t gun_index)
- {
- int result = PASS;
- char sqlCmd[512];
- char *errMsg = 0;
- sprintf(sqlCmd, "delete from meterValuesBuffer where gun_index=%d", gun_index);
- if (sqlite3_exec(db, sqlCmd, 0, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("SQL error: %s\n",errMsg);
- result = FAIL;
- }
- return result;
- }
- int meterValueBufferInsert(uint8_t gun_index, ReadingContextEnumType dataType, char * transactionId, char *meterValue)
- {
- int result = PASS;
- char sqlCmd[8192];
- char *errMsg = 0;
- sprintf(sqlCmd, "insert into meterValuesBuffer(occurDatetime, gun_index, transactionId, ReadingContext, meterValue) values(CURRENT_TIMESTAMP, '%d', '%s','%d','%s')", gun_index
- , transactionId
- , (dataType==ReadingContextEnumType_Sample_Periodic?0:1)
- , meterValue);
- if (sqlite3_exec(db, sqlCmd, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_WARN( "Insert meter value record error message: %s\n", errMsg);
- }
- return result;
- }
- int meterValueBufferReplace(int bufferIdx, uint8_t gun_index, ReadingContextEnumType dataType, char * transactionId, char *meterValue)
- {
- int result = PASS;
- char sqlCmd[8192];
- char *errMsg = 0;
- sprintf(sqlCmd, "replace into meterValuesBuffer(idx, occurDatetime, gun_index, transactionId, ReadingContext, meterValue) values('%d', CURRENT_TIMESTAMP, '%d', '%s','%d','%s')", bufferIdx
- , gun_index
- , transactionId
- , (dataType==ReadingContextEnumType_Sample_Periodic?0:1)
- , meterValue);
- if (sqlite3_exec(db, sqlCmd, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_WARN( "Insert meter value record error message: %s\n", errMsg);
- }
- return result;
- }
- int meterValueBufferQuery(uint8_t gun_index, json_object *MeterValues)
- {
- int result = PASS;
- char sqlCmd[8192];
- char zErrMsg[200];
- int rows, cols;
- char **resultData;
- sprintf(sqlCmd, "select * from meterValuesBuffer where gun_index='%d' order by ReadingContext, idx", gun_index);
- if( sqlite3_get_table(db, sqlCmd, &resultData, &rows, &cols, (char **)&zErrMsg) != SQLITE_OK)
- {
- DEBUG_WARN("SQL error: %s\n", zErrMsg);
- result = FAIL;
- }
- else
- {
- for(uint32_t idxRow=1;idxRow<=rows;idxRow++)
- {
- json_object *MeterValue = json_tokener_parse(resultData[(idxRow*cols)+5]);
- json_object_array_add(MeterValues, MeterValue);
- }
- }
- return result;
- }
- //=========================================
- // Certificate related routine
- //=========================================
- int certVerify(char *privateKey, char *cert)
- {
- int result = PASS;
- SSL_CTX *ctx = SSL_CTX_new(TLS_method());
- // Load certificate file
- if(SSL_CTX_use_certificate_file(ctx, cert, SSL_FILETYPE_PEM) <= 0)
- {
- DEBUG_ERROR("Load certificate error!\n");
- result = FAIL;
- }
- // Load private key file
- if(SSL_CTX_use_PrivateKey_file(ctx, privateKey, SSL_FILETYPE_PEM) <= 0)
- {
- DEBUG_ERROR("Load private key error!\n");
- result = FAIL;
- }
- if(!SSL_CTX_check_private_key(ctx))
- {
- result = FAIL;
- }
- SSL_CTX_free(ctx);
- return result;
- }
- //==========================================
- // Parse certificate content
- //==========================================
- int parseCertInfo(char *certPath, int parseType, char *data)
- {
- int result = FAIL;
- int count = 0;
- int showupLine = 0;
- memset(data, 0, ARRAY_SIZE(data));
- if(access(certPath,F_OK) != -1)
- {
- char temp[512] = {0};
- char capturedData[256] = {0};
- char hashType[10] = "SHA256";
- FILE *fp;
- // Need to get hash type first
- sprintf(temp ,"openssl x509 -noout -text -in %s", certPath);
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if(strstr(temp, "Signature Algorithm:") != NULL)
- {
- result = PASS;
- if(strstr(temp, "sha256") != NULL || strstr(temp, "SHA256") != NULL)
- sprintf((char*)hashType, "SHA256");
- else if(strstr(temp, "sha384") != NULL || strstr(temp, "SHA384") != NULL)
- sprintf((char*)hashType, "SHA384");
- else if(strstr(temp, "sha512") != NULL || strstr(temp, "SHA512") != NULL)
- sprintf((char*)hashType, "SHA512");
- else
- {
- DEBUG_INFO("Error: hashAlgorithm is illegal or missing.\n");
- result = FAIL;
- }
- break;
- }
- }
- }
- switch(parseType)
- {
- case CERT_PARSE_HashAlgorithm:
- sprintf((char*)data, hashType);
- DEBUG_INFO("hashAlgorithm: %s\n", hashType);
- break;
- case CERT_PARSE_SerialNumber:
- sprintf(temp ,"openssl x509 -noout -serial -in %s", certPath);
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if(strstr(temp, "serial=") != NULL)
- {
- sscanf(temp, "%*[^=]=%s", capturedData);
- result = PASS;
- break;
- }
- }
- DEBUG_INFO("serialNumber: %s\n", capturedData);
- sprintf((char*)data, capturedData);
- }
- break;
- case CERT_PARSE_IssuerNameHash:
- sprintf(temp ,"openssl asn1parse -i < %s", certPath);
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if(strstr(temp, "SEQUENCE") != NULL)
- {
- count++;
- if(count==4)
- {
- sscanf(temp, "%[^:]", capturedData);
- showupLine = atoi(capturedData);
- break;
- }
- }
- }
- }
- if(showupLine > 0)
- {
- sprintf(temp ,"openssl asn1parse -i < %s -strparse %d -out /Storage/OCPP/IssuerNameHash", certPath, showupLine);
- system(temp);
- }
- else
- {
- break;
- }
- if(access("/Storage/OCPP/IssuerNameHash",F_OK) != -1)
- {
- sprintf(temp ,"openssl %s < /Storage/OCPP/IssuerNameHash", (char*)hashType);
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if(strstr(temp, "(stdin)=") != NULL)
- {
- sscanf(temp, "%*[^=]=%s", capturedData);
- result = PASS;
- break;
- }
- }
- stringtrimspace(capturedData);
- DEBUG_INFO("issuerNameHash: %s\n", capturedData);
- sprintf((char*)data, capturedData);
- }
- }
- break;
- case CERT_PARSE_IssuerKeyHash:
- sprintf(temp ,"openssl asn1parse -i < %s", certPath);
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if(strstr(temp, "BIT STRING") != NULL)
- {
- sscanf(temp, "%[^:]", capturedData);
- showupLine = atoi(capturedData);
- break;
- }
- }
- }
- if(showupLine > 0)
- {
- sprintf(temp ,"openssl asn1parse -i < %s -strparse %d -out /Storage/OCPP/IssuerKeyHash", certPath, showupLine);
- system(temp);
- }
- else
- {
- break;
- }
- if(access("/Storage/OCPP/IssuerKeyHash",F_OK) != -1)
- {
- sprintf(temp ,"openssl %s < /Storage/OCPP/IssuerKeyHash", (char*)hashType);
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if(strstr(temp, "(stdin)=") != NULL)
- {
- sscanf(temp, "%*[^=]=%s", capturedData);
- result = PASS;
- break;
- }
- }
- stringtrimspace(capturedData);
- DEBUG_INFO("issuerNameHash: %s\n", capturedData);
- sprintf((char*)data, capturedData);
- }
- }
- break;
- case CERT_PARSE_OcspUrl:
- //sprintf(temp ,"openssl x509 -noout -ocsp_uri -in %s", certPath);
- sprintf(temp ,"openssl crl2pkcs7 -nocrl -certfile %s | openssl pkcs7 -print_certs -text -noout", certPath);
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if(strstr(temp, "OCSP - URI:") != NULL)
- {
- //strcpy((char*)data, temp);
- sscanf(temp, "%*[^:]:%s", capturedData);
- sprintf((char*)data, capturedData);
- DEBUG_INFO("OCSP_URI: %s\n", data);
- result = PASS;
- break;
- }
- }
- }
- break;
- default:
- DEBUG_INFO("Parse type is invalid.\n");
- break;
- }
- pclose(fp);
- }
- return result;
- }
- //=========================================
- // Get connector charging info
- //=========================================
- struct ChargingInfoData *getTargetChargingInfoData(uint8_t gun_index)
- {
- struct ChargingInfoData *targetChargingInfoData;
- uint8_t tempIndex;
- if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
- {
- targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
- break;
- }
- }
- }
- else if(gunType[gun_index] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
- break;
- }
- }
- }
- else if(gunType[gun_index] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
- break;
- }
- }
- }
- else if(gunType[gun_index] == GUN_TYPE_DO)
- {
- tempIndex = gun_index;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData;
- break;
- }
- }
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.AcChargingData[index];
- break;
- }
- }
- }
- return targetChargingInfoData;
- }
- //=========================================
- // Save configuration
- //=========================================
- int runShellCmd(const char*cmd)
- {
- int result = FAIL;
- char buf[256];
- FILE *fp;
- fp = popen(cmd, "r");
- if(fp != NULL)
- {
- while(fgets(buf, sizeof(buf), fp) != NULL)
- {
- DEBUG_INFO("%s\n", buf);
- }
- result = PASS;
- }
- pclose(fp);
- return result;
- }
- int StoreUsrConfigData(struct SysConfigData *UsrData)
- {
- int result = PASS;
- int fd,wrd;
- unsigned int i,Chk;
- unsigned char *ptr, *BufTmp;
- int MtdBlockSize = 0x300000;
- Chk=0;
- ptr=(unsigned char *)UsrData;
- if((BufTmp=malloc(MtdBlockSize))!=NULL)
- {
- memset(BufTmp,0,MtdBlockSize);
- memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
- for(i=ARRAY_SIZE(UsrData->CsuBootLoadFwRev);i<MtdBlockSize-4;i++)
- Chk+=*(BufTmp+i);
- memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
- // Output configuration to file.
- fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
- if (fd < 0)
- {
- DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
- free(BufTmp);
- return 0;
- }
- wrd=write(fd, BufTmp, MtdBlockSize);
- close(fd);
- if(wrd<MtdBlockSize)
- {
- DEBUG_ERROR("write /mnt/EvseConfig.bin NG\n");
- free(BufTmp);
- return 0;
- }
- DEBUG_INFO("EvseConfig write to file in /mnt OK.\n");
- DEBUG_INFO("Erase /dev/mtd10.\n");
- runShellCmd("flash_erase /dev/mtd10 0 0");
- DEBUG_INFO("Write /dev/mtd10.\n");
- runShellCmd("nandwrite -p /dev/mtd10 /mnt/EvseConfig.bin");
- DEBUG_INFO("Erase /dev/mtd11.\n");
- runShellCmd("flash_erase /dev/mtd11 0 0");
- DEBUG_INFO("Write /dev/mtd11.\n");
- runShellCmd("nandwrite -p /dev/mtd11 /mnt/EvseConfig.bin");
- system("rm -f /mnt/EvseConfig.bin");
- DEBUG_INFO("EvseConfig write to flash OK\n");
- }
- else
- {
- DEBUG_ERROR("alloc BlockSize NG\r\n");
- result = FAIL;
- }
- if(BufTmp!=NULL)
- free(BufTmp);
- return result;
- }
- //=========================================
- // Date time related function
- //=========================================
- void getNowDatetime(uint8_t *data)
- {
- time_t t = time(NULL);
- struct tm tm = *localtime(&t);
- 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);
- }
- //=========================================
- // Sqlite3 related function
- //=========================================
- int DB_Initial()
- {
- int result = PASS;
- char* errMsg = NULL;
- char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
- "idToken text UNIQUE,"
- "type text,"
- "status text,"
- "cacheExpiryDateTime text,"
- "chargingPriority integer,"
- "language1 text,"
- "evseId text,"
- "language2 text,"
- "groupIdToken_idToken text,"
- "groupIdToken_type text,"
- "personalMessage text);";
- char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
- "idToken text UNIQUE,"
- "type text,"
- "status text,"
- "cacheExpiryDateTime text,"
- "chargingPriority integer,"
- "language1 text,"
- "evseId text,"
- "language2 text,"
- "groupIdToken_idToken text,"
- "groupIdToken_type text,"
- "personalMessage text,"
- "version text);";
- char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
- "componentName text NOT NULL ,"
- "componentInstance text, "
- "variableName text NOT NULL, "
- "variableInstance text, "
- "variableCharacteristicsDataType integer, "
- "variableCharacteristicsUnit text, "
- "variableCharacteristicsMaxLimit real,"
- "variableAttributesType text, "
- "variableAttributesTypeMutability text, "
- "variableAttributesTypeValue text, "
- "variableCharacteristicsMinLimit real,"
- "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
- char *sqlVariableMonitoring = "create table if not exists ocpp20_variable_monitoring (idx integer primary key,"
- "id integer ,"
- "txn text, "
- "value text , "
- "type text, "
- "severity integer, "
- "component_name text, "
- "component_instance text,"
- "component_evse_id integer, "
- "component_evse_connectorId integer, "
- "variable_name text, "
- "variable_instance text);";
- char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
- "type text);";
- char *sqlSecurityEventType = "create table if not exists ocpp20_securityevent_type (idx integer primary key,"
- "type text);";
- char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
- "slot integer UNIQUE, connectionData text);";
- char *sqlTransaction = "create table if not exists ocpp20_transaction_record (idx integer primary key,"
- "occurDatetime text,"
- "message_type text,"
- "message_content text)";
- char *sqlMeterValueBuffer = "create table if not exists meterValuesBuffer( idx integer primary key,"
- "occurDatetime text,"
- "gun_index text,"
- "transactionId text,"
- "ReadingContext text,"
- "meterValue text);";
- //sqlite3_config(SQLITE_CONFIG_URI, 1);
- if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
- {
- result = FAIL;
- DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
- sqlite3_close(db);
- }
- else
- {
- DEBUG_INFO( "OCPP local database open successfully.\n");
- if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
- }
- else
- {
- DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
- }
- if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
- }
- else
- {
- DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
- }
- if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
- }
- else
- {
- DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
- }
- if (sqlite3_exec(db, sqlVariableMonitoring, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_ERROR( "Create OCPP 2.0 variable monitoring table error message: %s\n", errMsg);
- }
- else
- {
- DEBUG_INFO( "Create OCPP 2.0 variable monitoring table successfully\n");
- }
- if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
- }
- else
- {
- DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
- }
- if (sqlite3_exec(db, sqlSecurityEventType, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_ERROR( "Create OCPP 2.0 securityevent_type table error message: %s\n", errMsg);
- }
- else
- {
- DEBUG_INFO( "Create OCPP 2.0 securityevent_type table successfully\n");
- }
- if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
- }
- else
- {
- DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
- }
- if (sqlite3_exec(db, sqlTransaction, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_ERROR( "Create OCPP 2.0 ocpp20_transaction_record table error message: %s\n", errMsg);
- }
- else
- {
- DEBUG_INFO( "Create OCPP 2.0 ocpp20_transaction_record table successfully\n");
- }
- // Create meter values buffer table
- if(sqlite3_exec(db, sqlMeterValueBuffer, 0, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO( "Create Table meterValuesBuffer error %s\n",errMsg);
- return 0;
- }
- else
- {
- DEBUG_INFO( "Opened meterValuesBuffer table successfully\n");
- }
- //sqlite3_close(db);
- }
- return result;
- }
- int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
- {
- localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
- return 0;
- }
- void DB_getListVerion()
- {
- char sql[256];
- char* errMsg = NULL;
- strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
- /* Execute SQL statement */
- if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s", errMsg);
- }
- }
- int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
- {
- sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
- sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
- sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
- sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
- idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
- sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
- sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
- sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
- sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
- return 0;
- }
- void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
- {
- char sql[256];
- char* errMsg = NULL;
- memset(&idTagQuery, 0, sizeof(idTagQuery));
- //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
- if(isQueryFromCache)
- sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
- else
- sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
- /* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s", errMsg);
- }
- }
- int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
- {
- for (int i = 0; i < columnCount; i++)
- {
- DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
- }
- return 0;
- }
- void DB_get_TableAuthlocalAllData(void)
- {
- char sql[256];
- char* errMsg = NULL;
- sprintf(sql,"select * from ocpp20_auth_local;");
- /* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("SQL error: %s", errMsg);
- }
- }
- int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
- {
- for(int i = 0; i<columnCount; i++)
- {
- // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
- }
- return 0;
- }
- int DB_addLocalList(int listVersion, struct AuthorizationData *data)
- {
- int result = PASS;
- char sql[512];
- char* errMsg = NULL;
- 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;",
- data->idToken.idToken,
- data->idToken.type,
- data->idTokenInfo.status,
- data->idTokenInfo.cacheExpiryDateTime,
- data->idTokenInfo.chargingPriority,
- data->idTokenInfo.language1,
- data->idTokenInfo.language2,
- data->idTokenInfo.groupIdToken.idToken,
- data->idTokenInfo.groupIdToken.type,
- listVersion);
- //* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- result = FAIL;
- }
- else
- {
- memset(sql, 0, ARRAY_SIZE(sql));
- sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
- if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- result = FAIL;
- }
- }
- return result;
- }
- int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
- {
- int result = PASS;
- char sql[512];
- char* errMsg = NULL;
- 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;",
- idToken->idToken,
- idToken->type,
- idTokenInfo->status,
- idTokenInfo->cacheExpiryDateTime,
- idTokenInfo->chargingPriority,
- idTokenInfo->language1,
- idTokenInfo->language2,
- idTokenInfo->groupIdToken.idToken,
- idTokenInfo->groupIdToken.type);
- //* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- result = FAIL;
- }
- return result;
- }
- int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
- {
- // localversion = argv[5] ? atoi(columnValue[5]) : 0;
- // printf("localversion=%d\n", localversion);
- return 0;
- }
- void DB_deleteIdTag(char idTag[])
- {
- char sql[512];
- char* errMsg = NULL;
- sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
- //* Execute SQL statement */
- if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s", errMsg);
- }
- }
- int DB_cleanLocalList()
- {
- int result = PASS;
- char * sqlcleanLocalList = "delete from ocpp20_auth_local";
- char *errMsg = 0;
- if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("%s\n", errMsg);
- result = FAIL;
- }
- return result;
- }
- int DB_cleanLocalCache()
- {
- int result = PASS;
- char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
- char *errMsg = 0;
- if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("%s\n", errMsg);
- result = FAIL;
- }
- return result;
- }
- int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
- {
- sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
- return 0;
- }
- void DB_getBooType()
- {
- char sql[256];
- char* errMsg = NULL;
- sprintf(sql,"select * from ocpp20_boot_type;");
- /* Execute SQL statement */
- if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- }
- }
- int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
- {
- for(int i = 0; i<columnCount; i++)
- {
- // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
- }
- return 0;
- }
- int DB_updateBootType(BootReasonEnumType reason)
- {
- int result = PASS;
- char sql[512];
- char* errMsg = NULL;
- sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
- //* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- result = FAIL;
- }
- return result;
- }
- int SecurityEventTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
- {
- sprintf((char*)ShmOCPP20Data->SecurityEventNotification.type,"%s", columnValue[1] ? columnValue[1] : SecurityEventEnumTypeStr[SecurityEventEnumType_ResetOrReboot]);
- return 0;
- }
- void DB_getSecurityEventType()
- {
- char sql[256];
- char* errMsg = NULL;
- sprintf(sql,"select * from ocpp20_securityevent_type;");
- /* Execute SQL statement */
- if(sqlite3_exec(db, sql, SecurityEventTypecallback, 0, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- }
- }
- int DB_cbUpdateSecurityEventType(void *para, int columnCount, char **columnValue, char **columnName)
- {
- for(int i = 0; i<columnCount; i++)
- {
- // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
- }
- return 0;
- }
- int DB_updateSecurityEventType(SecurityEventEnumType reason)
- {
- int result = PASS;
- char sql[512];
- char* errMsg = NULL;
- sprintf(sql,"insert or replace into ocpp20_securityevent_type (idx, type) VALUES(1, '%s');", SecurityEventEnumTypeStr[reason]);
- //* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbUpdateSecurityEventType, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- result = FAIL;
- }
- return result;
- }
- int DB_variableClear()
- {
- int result = PASS;
- char * sqlclearVariable = "delete from ocpp20_variable";
- char *errMsg = 0;
- if (sqlite3_exec(db, sqlclearVariable, 0, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("%s\n", errMsg);
- result = FAIL;
- }
- return result;
- }
- int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
- {
- for(int i = 0; i<columnCount; i++)
- {
- // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
- }
- return 0;
- }
- int DB_variableSaveToDb(struct ReportDataType *variable)
- {
- int result = FAIL;
- char sql[4096];
- char* errMsg = NULL;
- sprintf(sql,"insert or replace into ocpp20_variable (componentName, componentInstance, variableName, variableInstance, variableCharacteristicsDataType, variableCharacteristicsUnit, variableCharacteristicsMaxLimit, variableAttributesType, variableAttributesTypeMutability, variableAttributesTypeValue, variableCharacteristicsMinLimit) VALUES('%s', '%s', '%s', '%s', '%s', '%s', %f, '%s', '%s', '%s', '%f'); SELECT * from ocpp20_variable;",
- variable->component.name,
- variable->component.instance,
- variable->variable.name,
- variable->variable.instance,
- variable->variableCharacteristics.dataType,
- variable->variableCharacteristics.unit,
- variable->variableCharacteristics.maxLimit,
- variable->variableAttribute[0].type,
- variable->variableAttribute[0].mutability,
- variable->variableAttribute[0].value,
- variable->variableCharacteristics.minLimit);
- //* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- result = FAIL;
- }
- return result;
- }
- int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
- {
- memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
- if(atoi(columnValue[0]) == 0)
- {
- DB_updateBootType(BootReasonEnumType_PowerUp);
- // Create variable table content
- /* AlignedDataCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
- ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.maxLimit = 20;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- 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");
- else
- 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");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 5;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
- ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
- "Energy.Active.Import.Register,"
- "Energy.Active.Import.Interval,"
- "Power.Active.Import,"
- "Voltage,"
- "SoC");
- else
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
- "Energy.Active.Import.Register,"
- "Energy.Active.Import.Interval,"
- "Power.Active.Import,"
- "Voltage");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
- /* AuthCtrlrVariable Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE?"true":"false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
- /* AuthCacheCtrlr Variable Required item*/
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
- /* ClockCtrlr Variable Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
- /* ChargingStation Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variable.name, "SystemUptimeSec");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].value, "0");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variable.name, "FreeVend");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].value, (ShmSysConfigAndInfo->SysConfig.AuthorisationMode?"true":"false"));
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variable.name, "FreeVendIdtag");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].value, "FreeVendIdtag");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variable.name, "OffLineMaxChargingPower");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variableAttribute[0].value, "0");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower]);
- /* Connector Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
- /* CustomizationCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
- /* DeviceDataCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
- ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
- ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
- /* DisplayMessageCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.maxLimit = 1;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "1");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
- /* EVSE Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
- /* LocalAuthListCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.maxLimit = 5000;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "500");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "20480");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "100000");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
- /* MonitoringCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
- /* OCPPCommCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
- ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.minLimit = 10;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "30");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
- ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.minLimit = 10;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variable.name, "VariableVersion");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].value, "%d", variableVersion);
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variable.name, "StatusNotificationPeriodically");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variable.name, "StatusNotificationInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.unit, "Seconds");
- ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.minLimit = 10;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].value, "120");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].variable.name, "CharingProfileRefreshInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].variableCharacteristics.unit, "Seconds");
- ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].variableCharacteristics.minLimit = 5;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].variableAttribute[0].value, "30");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_RfidEndianType].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_RfidEndianType].variable.name, "RfidEndianType");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_RfidEndianType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_RfidEndianType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_RfidEndianType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_RfidEndianType].variableAttribute[0].value, ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian==1?"big":"little");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_RfidEndianType]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].variable.name, "AuthorizeTimeout");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].variableCharacteristics.unit, "Seconds");
- ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].variableCharacteristics.minLimit = 10;
- ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].variableCharacteristics.maxLimit = 300;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].variableAttribute[0].value, "15");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_Enable15118].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_Enable15118].variable.name, "Enable15118");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_Enable15118].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_Enable15118].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_Enable15118].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_Enable15118].variableAttribute[0].value, ShmSysConfigAndInfo->SysConfig.isEnable15118==1?"true":"false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_Enable15118]);
- /* ReservationCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
- /* SampledDataCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
- ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
- "Energy.Active.Import.Register,"
- "Energy.Active.Import.Interval,"
- "Power.Active.Import,"
- "Voltage,"
- "SoC");
- else
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
- "Energy.Active.Import.Register,"
- "Energy.Active.Import.Interval,"
- "Power.Active.Import,"
- "Voltage");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
- ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.maxLimit = 10;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
- ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.maxLimit = 10;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- 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");
- else
- 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");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 3;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
- /* SecurityCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, "%s", (strlen((char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword)>0?(char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword:"00000000"));
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.maxLimit = 1;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.maxLimit = 10000;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].value, "10000");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize]);
- /* SmartChargingCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "3");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.maxLimit = 10;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "10");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
- /* TariffCostCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
- ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
- /* TxCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "true");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "0");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "false");
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
- }
- else
- {
- // Variable name init
- /* AlignedDataCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
- /* AuthCtrlrVariable Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
- /* AuthCacheCtrlr Variable Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
- /* ClockCtrlr Variable Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
- /* ChargingStation Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variable.name, "SystemUptimeSec");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variable.name, "FreeVend");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variable.name, "FreeVendIdtag");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].component.name, "ChargingStation");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variable.name, "OffLineMaxChargingPower");
- /* Connector Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
- /* CustomizationCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
- /* DeviceDataCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
- /* DisplayMessageCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
- /* EVSE Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
- /* LocalAuthListCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
- /* MonitoringCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
- /* OCPPCommCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variable.name, "VariableVersion");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variable.name, "StatusNotificationPeriodically");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variable.name, "StatusNotificationInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].variable.name, "CharingProfileRefreshInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_RfidEndianType].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_RfidEndianType].variable.name, "RfidEndianType");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_AuthorizeTimeout].variable.name, "AuthorizeTimeout");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_Enable15118].component.name, "OCPPCommCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_Enable15118].variable.name, "Enable15118");
- /* ReservationCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
- /* SampledDataCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
- /* SecurityCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
- /* SmartChargingCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
- /* TariffCostCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
- /* TxCtrlr Required item */
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
- }
- return 0;
- }
- void DB_variableIsCreate()
- {
- char sql[512];
- char* errMsg = NULL;
- sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
- /* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- }
- }
- int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
- {
- for(int idx=0;idx<CtrlrVariable_CNT;idx++)
- {
- if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) == 0) &&
- (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) == 0) &&
- (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) == 0) &&
- (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) == 0))
- {
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
- ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
- ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.minLimit = strlen(columnValue[11])>=0?atoi(columnValue[11]):0;
- }
- }
- return 0;
- }
- void DB_variableLoadFromDb()
- {
- char sql[512];
- char* errMsg = NULL;
- sprintf(sql,"select * from ocpp20_variable order by idx;");
- /* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- }
- }
- //==============================
- // Variable Monitoring
- //==============================
- int variableMonitoringQuantity()
- {
- uint32_t result = 0;
- char sqlCmd[8192];
- char zErrMsg[200];
- int rows, cols;
- char **resultData;
- sprintf(sqlCmd, "select count(idx) as dataQuantity from ocpp20_variable_monitoring");
- if( sqlite3_get_table(db, sqlCmd, &resultData, &rows, &cols, (char **)&zErrMsg) != SQLITE_OK)
- {
- DEBUG_WARN("SQL error: %s\n", zErrMsg);
- }
- else
- {
- if(rows >= 1)
- {
- result = atoi(resultData[1]);
- }
- }
- return result;
- }
- int DB_variableMonitoringClear()
- {
- int result = PASS;
- char * sqlclearVariableMonitoring = "delete from ocpp20_variable_monitoring";
- char *errMsg = 0;
- if (sqlite3_exec(db, sqlclearVariableMonitoring, 0, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("%s\n", errMsg);
- result = FAIL;
- }
- return result;
- }
- int VariableMonitoringReplace(uint8_t idx, struct SetMonitoringDataType *variableMonitoring)
- {
- int result = PASS;
- char sql[1024];
- char *errMsg = 0;
- sprintf(sql,"replace into ocpp20_variable_monitoring "
- "(idx, id, txn, value, type, severity, component_name, component_instance, component_evse_id, component_evse_connectorId, variable_name, variable_instance) "
- "VALUES('%d', '%d', '%d', '%.2f', '%s', '%d', '%s', '%s', '%d', '%d', '%s', '%s'); SELECT * from ocpp20_variable_monitoring;",
- idx,
- variableMonitoring->id,
- variableMonitoring->transaction,
- variableMonitoring->value,
- variableMonitoring->type,
- variableMonitoring->severity,
- variableMonitoring->component.name,
- variableMonitoring->component.instance,
- variableMonitoring->component.evse.id,
- variableMonitoring->component.evse.connectorId,
- variableMonitoring->variable.name,
- variableMonitoring->variable.instance
- );
- if (sqlite3_exec(db, sql, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_WARN( "Insert meter value record error message: %s\n", errMsg);
- }
- return result;
- }
- int DB_cbVariableMonitoringSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
- {
- for(int i = 0; i<columnCount; i++)
- {
- // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
- }
- return 0;
- }
- int DB_variableMonitoringSaveToDb(struct SetMonitoringDataType *variableMonitoring)
- {
- int result = FAIL;
- char sql[1024];
- char* errMsg = NULL;
- sprintf(sql,"insert or replace into ocpp20_variable_monitoring "
- "(id, txn, value, type, severity, component_name, component_instance, component_evse_id, component_evse_connectorId, variable_name, variable_instance) "
- "VALUES('%d', '%d', '%.2f', '%s', '%d', '%s', '%s', '%d', '%d', '%s', '%s'); SELECT * from ocpp20_variable_monitoring;",
- variableMonitoring->id,
- variableMonitoring->transaction,
- variableMonitoring->value,
- variableMonitoring->type,
- variableMonitoring->severity,
- variableMonitoring->component.name,
- variableMonitoring->component.instance,
- variableMonitoring->component.evse.id,
- variableMonitoring->component.evse.connectorId,
- variableMonitoring->variable.name,
- variableMonitoring->variable.instance
- );
- //* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbVariableMonitoringSaveToDb, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- result = FAIL;
- }
- return result;
- }
- int DB_cbVariableMonitoringLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
- {
- for(int idx=0;idx<10;idx++)
- {
- if((strlen((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].component.name) == 0) &&
- (strlen((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].variable.name) == 0))
- {
- ShmOCPP20Data->MonitoringComponentVariable[idx].id = strlen(columnValue[1])>=0?atoi(columnValue[1]):-1;
- ShmOCPP20Data->MonitoringComponentVariable[idx].transaction = strlen(columnValue[2])>=0?atoi(columnValue[2]):0;
- ShmOCPP20Data->MonitoringComponentVariable[idx].value = strlen(columnValue[3])>=0?atof(columnValue[3]):0;
- sprintf((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type, "%s", columnValue[4]);
- ShmOCPP20Data->MonitoringComponentVariable[idx].severity = strlen(columnValue[5])>0?atoi(columnValue[5]):9;
- sprintf((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].component.name, "%s", columnValue[6]);
- sprintf((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].component.instance, "%s", columnValue[7]);
- ShmOCPP20Data->MonitoringComponentVariable[idx].component.evse.id = strlen(columnValue[8])>0?atoi(columnValue[8]):-1;
- ShmOCPP20Data->MonitoringComponentVariable[idx].component.evse.connectorId = strlen(columnValue[9])>0?atoi(columnValue[9]):-1;
- sprintf((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].variable.name, "%s", columnValue[10]);
- sprintf((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].variable.instance, "%s", columnValue[11]);
- break;
- }
- }
- return 0;
- }
- void DB_variableMonitoringLoadFromDb()
- {
- char sql[512];
- char* errMsg = NULL;
- sprintf(sql,"select * from ocpp20_variable_monitoring order by idx;");
- /* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbVariableMonitoringLoadFromDb, 0, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- }
- }
- int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
- {
- memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
- if(columnCount > 0)
- {
- for(int idx=0;idx<columnCount;idx++)
- {
- json_object *SetNetworkProfile;
- SetNetworkProfile = json_tokener_parse(columnValue[2]);
- if(!is_error(SetNetworkProfile))
- {
- // Required data
- if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
- if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
- if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
- if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
- ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
- if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
- if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
- {
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
- sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
- }
- if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
- {
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
- {
- memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
- }
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
- {
- memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
- }
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
- {
- memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
- }
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
- ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
- ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
- sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
- }
- }
- json_object_put(SetNetworkProfile);
- ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
- }
- }
- return 0;
- }
- void DB_getNetworkProfileFromDb()
- {
- char sql[512];
- char* errMsg = NULL;
- sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
- /* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- }
- }
- int DB_addNetworkProfile(int slot, char *data)
- {
- int result = PASS;
- char sql[512];
- char* errMsg = NULL;
- sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
- slot,
- data);
- //* Execute SQL statement */
- if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("SQL error: %s\n", errMsg);
- result = FAIL;
- }
- return result;
- }
- int DB_deleteNetworkProfile(int slot)
- {
- int result = PASS;
- char sql[512];
- char* errMsg = NULL;
- sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
- //* Execute SQL statement */
- if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
- {
- DEBUG_INFO("SQL error: %s", errMsg);
- result = FAIL;
- }
- return result;
- }
- int isNumber(uint8_t *string, uint8_t isFloat)
- {
- int result = NO;
- int cntDecimal = 0;
- float i;
- for(int idx=0; idx<strlen((char*)string); idx++)
- {
- if((isdigit(string[idx])==0) && (string[idx] != '.'))
- {
- return result;
- }
- else if(string[idx] == '.')
- cntDecimal++;
- if(cntDecimal>1)
- return result;
- }
- if((isFloat==FALSE) && (strstr((char*)string, ".") != NULL))
- {
- //DEBUG_INFO("%s is not pure integer!!\n", string);
- }
- else if((isFloat==TRUE) && (strstr((char*)string, ".") == NULL))
- {
- //DEBUG_INFO("%s is not float format!!\n", string);
- }
- else if(sscanf((char*)string, "%f", &i) != 0)
- {
- result = YES;
- }
- return result;
- }
- int isMatchTimeFormat(uint8_t *time)
- {
- int result = NO;
- struct ParsingResult
- {
- int result;
- int scanedElement;
- int year;
- int month;
- int mday;
- int hour;
- int min;
- int sec;
- int tz_hour;
- int tz_min;
- float minSec;
- }parsingResult;
- memset(&parsingResult, 0x00, sizeof(struct ParsingResult));
- if(strstr((char*)time, ".") != NULL)
- {
- // Original data with mini second
- if(strstr((char*)time, "Z") != NULL)
- {
- // Original data with Z
- parsingResult.scanedElement = sscanf((char*)time, "%d-%d-%dT%d:%d:%d.%fZ",
- &parsingResult.year,
- &parsingResult.month,
- &parsingResult.mday,
- &parsingResult.hour,
- &parsingResult.min,
- &parsingResult.sec,
- &parsingResult.minSec);
- }
- else
- {
- // Original data without Z
- parsingResult.scanedElement = sscanf((char*)time, "%d-%d-%dT%d:%d:%d.%f%d:%d",
- &parsingResult.year,
- &parsingResult.month,
- &parsingResult.mday,
- &parsingResult.hour,
- &parsingResult.min,
- &parsingResult.sec,
- &parsingResult.minSec,
- &parsingResult.tz_hour,
- &parsingResult.tz_min);
- }
- }
- else
- {
- // Original data without mini second
- if(strstr((char*)time, "Z") != NULL)
- {
- // Original data with Z
- parsingResult.scanedElement = sscanf((char*)time, "%d-%d-%dT%d:%d:%dZ",
- &parsingResult.year,
- &parsingResult.month,
- &parsingResult.mday,
- &parsingResult.hour,
- &parsingResult.min,
- &parsingResult.sec);
- }
- else
- {
- // Original data without Z
- parsingResult.scanedElement = sscanf((char*)time, "%d-%d-%dT%d:%d:%d%d:%d",
- &parsingResult.year,
- &parsingResult.month,
- &parsingResult.mday,
- &parsingResult.hour,
- &parsingResult.min,
- &parsingResult.sec,
- &parsingResult.tz_hour,
- &parsingResult.tz_min);
- }
- }
- if(parsingResult.scanedElement >= 6)
- {
- result = YES;
- }
- return result;
- }
- int getCurrentYear()
- {
- int result = 0;
- time_t CurrentTime;
- struct tm *tm;
- CurrentTime = time(NULL);
- tm=localtime(&CurrentTime);
- result = (tm->tm_year + 1900);
- return result;
- }
- int OCPP_insert_transaction_msg(uint8_t isStartTransaction, char *transactionMsg)
- {
- int result = PASS;
- char* errMsg = NULL;
- char sqlStr[WEBSOCKET_BUFFER_SIZE];
- sprintf(sqlStr, "insert into ocpp20_transaction_record(occurDatetime, message_type, message_content) values(CURRENT_TIMESTAMP, '%s', '%s');", (isStartTransaction?"startTransaction":"stopTransaction"), transactionMsg);
- if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_WARN( "Insert local transaction record error message: %s\n", errMsg);
- }
- 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));
- if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
- {
- result = FAIL;
- DEBUG_WARN( "delete local transaction record error message: %s\n", errMsg);
- }
- return result;
- }
- //==========================================
- // Check time passed since today
- //==========================================
- long long DiffTimebWithNow(struct timeb ST)
- {
- //return milli-second
- struct timeb ET;
- long long StartTime,StopTime;
- ftime(&ET);
- StartTime=(long long)ST.time;
- StopTime=(long long)ET.time;
- return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
- }
- int getTimePassSinceToday(uint8_t gun_index)
- {
- int result = -1;
- static time_t lastTime[4];
- time_t t;
- struct tm *tmStartToday;
- struct timeb tbStartToday;
- t=time(NULL);
- if(difftime(t, lastTime[gun_index])>0)
- {
- tmStartToday=localtime(&t);
- tmStartToday->tm_hour = 0;
- tmStartToday->tm_min = 0;
- tmStartToday->tm_sec = 0;
- tbStartToday.time = mktime(tmStartToday);
- tbStartToday.millitm = 0;
- result = DiffTimebWithNow(tbStartToday)/1000;
- lastTime[gun_index] = t;
- }
- return result;
- }
- int syncDateTimeRTC(uint8_t *data)
- {
- struct ParsingResult
- {
- int result;
- int scanedElement;
- int year;
- int month;
- int mday;
- int hour;
- int min;
- int sec;
- int tz_hour;
- int tz_min;
- float minSec;
- }result;
- struct tm tmOrg;
- struct tm *tmTarget;
- struct timeb tbTarget;
- char buf[128];
- memset(&result, 0x00, sizeof(struct ParsingResult));
- result.result = PASS;
- if(strstr((char*)data, ".") != NULL)
- {
- // Original data with mini second
- if(strstr((char*)data, "Z") != NULL)
- {
- // Original data with Z
- result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%fZ",
- &result.year,
- &result.month,
- &result.mday,
- &result.hour,
- &result.min,
- &result.sec,
- &result.minSec);
- }
- else
- {
- // Original data without Z
- result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%f%d:%d",
- &result.year,
- &result.month,
- &result.mday,
- &result.hour,
- &result.min,
- &result.sec,
- &result.minSec,
- &result.tz_hour,
- &result.tz_min);
- }
- }
- else
- {
- // Original data without mini second
- if(strstr((char*)data, "Z") != NULL)
- {
- // Original data with Z
- result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%dZ",
- &result.year,
- &result.month,
- &result.mday,
- &result.hour,
- &result.min,
- &result.sec);
- }
- else
- {
- // Original data without Z
- result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d%d:%d",
- &result.year,
- &result.month,
- &result.mday,
- &result.hour,
- &result.min,
- &result.sec,
- &result.tz_hour,
- &result.tz_min);
- }
- }
- tmOrg.tm_year = result.year - 1900;
- tmOrg.tm_mon = result.month - 1;
- tmOrg.tm_mday = result.mday;
- tmOrg.tm_hour = result.hour;
- tmOrg.tm_min = result.min;
- tmOrg.tm_sec = result.sec;
- tmOrg.tm_gmtoff = 0;
- tbTarget.time = mktime(&tmOrg);
- tbTarget.timezone = 0;
- tbTarget.time -= (result.tz_hour*3600) + (result.tz_min*60*(result.tz_hour>=0?1:-1));
- tmTarget = gmtime(&tbTarget.time);
- 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);
- //DEBUG_INFO(" org date time: %s\n", data);
- //DEBUG_INFO("parse date time: %s\n", buf);
- system(buf);
- system("/sbin/hwclock -w --systohc");
- if(result.scanedElement < 6)
- result.result = FAIL;
- return result.result;
- }
- //==========================================
- // GetCompositeSchedule logic related function
- //==========================================
- int DiffTimebSec(struct timeb ST, struct timeb ET)
- {
- //return milli-second
- unsigned int StartTime,StopTime;
- StartTime=(unsigned int)ST.time;
- StopTime=(unsigned int)ET.time;
- return (StopTime-StartTime);
- }
- int DiffTimebWithNowSec(struct timeb ST)
- {
- //return milli-second
- struct timeb ET;
- unsigned int StartTime,StopTime;
- ftime(&ET);
- StartTime=(unsigned int)ST.time;
- StopTime=(unsigned int)ET.time;
- return (StopTime-StartTime);
- }
- int getStartStop(uint8_t *start, uint8_t *stop)
- {
- struct ParsingResult
- {
- int result;
- int scanedElement;
- int year;
- int month;
- int mday;
- int hour;
- int min;
- int sec;
- int tz_hour;
- int tz_min;
- float minSec;
- };
- struct ParsingResult parseStart;
- struct ParsingResult parseStop;
- int result = -1;
- struct tm tmStart;
- struct timeb tbStart;
- struct tm tmStop;
- struct timeb tbStop;
- memset(&parseStart, 0x00, sizeof(struct ParsingResult));
- memset(&parseStop, 0x00, sizeof(struct ParsingResult));
- // Scan start & stop date time
- if(strstr((char*)start, ".") != NULL)
- {
- // Original data with mini second
- if(strstr((char*)start, "Z") != NULL)
- {
- // Original data with Z
- parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
- &parseStart.year,
- &parseStart.month,
- &parseStart.mday,
- &parseStart.hour,
- &parseStart.min,
- &parseStart.sec,
- &parseStart.minSec);
- }
- else
- {
- // Original data without Z
- parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
- &parseStart.year,
- &parseStart.month,
- &parseStart.mday,
- &parseStart.hour,
- &parseStart.min,
- &parseStart.sec,
- &parseStart.minSec,
- &parseStart.tz_hour,
- &parseStart.tz_min);
- }
- }
- else
- {
- // Original data without mini second
- if(strstr((char*)start, "Z") != NULL)
- {
- // Original data with Z
- parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
- &parseStart.year,
- &parseStart.month,
- &parseStart.mday,
- &parseStart.hour,
- &parseStart.min,
- &parseStart.sec);
- }
- else
- {
- // Original data without Z
- parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
- &parseStart.year,
- &parseStart.month,
- &parseStart.mday,
- &parseStart.hour,
- &parseStart.min,
- &parseStart.sec,
- &parseStart.tz_hour,
- &parseStart.tz_min);
- }
- }
- if(strstr((char*)stop, ".") != NULL)
- {
- // Original data with mini second
- if(strstr((char*)stop, "Z") != NULL)
- {
- // Original data with Z
- parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%fZ",
- &parseStop.year,
- &parseStop.month,
- &parseStop.mday,
- &parseStop.hour,
- &parseStop.min,
- &parseStop.sec,
- &parseStop.minSec);
- }
- else
- {
- // Original data without Z
- parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%f%d:%d",
- &parseStop.year,
- &parseStop.month,
- &parseStop.mday,
- &parseStop.hour,
- &parseStop.min,
- &parseStop.sec,
- &parseStop.minSec,
- &parseStop.tz_hour,
- &parseStop.tz_min);
- }
- }
- else
- {
- // Original data without mini second
- if(strstr((char*)stop, "Z") != NULL)
- {
- // Original data with Z
- parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%dZ",
- &parseStop.year,
- &parseStop.month,
- &parseStop.mday,
- &parseStop.hour,
- &parseStop.min,
- &parseStop.sec);
- }
- else
- {
- // Original data without Z
- parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d%d:%d",
- &parseStop.year,
- &parseStop.month,
- &parseStop.mday,
- &parseStop.hour,
- &parseStop.min,
- &parseStop.sec,
- &parseStop.tz_hour,
- &parseStop.tz_min);
- }
- }
- // Calculate date time difference
- if((parseStart.scanedElement >=6) &&
- (parseStop.scanedElement >=6))
- {
- //DEBUG_INFO("Start: %04d-%02d-%02d %02d:%02d:%02d(%02d:%02d)\n", parseStart.year, parseStart.month, parseStart.mday, parseStart.hour, parseStart.min, parseStart.sec, parseStart.tz_hour, parseStart.tz_min);
- //DEBUG_INFO("Stop: %04d-%02d-%02d %02d:%02d:%02d(%02d:%02d)\n", parseStop.year, parseStop.month, parseStop.mday, parseStop.hour, parseStop.min, parseStop.sec, parseStop.tz_hour, parseStop.tz_min);
- tmStart.tm_year = parseStart.year - 1900;
- tmStart.tm_mon = parseStart.month - 1;
- tmStart.tm_mday = parseStart.mday;
- tmStart.tm_hour = parseStart.hour;
- tmStart.tm_min = parseStart.min;
- tmStart.tm_sec = parseStart.sec;
- tmStart.tm_gmtoff = 0;
- tbStart.time = mktime(&tmStart);
- tbStart.timezone = 0;
- tbStart.time -= (parseStart.tz_hour*3600) + (parseStart.tz_min*60*(parseStart.tz_hour>=0?1:-1));
- tmStop.tm_year = parseStop.year - 1900;
- tmStop.tm_mon = parseStop.month - 1;
- tmStop.tm_mday = parseStop.mday;
- tmStop.tm_hour = parseStop.hour;
- tmStop.tm_min = parseStop.min;
- tmStop.tm_sec = parseStop.sec;
- tmStop.tm_gmtoff = 0;
- tbStop.time = mktime(&tmStop);
- tbStop.timezone = 0;
- tbStop.time -= (parseStop.tz_hour*3600) + (parseStop.tz_min*60*(parseStop.tz_hour>=0?1:-1));
- result = DiffTimebSec(tbStart, tbStop);
- //DEBUG_INFO("getStartStop(): %d\n", result);
- }
- else
- {
- DEBUG_WARN("Start or stop date parsing error.\r\n");
- }
- return result;
- }
- int isOvertNow(uint8_t *start)
- {
- int result = NO;
- struct ParsingResult
- {
- int result;
- int scanedElement;
- int year;
- int month;
- int mday;
- int hour;
- int min;
- int sec;
- int tz_hour;
- int tz_min;
- float minSec;
- }parsingResult;
- struct tm tmStart;
- struct timeb tbStart;
- memset(&parsingResult, 0x00, sizeof(struct ParsingResult));
- if(strstr((char*)start, ".") != NULL)
- {
- // Original data with mini second
- if(strstr((char*)start, "Z") != NULL)
- {
- // Original data with Z
- parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
- &parsingResult.year,
- &parsingResult.month,
- &parsingResult.mday,
- &parsingResult.hour,
- &parsingResult.min,
- &parsingResult.sec,
- &parsingResult.minSec);
- }
- else
- {
- // Original data without Z
- parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
- &parsingResult.year,
- &parsingResult.month,
- &parsingResult.mday,
- &parsingResult.hour,
- &parsingResult.min,
- &parsingResult.sec,
- &parsingResult.minSec,
- &parsingResult.tz_hour,
- &parsingResult.tz_min);
- }
- }
- else
- {
- // Original data without mini second
- if(strstr((char*)start, "Z") != NULL)
- {
- // Original data with Z
- parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
- &parsingResult.year,
- &parsingResult.month,
- &parsingResult.mday,
- &parsingResult.hour,
- &parsingResult.min,
- &parsingResult.sec);
- }
- else
- {
- // Original data without Z
- parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
- &parsingResult.year,
- &parsingResult.month,
- &parsingResult.mday,
- &parsingResult.hour,
- &parsingResult.min,
- &parsingResult.sec,
- &parsingResult.tz_hour,
- &parsingResult.tz_min);
- }
- }
- if(parsingResult.scanedElement >= 6)
- {
- tmStart.tm_year = parsingResult.year - 1900;
- tmStart.tm_mon = parsingResult.month - 1;
- tmStart.tm_mday = parsingResult.mday;
- tmStart.tm_hour = parsingResult.hour;
- tmStart.tm_min = parsingResult.min;
- tmStart.tm_sec = parsingResult.sec;
- tmStart.tm_gmtoff = 0;
- tbStart.time = mktime(&tmStart);
- tbStart.timezone = 0;
- tbStart.millitm = 0;
- tbStart.time -= (parsingResult.tz_hour*3600) + (parsingResult.tz_min*60*(parsingResult.tz_hour>=0?1:-1));
- if(DiffTimebWithNowSec(tbStart) <= 0)
- result = NO;
- else
- result = YES;
- }
- else
- {
- DEBUG_WARN("Start date parsing error.\n");
- }
- return result;
- }
- int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
- {
- struct ParsingResult
- {
- int result;
- int scanedElement;
- int year;
- int month;
- int mday;
- int hour;
- int min;
- int sec;
- int tz_hour;
- int tz_min;
- float minSec;
- };
- struct ParsingResult parseStart;
- struct ParsingResult parseStop;
- int result = -1;
- struct tm tmStart;
- struct timeb tbStart;
- struct tm tmStop;
- struct timeb tbStop;
- memset(&parseStart, 0x00, sizeof(struct ParsingResult));
- memset(&parseStop, 0x00, sizeof(struct ParsingResult));
- // Scan start & stop date time
- if(strstr((char*)start, ".") != NULL)
- {
- // Original data with mini second
- if(strstr((char*)start, "Z") != NULL)
- {
- // Original data with Z
- parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
- &parseStart.year,
- &parseStart.month,
- &parseStart.mday,
- &parseStart.hour,
- &parseStart.min,
- &parseStart.sec,
- &parseStart.minSec);
- }
- else
- {
- // Original data without Z
- parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
- &parseStart.year,
- &parseStart.month,
- &parseStart.mday,
- &parseStart.hour,
- &parseStart.min,
- &parseStart.sec,
- &parseStart.minSec,
- &parseStart.tz_hour,
- &parseStart.tz_min);
- }
- }
- else
- {
- // Original data without mini second
- if(strstr((char*)start, "Z") != NULL)
- {
- // Original data with Z
- parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
- &parseStart.year,
- &parseStart.month,
- &parseStart.mday,
- &parseStart.hour,
- &parseStart.min,
- &parseStart.sec);
- }
- else
- {
- // Original data without Z
- parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
- &parseStart.year,
- &parseStart.month,
- &parseStart.mday,
- &parseStart.hour,
- &parseStart.min,
- &parseStart.sec,
- &parseStart.tz_hour,
- &parseStart.tz_min);
- }
- }
- if(strstr((char*)stop, ".") != NULL)
- {
- // Original data with mini second
- if(strstr((char*)stop, "Z") != NULL)
- {
- // Original data with Z
- parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%fZ",
- &parseStop.year,
- &parseStop.month,
- &parseStop.mday,
- &parseStop.hour,
- &parseStop.min,
- &parseStop.sec,
- &parseStop.minSec);
- }
- else
- {
- // Original data without Z
- parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%f%d:%d",
- &parseStop.year,
- &parseStop.month,
- &parseStop.mday,
- &parseStop.hour,
- &parseStop.min,
- &parseStop.sec,
- &parseStop.minSec,
- &parseStop.tz_hour,
- &parseStop.tz_min);
- }
- }
- else
- {
- // Original data without mini second
- if(strstr((char*)stop, "Z") != NULL)
- {
- // Original data with Z
- parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%dZ",
- &parseStop.year,
- &parseStop.month,
- &parseStop.mday,
- &parseStop.hour,
- &parseStop.min,
- &parseStop.sec);
- }
- else
- {
- // Original data without Z
- parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d%d:%d",
- &parseStop.year,
- &parseStop.month,
- &parseStop.mday,
- &parseStop.hour,
- &parseStop.min,
- &parseStop.sec,
- &parseStop.tz_hour,
- &parseStop.tz_min);
- }
- }
- // Calculate date time difference
- if((parseStart.scanedElement >=6) &&
- (parseStop.scanedElement >=6))
- {
- //DEBUG_INFO("Start: %04d-%02d-%02d %02d:%02d:%02d(%02d:%02d)\n", parseStart.year, parseStart.month, parseStart.mday, parseStart.hour, parseStart.min, parseStart.sec, parseStart.tz_hour, parseStart.tz_min);
- //DEBUG_INFO("Stop: %04d-%02d-%02d %02d:%02d:%02d(%02d:%02d)\n", parseStop.year, parseStop.month, parseStop.mday, parseStop.hour, parseStop.min, parseStop.sec, parseStop.tz_hour, parseStop.tz_min);
- tmStart.tm_year = parseStart.year - 1900;
- tmStart.tm_mon = parseStart.month - 1;
- tmStart.tm_mday = parseStart.mday;
- tmStart.tm_hour = parseStart.hour;
- tmStart.tm_min = parseStart.min;
- tmStart.tm_sec = parseStart.sec;
- tmStart.tm_gmtoff = 0;
- tbStart.time = mktime(&tmStart);
- tbStart.timezone = 0;
- tbStart.time -= (parseStart.tz_hour*3600) + (parseStart.tz_min*60*(parseStart.tz_hour>=0?1:-1));
- tmStop.tm_year = parseStop.year - 1900;
- tmStop.tm_mon = parseStop.month - 1;
- tmStop.tm_mday = parseStop.mday;
- tmStop.tm_hour = parseStop.hour;
- tmStop.tm_min = parseStop.min;
- tmStop.tm_sec = parseStop.sec;
- tmStop.tm_gmtoff = 0;
- tbStop.time = mktime(&tmStop);
- tbStop.timezone = 0;
- tbStop.time -= (parseStop.tz_hour*3600) + (parseStop.tz_min*60*(parseStop.tz_hour>=0?1:-1));
- result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
- //DEBUG_INFO("getStartStop(): %d\n", result);
- }
- else
- {
- DEBUG_WARN("Start or stop date parsing error.\r\n");
- }
- return result;
- }
- void checkChargingStationMaxProfile(uint32_t durationReq, struct ChargingProfileType *targetCompositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
- {
- FILE *fp;
- char profileFileName[128];
- char *line = NULL;
- size_t len = 0;
- time_t CurrentTime;
- struct tm *tmComposite;
- struct ChargingProfileType maxProfile;
- struct ChargingProfileType compositeProfile;
- uint8_t limitMax=0;
- int compositePeriodIdx = 0;
- CurrentTime = time(NULL);
- tmComposite=localtime(&CurrentTime);
- 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);
- if(isUnitA)
- sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
- else
- sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
- compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
- }
- compositeProfile.id = 0;
- compositeProfile.stackLevel = 99 ;
- sprintf((char*)compositeProfile.chargingProfileKind ,"Absolute");
- maxProfile.id = -1;
- maxProfile.chargingSchedule[idxSchedule].duration = -1;
- system("rm -f /tmp/*.json");
- system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
- // Search max profile
- sprintf(profileFileName, "/tmp/ChargingStationMaxProfile_OCPP20.json");
- if((access(profileFileName, F_OK))!=-1)
- {
- fp = fopen(profileFileName, "r");
- while(getline(&line, &len, fp) != -1)
- {
- json_object *obj = NULL;
- obj = json_tokener_parse(line);
- if(is_error(obj))
- {
- DEBUG_ERROR("Parse MaxProfile from file error.\n");
- }
- else
- {
- if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != maxProfile.id) &&
- (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= maxProfile.stackLevel)
- )
- {
- if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
- (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- )
- {
- struct tm tmFrom, tmTo;
- struct timeb tbFrom, tbTo;
- if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
- (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
- {
- tmFrom.tm_year -= 1900;
- tmFrom.tm_mon -= 1;
- tbFrom.time = mktime(&tmFrom);
- tmTo.tm_year -= 1900;
- tmTo.tm_mon -= 1;
- tbTo.time = mktime(&tmTo);
- if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
- {
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
- }
- if(maxProfile.id == -1)
- DEBUG_INFO("MaxProfile found.\n");
- else
- DEBUG_INFO("MaxProfile updated.\n");
- // Required item
- maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
- maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
- sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
- if(isUnitA)
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
- }
- }
- else
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- }
- }
- // Optional item
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
- {
- sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
- }
- else
- {
- sprintf((char*)maxProfile.validFrom, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- {
- sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
- }
- else
- {
- sprintf((char*)maxProfile.validTo, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
- {
- sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
- }
- else
- {
- sprintf((char*)maxProfile.recurrencyKind, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
- {
- sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
- }
- else
- {
- sprintf((char*)maxProfile.transactionId, " ");
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].duration = 86400;
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
- }
- else
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
- {
- maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
- }
- }
- }
- }
- else
- {
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
- }
- if(maxProfile.id == -1)
- DEBUG_INFO("MaxProfile found.\n");
- else
- DEBUG_INFO("MaxProfile updated.\n");
- // Required item
- maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
- maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
- sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
- if(isUnitA)
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
- }
- }
- else
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- }
- }
- // Optional item
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
- {
- sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
- }
- else
- {
- sprintf((char*)maxProfile.validFrom, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- {
- sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
- }
- else
- {
- sprintf((char*)maxProfile.validTo, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
- {
- sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
- }
- else
- {
- sprintf((char*)maxProfile.recurrencyKind, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
- {
- sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
- }
- else
- {
- sprintf((char*)maxProfile.transactionId, " ");
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].duration = 86400;
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
- }
- else
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
- {
- maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
- }
- }
- }
- }
- json_object_put(obj);
- }
- fclose(fp);
- /*
- if(maxProfile.id !=-1)
- {
- DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
- DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
- DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
- DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
- DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
- DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
- DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
- DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
- DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
- DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
- DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
- {
- DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
- DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
- DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
- }
- }
- }
- else
- DEBUG_INFO("MaxProfile not found.\n");
- DEBUG_INFO("------------------------------------\n");*/
- }
- if(maxProfile.id != -1)
- {
- if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
- {
- if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- if(idxPeriod > 0)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
- {
- if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod;
- if(idxPeriod > 0)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else
- {
- if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
- {
- if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
- if(idxPeriod > 0)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else
- {
- if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
- if(idxPeriod > 0)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- }
- /*
- DEBUG_INFO("MaxProfile after align.\n");
- DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
- DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
- DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
- DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
- DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
- DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
- DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
- DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
- DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
- DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
- DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
- {
- DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
- DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
- DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
- }
- }
- DEBUG_INFO("------------------------------------\n");*/
- }
- // Find each profile period quantity
- for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
- limitMax = idx+1;
- }
- if(maxProfile.id != -1)
- {
- for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
- {
- if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
- (maxProfile.chargingSchedule[idxSchedule].duration > 0))
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
- }
- }
- }
- }
- DEBUG_INFO("ChargePointMaxProfile ready.\n");
- DEBUG_INFO("Schedule start: %s\n", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
- DEBUG_INFO("Schedule duration: %d\n", compositeProfile.chargingSchedule[idxSchedule].duration);
- DEBUG_INFO("Rate unit: %s\n", compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit);
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
- {
- compositeProfile.id = 1;
- DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
- DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
- DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
- }
- if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
- if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
- }
- memcpy(targetCompositeProfile, &compositeProfile, sizeof(struct StructChargingProfile));
- if(line)
- free(line);
- }
- void checkCompositeSchedule(uint8_t evseId, uint32_t durationReq, struct ChargingProfileType *targetCompositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
- {
- FILE *fp;
- char profileFileName[128];
- char *line = NULL;
- size_t len = 0;
- time_t CurrentTime;
- struct tm *tmComposite;
- struct ChargingProfileType maxProfile;
- struct ChargingProfileType defaultTxProfile;
- struct ChargingProfileType txProfile;
- struct ChargingProfileType compositeProfile;
- struct ChargingSchedulePeriodType tmpPeriod;
- uint8_t limitMax=0;
- uint8_t limitDef=0;
- uint8_t limitTx=0;
- int compositePeriodIdx = 0;
- CurrentTime = time(NULL);
- tmComposite=localtime(&CurrentTime);
- 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);
- if(isUnitA)
- sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
- else
- sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
- compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
- }
- compositeProfile.id = 0;
- compositeProfile.stackLevel = 99 ;
- sprintf((char*)compositeProfile.chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
- maxProfile.id = -1;
- defaultTxProfile.id = -1;
- txProfile.id = -1;
- maxProfile.chargingSchedule[idxSchedule].duration = -1;
- defaultTxProfile.chargingSchedule[idxSchedule].duration = -1;
- txProfile.chargingSchedule[idxSchedule].duration = -1;
- system("rm -f /tmp/*.json");
- system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
- /*
- * Search valid charging profile
- */
- //DEBUG_INFO("====================================\n");
- // Search tx profile
- sprintf(profileFileName, "/tmp/TxProfile_%d_OCPP20.json", evseId);
- if((access(profileFileName, F_OK))!=-1)
- {
- fp = fopen(profileFileName, "r");
- while(getline(&line, &len, fp) != -1)
- {
- json_object *obj = NULL;
- obj = json_tokener_parse(line);
- if(is_error(obj))
- {
- DEBUG_ERROR("Parse txProfile from file error.\n");
- }
- else
- {
- if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != txProfile.id) &&
- (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= txProfile.stackLevel)
- )
- {
- if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
- (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- )
- {
- struct tm tmFrom, tmTo;
- struct timeb tbFrom, tbTo;
- if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
- (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
- {
- tmFrom.tm_year -= 1900;
- tmFrom.tm_mon -= 1;
- tbFrom.time = mktime(&tmFrom);
- tmTo.tm_year -= 1900;
- tmTo.tm_mon -= 1;
- tbTo.time = mktime(&tmTo);
- if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
- {
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
- }
- if(txProfile.id == -1)
- DEBUG_INFO("TxProfile found.\n");
- else
- DEBUG_INFO("TxProfile updated.\n");
- // Required item
- txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
- txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
- sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
- if(isUnitA)
- {
- sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
- }
- }
- else
- {
- sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- }
- }
- // Optional item
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
- {
- sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
- }
- else
- {
- sprintf((char*)txProfile.validFrom, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- {
- sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
- }
- else
- {
- sprintf((char*)txProfile.validTo, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
- {
- sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
- }
- else
- {
- sprintf((char*)txProfile.recurrencyKind, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
- {
- sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
- }
- else
- {
- sprintf((char*)txProfile.transactionId, " ");
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
- {
- txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
- }
- else
- {
- txProfile.chargingSchedule[idxSchedule].duration = 86400;
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
- {
- sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
- }
- else
- {
- sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
- {
- txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
- }
- else
- {
- txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
- }
- }
- }
- }
- else
- {
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
- }
- if(txProfile.id == -1)
- DEBUG_INFO("TxProfile found.\n");
- else
- DEBUG_INFO("TxProfile updated.\n");
- // Required item
- txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
- txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
- sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
- if(isUnitA)
- {
- sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
- }
- }
- else
- {
- sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- }
- }
- // Optional item
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
- {
- sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
- }
- else
- {
- sprintf((char*)txProfile.validFrom, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- {
- sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
- }
- else
- {
- sprintf((char*)txProfile.validTo, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
- {
- sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
- }
- else
- {
- sprintf((char*)txProfile.recurrencyKind, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
- {
- sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
- }
- else
- {
- sprintf((char*)txProfile.transactionId, " ");
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
- {
- txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
- }
- else
- {
- txProfile.chargingSchedule[idxSchedule].duration = 86400;
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
- {
- sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
- }
- else
- {
- sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
- {
- txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
- }
- else
- {
- txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
- }
- }
- }
- }
- json_object_put(obj);
- }
- fclose(fp);
- /*
- if(txProfile.id != -1)
- {
- DEBUG_INFO("Profile ID: %d\n", txProfile.id);
- DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
- DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
- DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
- DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
- DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
- DEBUG_INFO("Profile recurrencyKind: %s\n", txProfile.recurrencyKind);
- DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[idxSchedule].StartSchedule);
- DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
- DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
- DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
- {
- if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
- {
- DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
- DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
- DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
- }
- }
- }
- else
- DEBUG_INFO("TxProfile not found.\n");*/
- }
- // Search default tx profile
- sprintf(profileFileName, "/tmp/TxDefaultProfile_%d_OCPP20.json", evseId);
- if((access(profileFileName, F_OK))==-1)
- sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
- if((access(profileFileName, F_OK))!=-1)
- {
- fp = fopen(profileFileName, "r");
- while(getline(&line, &len, fp) != -1)
- {
- json_object *obj = NULL;
- obj = json_tokener_parse(line);
- if(is_error(obj))
- {
- DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
- }
- else
- {
- if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != defaultTxProfile.id) &&
- (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= defaultTxProfile.stackLevel)
- )
- {
- if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
- (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- )
- {
- struct tm tmFrom, tmTo;
- struct timeb tbFrom, tbTo;
- if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
- (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
- {
- tmFrom.tm_year -= 1900;
- tmFrom.tm_mon -= 1;
- tbFrom.time = mktime(&tmFrom);
- tmTo.tm_year -= 1900;
- tmTo.tm_mon -= 1;
- tbTo.time = mktime(&tmTo);
- if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
- {
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
- }
- if(defaultTxProfile.id == -1)
- DEBUG_INFO("TxDefaultProfile found.\n");
- else
- DEBUG_INFO("TxDefaultProfile updated.\n");
- // Required item
- defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
- defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
- sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
- if(isUnitA)
- {
- sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
- }
- }
- else
- {
- sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- }
- }
- // Optional item
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
- {
- sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
- }
- else
- {
- sprintf((char*)defaultTxProfile.validFrom, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- {
- sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
- }
- else
- {
- sprintf((char*)defaultTxProfile.validTo, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
- {
- sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
- }
- else
- {
- sprintf((char*)defaultTxProfile.recurrencyKind, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
- {
- sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
- }
- else
- {
- sprintf((char*)defaultTxProfile.transactionId, " ");
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
- }
- else
- {
- defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
- {
- sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
- }
- else
- {
- sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
- }
- else
- {
- defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
- }
- }
- }
- }
- else
- {
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
- }
- if(defaultTxProfile.id == -1)
- DEBUG_INFO("TxDefaultProfile found.\n");
- else
- DEBUG_INFO("TxDefaultProfile updated.\n");
- // Required item
- defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
- defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
- sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
- if(isUnitA)
- {
- sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
- }
- }
- else
- {
- sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- }
- }
- // Optional item
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
- {
- sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
- }
- else
- {
- sprintf((char*)defaultTxProfile.validFrom, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- {
- sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
- }
- else
- {
- sprintf((char*)defaultTxProfile.validTo, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
- {
- sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
- }
- else
- {
- sprintf((char*)defaultTxProfile.recurrencyKind, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
- {
- sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
- }
- else
- {
- sprintf((char*)defaultTxProfile.transactionId, " ");
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
- }
- else
- {
- defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
- {
- sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
- }
- else
- {
- sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
- }
- else
- {
- defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
- }
- }
- }
- }
- json_object_put(obj);
- }
- fclose(fp);
- /*
- if(defaultTxProfile.id != -1)
- {
- DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.id);
- DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
- DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
- DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
- DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
- DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
- DEBUG_INFO("Profile recurrencyKind: %s\n", defaultTxProfile.recurrencyKind);
- DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].StartSchedule);
- DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
- DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
- DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
- {
- DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
- DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
- DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
- }
- }
- }
- else
- DEBUG_INFO("TxDefaultProfile not found.\n");
- DEBUG_INFO("------------------------------------\n");*/
- }
- // Search max profile
- sprintf(profileFileName, "/tmp/ChargingStationMaxProfile_OCPP20.json");
- if((access(profileFileName, F_OK))!=-1)
- {
- fp = fopen(profileFileName, "r");
- while(getline(&line, &len, fp) != -1)
- {
- json_object *obj = NULL;
- obj = json_tokener_parse(line);
- if(is_error(obj))
- {
- DEBUG_ERROR("Parse MaxProfile from file error.\n");
- }
- else
- {
- if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != maxProfile.id) &&
- (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= maxProfile.stackLevel)
- )
- {
- if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
- (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- )
- {
- struct tm tmFrom, tmTo;
- struct timeb tbFrom, tbTo;
- if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
- (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
- {
- tmFrom.tm_year -= 1900;
- tmFrom.tm_mon -= 1;
- tbFrom.time = mktime(&tmFrom);
- tmTo.tm_year -= 1900;
- tmTo.tm_mon -= 1;
- tbTo.time = mktime(&tmTo);
- if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
- {
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
- }
- if(maxProfile.id == -1)
- DEBUG_INFO("MaxProfile found.\n");
- else
- DEBUG_INFO("MaxProfile updated.\n");
- // Required item
- maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
- maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
- sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
- if(isUnitA)
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
- }
- }
- else
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- }
- }
- // Optional item
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
- {
- sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
- }
- else
- {
- sprintf((char*)maxProfile.validFrom, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- {
- sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
- }
- else
- {
- sprintf((char*)maxProfile.validTo, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
- {
- sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
- }
- else
- {
- sprintf((char*)maxProfile.recurrencyKind, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
- {
- sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
- }
- else
- {
- sprintf((char*)maxProfile.transactionId, " ");
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].duration = 86400;
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
- }
- else
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
- {
- maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
- }
- }
- }
- }
- else
- {
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
- }
- if(maxProfile.id == -1)
- DEBUG_INFO("MaxProfile found.\n");
- else
- DEBUG_INFO("MaxProfile updated.\n");
- // Required item
- maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
- maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
- sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
- if(isUnitA)
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
- }
- }
- else
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
- {
- 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_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- /*if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A')
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = ((ShmSysConfigAndInfo->SysConfig.ModelName[2]=='Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='D') || (ShmSysConfigAndInfo->SysConfig.ModelName[2]=='W')?3:1);
- else
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 1;
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }*/
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- }
- }
- // Optional item
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
- {
- sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
- }
- else
- {
- sprintf((char*)maxProfile.validFrom, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
- {
- sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
- }
- else
- {
- sprintf((char*)maxProfile.validTo, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
- {
- sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
- }
- else
- {
- sprintf((char*)maxProfile.recurrencyKind, " ");
- }
- if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
- {
- sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
- }
- else
- {
- sprintf((char*)maxProfile.transactionId, " ");
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].duration = 86400;
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
- }
- else
- {
- sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
- {
- maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
- }
- else
- {
- maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
- }
- }
- }
- }
- json_object_put(obj);
- }
- fclose(fp);
- /*
- if(maxProfile.id !=-1)
- {
- DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
- DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
- DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
- DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
- DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
- DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
- DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
- DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
- DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
- DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
- DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
- {
- DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
- DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
- DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
- }
- }
- }
- else
- DEBUG_INFO("MaxProfile not found.\n");
- DEBUG_INFO("------------------------------------\n");*/
- }
- /*
- * Align found profile start schedule & periods
- */
- //DEBUG_INFO("====================================\n");
- /*
- // For local test usage, force modify found profile start schedule info
- 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);
- 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);
- 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);
- */
- if(txProfile.id != -1)
- {
- if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
- {
- if(txProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- if(idxPeriod > 0)
- {
- if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
- {
- if(txProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- txProfile.chargingSchedule[idxSchedule].duration = !cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging?txProfile.chargingSchedule[idxSchedule].duration:((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = !cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging?txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod:((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- if(idxPeriod > 0)
- {
- if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else
- {
- if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
- {
- if(txProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
- 0:
- (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
- 0:
- (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
- if(idxPeriod > 0)
- {
- if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else
- {
- if(txProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
- 0:
- (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
- 0:
- (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
- if(idxPeriod > 0)
- {
- if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- }
- /*
- DEBUG_INFO("txProfile after align.\n");
- DEBUG_INFO("Profile ID: %d\n", txProfile.id);
- DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
- DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
- DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
- DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
- DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
- DEBUG_INFO("Profile recurrencyKind: %s\n", txProfile.recurrencyKind);
- DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
- DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
- DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
- DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
- {
- if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
- {
- DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
- DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
- DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
- }
- }*/
- }
- if(defaultTxProfile.id != -1)
- {
- if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- if(idxPeriod > 0)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].duration = !cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging?defaultTxProfile.chargingSchedule[idxSchedule].duration:((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = !cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging?defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod:((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- if(idxPeriod > 0)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else
- {
- if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
- 0:
- (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
- 0:
- (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
- if(idxPeriod > 0)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
- 0:
- (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
- 0:
- (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
- if(idxPeriod > 0)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- }
- /*
- DEBUG_INFO("defaultTxProfile after align.\n");
- DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.id);
- DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
- DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
- DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
- DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
- DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
- DEBUG_INFO("Profile recurrencyKind: %s\n", defaultTxProfile.recurrencyKind);
- DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
- DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
- DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
- DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
- {
- DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
- DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
- DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
- }
- }
- DEBUG_INFO("------------------------------------\n");*/
- }
- if(maxProfile.id != -1)
- {
- if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
- {
- if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- if(idxPeriod > 0)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
- {
- if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = !cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging?maxProfile.chargingSchedule[idxSchedule].duration:((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[9].startSchedule)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = !cpinitateMsg.bits[(evseId==0?0:evseId-1)].isOnCharging?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod:((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(evseId==0?0:evseId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
- if(idxPeriod > 0)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else
- {
- if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
- {
- if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
- if(idxPeriod > 0)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- else
- {
- if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
- }
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
- 0:
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
- if(idxPeriod > 0)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
- {
- maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
- }
- }
- }
- }
- }
- }
- /*
- DEBUG_INFO("MaxProfile after align.\n");
- DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
- DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
- DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
- DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
- DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
- DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
- DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
- DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
- DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
- DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
- DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
- {
- DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
- DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
- DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
- }
- }
- DEBUG_INFO("------------------------------------\n");*/
- }
- /*
- * Merge to conposite schedule
- */
- //DEBUG_INFO("====================================\n");
- // Find each profile period quantity
- for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
- limitMax = idx+1;
- }
- for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
- limitDef = idx+1;
- }
- for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
- {
- if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
- limitTx = idx+1;
- }
- // TxProfile found, composite schedule based on it
- if(txProfile.id != -1)
- {
- compositeProfile.chargingSchedule[idxSchedule].duration = txProfile.chargingSchedule[idxSchedule].duration;
- for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
- {
- if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
- (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
- (txProfile.chargingSchedule[idxSchedule].duration > 0))
- {
- if(maxProfile.id != -1)
- {
- for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
- {
- if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
- {
- if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
- {
- tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
- tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
- 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);
- }
- else
- {
- tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
- tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
- tmpPeriod.limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit;
- }
- }
- if(idxMaxPeriod == (limitMax-1))
- {
- if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
- {
- if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
- }
- }
- }
- }
- }
- else
- {
- if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
- }
- }
- }
- if(idxTxPeriod == (limitTx-1))
- {
- if(defaultTxProfile.id != -1)
- {
- compositeProfile.chargingSchedule[idxSchedule].duration = (defaultTxProfile.chargingSchedule[idxSchedule].duration>compositeProfile.chargingSchedule[idxSchedule].duration)?defaultTxProfile.chargingSchedule[idxSchedule].duration:compositeProfile.chargingSchedule[idxSchedule].duration;
- for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
- {
- if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
- (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
- (defaultTxProfile.chargingSchedule[idxSchedule].duration>0))
- {
- if(maxProfile.id != -1)
- {
- for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
- {
- if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
- {
- tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
- tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
- 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);
- }
- else
- {
- tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
- tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
- tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
- }
- if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
- {
- if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
- }
- }
- // Delete duplicate period
- if(compositePeriodIdx > 1)
- {
- if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
- {
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
- compositePeriodIdx -= 1;
- }
- }
- }
- else
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
- }
- break;
- }
- }
- }
- else
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
- }
- }
- }
- }
- }
- }
- }
- }
- // TxProfile not found but defaultTxProfile found, composite schedule based on it
- else if(defaultTxProfile.id != -1)
- {
- compositeProfile.chargingSchedule[idxSchedule].duration = defaultTxProfile.chargingSchedule[idxSchedule].duration;
- for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
- {
- if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
- (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
- (defaultTxProfile.chargingSchedule[idxSchedule].duration > 0))
- {
- if(maxProfile.id != -1)
- {
- for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
- {
- tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
- tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
- if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
- {
- 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);
- }
- else
- {
- tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
- }
- if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
- {
- if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
- }
- }
- // Delete duplicate period
- if(compositePeriodIdx > 1)
- {
- if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
- {
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
- compositePeriodIdx -= 1;
- }
- }
- }
- else
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
- }
- break;
- }
- }
- }
- else
- {
- if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
- }
- }
- }
- }
- }
- // Fill other period by MaxProfile
- if(maxProfile.id != -1)
- {
- if(compositePeriodIdx==0)
- {
- compositeProfile.chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
- for(int idxMaxPeriod=0;idxMaxPeriod<limitDef;idxMaxPeriod++)
- {
- if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
- (maxProfile.chargingSchedule[idxSchedule].duration > 0))
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
- }
- }
- }
- }
- else
- {
- int lastCompositePeriodIdx = compositePeriodIdx;
- for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
- {
- if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
- (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
- (maxProfile.chargingSchedule[idxSchedule].duration > 0))
- {
- if((maxProfile.chargingSchedule[idxSchedule].duration >= compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod))
- {
- if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit > compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit)
- {
- tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
- tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
- tmpPeriod.limit = compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit;
- }
- else
- {
- tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
- tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
- tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
- }
- }
- if(tmpPeriod.limit != -1)
- {
- if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].limit)
- {
- if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].startPeriod)
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
- compositePeriodIdx++;
- }
- else
- {
- memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
- }
- }
- // Delete duplicate period
- if(compositePeriodIdx > 1)
- {
- if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
- {
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
- compositePeriodIdx -= 1;
- }
- }
- }
- }
- }
- }
- }
- if(compositeProfile.chargingSchedule[idxSchedule].duration < durationReq)
- {
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if((idxPeriod >= 0) && (compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1))
- {
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = compositeProfile.chargingSchedule[idxSchedule].duration;
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (isUnitA==TRUE)?ShmSysConfigAndInfo->SysConfig.RatingCurrent:modelnameInfo.ratedPower;
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].numberPhases;
- DEBUG_INFO(">>> Adding startPeriod because the duration of the final schedule is shorter than requested duration.\n");
- DEBUG_INFO("Add Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
- DEBUG_INFO("Add Period-%02d limit: %f\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
- DEBUG_INFO("Add Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
- DEBUG_INFO("------------------------------------------------\n");
- break;
- }
- }
- }
- compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
- DEBUG_INFO("Connector-%d composite schedule ready.\n", evseId);
- DEBUG_INFO("Schedule start: %s\n", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
- DEBUG_INFO("Schedule duration: %d\n", compositeProfile.chargingSchedule[idxSchedule].duration);
- DEBUG_INFO("Rate unit: %s\n", compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit);
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
- {
- compositeProfile.id = 1;
- DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
- DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
- DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
- }
- if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
- if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
- compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
- }
- memcpy(targetCompositeProfile, &compositeProfile, sizeof(struct StructChargingProfile));
- if(line)
- free(line);
- ShmOCPP20Data->CSUMsg.bits[(evseId==0?0:evseId-1)].ChargingProfileConf = ON;
- }
- //==========================================
- // Init all share memory
- //==========================================
- int InitShareMemory()
- {
- int result = PASS;
- int MeterSMId;
- //creat ShmSysConfigAndInfo
- if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
- {
- DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
- result = FAIL;
- }
- else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
- result = FAIL;
- }
- else
- {}
- if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
- {
- DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
- result = FAIL;
- }
- else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
- result = FAIL;
- }
- else
- {}
- //creat ShmPsuData
- if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
- {
- DEBUG_ERROR("shmget ShmPsuData NG\n");
- result = FAIL;
- }
- else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- DEBUG_ERROR("shmat ShmPsuData NG\n");
- result = FAIL;
- }
- else
- {}
- //creat ShmOCPP20Data
- if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
- {
- DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
- result = FAIL;
- }
- else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
- result = FAIL;
- }
- else
- {}
- /****************************** For Initial Settings************************************************/
- /*
- DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
- DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
- DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
- DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
- DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
- DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
- DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
- DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
- DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
- DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
- DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
- DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
- DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
- DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
- DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
- DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
- DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
- DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
- DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
- DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
- DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
- DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
- DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
- DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
- DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
- DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
- DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
- DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
- DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
- DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
- DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
- DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
- DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
- DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
- DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
- DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
- DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
- DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
- DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
- DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
- DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
- DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
- DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
- DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
- DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
- DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
- DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
- DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
- DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
- DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
- DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
- DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
- DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
- DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
- DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
- DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
- DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
- DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
- DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
- DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
- DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
- DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
- */
- return result;
- }
- int ProcessShareMemory()
- {
- int result = PASS;
- if(InitShareMemory() == FAIL)
- {
- DEBUG_ERROR("InitShareMemory NG\n");
- if(ShmStatusCodeData!=NULL)
- {
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
- }
- result = FAIL;
- }
- if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
- {
- DEBUG_INFO("Model name rated power: %d\n", modelnameInfo.ratedPower);
- if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
- ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
- (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
- (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O') ||
- (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='L') ||
- (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='Z'))
- ) // 'D' means DC
- {
- // DO series
- for(int gun_index=0; gun_index<GENERAL_GUN_QUANTITY ; gun_index++)
- {
- gunTotalNumber += 1;
- gunType[gun_index] = GUN_TYPE_DO;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == gun_index)
- {
- periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
- periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
- DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption);
- }
- }
- switch(modelnameInfo.ParsingInfo[gun_index].GunType)
- {
- case Gun_Type_Chademo:
- DEBUG_INFO("Gun-%02d type: Cabinet CHAdeMO\n", gun_index);
- for(int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
- periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
- DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption);
- }
- }
- break;
- case Gun_Type_CCS_2:
- DEBUG_INFO("Gun-%02d type: Cabinet CCS\n", gun_index);
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
- periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
- DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption);
- }
- }
- break;
- case Gun_Type_GB:
- DEBUG_INFO("Gun-%02d type: Cabinet GBT\n", gun_index);
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
- periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
- DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption);
- }
- }
- break;
- case Gun_Type_AC:
- DEBUG_INFO("Gun-%02d type: Cabinet AC\n", gun_index);
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
- periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
- DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption);
- }
- }
- break;
- default:
- DEBUG_WARN("Gun-%02d type: Cabinet unknown\n", gun_index);
- break;
- }
- }
- }
- else
- {
- for(int gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
- {
- gunTotalNumber += 1;
- switch(modelnameInfo.ParsingInfo[gun_index].GunType)
- {
- case Gun_Type_Chademo:
- gunType[gun_index] = GUN_TYPE_CHAdeMO;
- DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
- break;
- case Gun_Type_CCS_2:
- gunType[gun_index] = GUN_TYPE_CCS;
- DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
- break;
- case Gun_Type_GB:
- gunType[gun_index] = GUN_TYPE_GBT;
- DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
- break;
- case Gun_Type_AC:
- gunType[gun_index] = GUN_TYPE_AC;
- DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
- break;
- default:
- DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
- break;
- }
- }
- }
- }
- else
- {
- DEBUG_ERROR("Model name parsing fail.\n");
- result = FAIL;
- }
- if(result != PASS)sleep(5);
- return result;
- }
- //---------------------common routine---------------------------//
- void checkNetworkProfile(void)
- {
- memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
- json_object *priority;
- priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
- if(!is_error(priority))
- {
- for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
- {
- for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
- {
- if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
- (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
- (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
- {
- memcpy(ShmOCPP20Data->OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
- ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
- break;
- }
- }
- }
- }
- json_object_put(priority);
- DEBUG_INFO("Get network profile URL: %s\n", ShmOCPP20Data->OcppServerURL);
- }
- void checkRemoteStart(uint8_t evseIdx)
- {
- uint8_t tempIndex;
- int isAllowStart = TRUE;
- char cmdBuf[512];
- //check Transaction active
- if(gunType[evseIdx-1] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((evseIdx-1) == 2) ? 1: 0;
- }
- else
- {
- tempIndex = (evseIdx-1);
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseIdx-1].idToken.idToken) == 0))
- {
- //Reserved
- DEBUG_INFO("CHAdeMO connector already reserved and idTag match.\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseIdx-1].idToken.idToken) != 0))
- {
- //Reserved
- DEBUG_INFO("CHAdeMO connector already reserved and idTag does not match.\n");
- isAllowStart = FALSE;
- }
- else
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) //S_PRECHARGE
- && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) //S_PREPARING_FOR_EV
- && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE )) // S_PREPARING_FOR_EVSE
- {
- DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n.");
- isAllowStart = FALSE;
- }
- }//END FOR ELSE
- }
- }// END FOR CHAdeMO_QUANTITY
- }
- else if(gunType[evseIdx-1] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((evseIdx-1) == 2) ? 1: 0;
- }
- else
- {
- tempIndex = (evseIdx-1);
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseIdx-1].idToken.idToken) == 0))
- {
- //Reserved
- DEBUG_INFO("CCS connector already reserved and idTag match.\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseIdx-1].idToken.idToken) != 0))
- {
- //Reserved
- DEBUG_INFO("CCS connector already reserved and idTag does not match.\n");
- isAllowStart = FALSE;
- }
- else
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
- && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
- && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
- {
- DEBUG_WARN("CCS connector not allow start cause busy.\n.");
- isAllowStart = FALSE;
- }
- }// END FOR ELSE
- }
- }// END FOR CCS_QUANTITY
- }
- else if(gunType[evseIdx-1] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((evseIdx-1) == 2) ? 1: 0;
- }
- else
- {
- tempIndex = (evseIdx-1);
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseIdx-1].idToken.idToken) == 0))
- {
- //Reserved
- DEBUG_INFO("GBT connector already reserved and idTag match.\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseIdx-1].idToken.idToken) != 0))
- {
- //Reserved
- DEBUG_INFO("GBT connector already reserved and idTag does not match.\n");
- isAllowStart = FALSE;
- }
- else
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
- && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
- && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
- {
- DEBUG_WARN("GBT connector not allow start cause busy.\n");
- isAllowStart = FALSE;
- }
- }// END FOR ELSE
- }
- } // END FOR GB_QUANTITY
- }
- else if(gunType[evseIdx-1] == GUN_TYPE_DO)
- {
- tempIndex = (evseIdx-1);
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
- {
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseIdx-1].idToken.idToken) == 0))
- {
- //Reserved
- DEBUG_INFO("Dispenser connector already reserved and idTag match.\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseIdx-1].idToken.idToken) != 0))
- {
- //Reserved
- DEBUG_INFO("Dispenser connector already reserved and idTag does not match.\n");
- isAllowStart = FALSE;
- }
- else
- {
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) //S_IDLE
- && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
- && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
- && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
- {
- DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
- isAllowStart = FALSE;
- }
- }// END FOR ELSE
- }
- } // END FOR GB_QUANTITY
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = (evseIdx-1);
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseIdx-1].idToken.idToken) == 0))
- {
- //Reserved
- DEBUG_INFO("AC connector already reserved and idTag match.\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseIdx-1].idToken.idToken) != 0))
- {
- //Reserved
- DEBUG_INFO("AC connector already reserved and idTag does not match.\n");
- isAllowStart = FALSE;
- }
- else
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
- && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
- && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
- {
- DEBUG_WARN("AC connector not allow start cause busy.\n");
- isAllowStart = FALSE;
- }
- }//END FOR ELSE
- }
- }// END FOR AC_QUANTITY
- }
- if(isAllowStart == TRUE)
- {
- if(ShmOCPP20Data->RequestStartTransaction[evseIdx -1].chargingProfile.id > 0)
- {
- if((access("/Storage/OCPP/TxProfile_Tmp_OCPP20.json", F_OK))!=-1)
- {
- sprintf(cmdBuf, "mv /Storage/OCPP/TxProfile_Tmp_OCPP20.json /Storage/OCPP/TxProfile_%d_OCPP20.json", evseIdx);
- system(cmdBuf);
- }
- }
- ShmOCPP20Data->CsMsg.bits[evseIdx-1].RequestStartTransactionReq = ON;
- }
- }
- void CheckSystemValue(void)
- {
- char filenmae[100]={0};
- char str[100]={0};
- int tempIndex = 0;
- //===============================
- // EVSE operation check
- //===============================
- //===============================
- // Heartbeat check
- //===============================
- if((server_sign == TRUE) && (getDiffSecNow(clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
- {
- //parameter for test
- if(HeartBeatWithNOResponse < 1)
- sendHeartbeatRequest(0);
- //==============================================
- // Reset Waiting Time
- //==============================================
- HeartBeatWithNOResponse += 1;
- }
- //===============================
- // CSU Trigger Authorize Request
- //===============================
- if(isWebsocketSendable &&
- (server_sign == TRUE) &&
- (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
- (authorizeRetryTimes < 3))
- {
- sendAuthorizeRequest(0);
- authorizeRetryTimes = authorizeRetryTimes + 1;
- if(authorizeRetryTimes < 3)
- ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
- }
- else if((server_sign == TRUE) &&
- (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
- (authorizeRetryTimes >= 3))
- {
- authorizeRetryTimes = 0;
- SetOcppConnStatus(FALSE);
- server_sign = FALSE;
- }
- else if((server_sign == FALSE) &&
- (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "true") == 0) &&
- (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "true") == 0) &&
- (ShmOCPP20Data->OcppConnStatus == OFF) &&
- (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
- {
- sendAuthorizeRequest(0);
- }
- //===============================
- // NotifyMonitoringReportRequest
- //===============================
- if(isWebsocketSendable &&
- (server_sign == TRUE) &&
- (ShmOCPP20Data->GetMonitoringReport.requestId > 0))
- {
- ShmOCPP20Data->NotifyMonitoringReport.requestId = ShmOCPP20Data->GetMonitoringReport.requestId;
- ShmOCPP20Data->NotifyMonitoringReport.tbc = 0;
- ShmOCPP20Data->NotifyMonitoringReport.seqNo = 0;
- getNowDatetime(ShmOCPP20Data->NotifyMonitoringReport.generatedAt);
- sendNotifyMonitoringReportRequest();
- ShmOCPP20Data->GetMonitoringReport.requestId = 0;
- }
- if(isWebsocketSendable &&
- (server_sign == TRUE) &&
- (ShmOCPP20Data->GetReport.requestId > 0))
- {
- for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetReport.componentCriteria);idxCriterion++)
- {
- if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Active]) == 0)
- {
- /*
- * TODO:
- * 1. Report component that are active
- */
- }
- else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Available]) == 0)
- {
- /*
- * TODO:
- * 1. Report component that are available
- */
- }
- else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Enabled]) == 0)
- {
- /*
- * TODO:
- * 1. Report component that are enable
- */
- }
- else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Problem]) == 0)
- {
- /*
- * TODO:
- * 1. Report component that are problem
- */
- }
- else
- {
- /*
- * TODO:
- * 1. Process unknown criteria condition
- */
- }
- }
- ShmOCPP20Data->GetReport.requestId = 0;
- }
- if(isWebsocketSendable &&
- (server_sign == TRUE) &&
- (ShmOCPP20Data->GetBaseReport.requestId > 0))
- {
- uint8_t reportIdx = 0;
- ShmOCPP20Data->NotifyReport.requestId = ShmOCPP20Data->GetBaseReport.requestId;
- if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
- {
- for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
- {
- if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
- {
- 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))
- {
- memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
- reportIdx++;
- }
- }
- else
- {
- getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
- if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
- ShmOCPP20Data->NotifyReport.seqNo += 1;
- else
- ShmOCPP20Data->NotifyReport.seqNo = 0;
- sendNotifyReportRequest();
- memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
- reportIdx = 0;
- idx_var--;
- }
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
- {
- for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
- {
- if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
- {
- memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
- reportIdx++;
- }
- else
- {
- getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
- if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
- ShmOCPP20Data->NotifyReport.seqNo += 1;
- else
- ShmOCPP20Data->NotifyReport.seqNo = 0;
- sendNotifyReportRequest();
- memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
- reportIdx = 0;
- idx_var--;
- }
- }
- }
- else
- {
- /*
- * TODO:
- * 1. Fill out summary inventory to response message, currently not support
- */
- }
- if(reportIdx > 0)
- {
- getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
- if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
- ShmOCPP20Data->NotifyReport.seqNo += 1;
- else
- ShmOCPP20Data->NotifyReport.seqNo = 0;
- sendNotifyReportRequest();
- memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
- reportIdx = 0;
- }
- ShmOCPP20Data->GetBaseReport.requestId = 0;
- }
- if(isWebsocketSendable &&
- (server_sign == TRUE) &&
- ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
- {
- getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
- ShmOCPP20Data->NotifyEvent.tbc = FALSE;
- if(ShmOCPP20Data->NotifyEvent.seqNo < INT_MAX)
- ShmOCPP20Data->NotifyEvent.seqNo += 1;
- else
- ShmOCPP20Data->NotifyEvent.seqNo = 0;
- sendNotifyEventRequest();
- memset(&ShmOCPP20Data->NotifyEvent.eventData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)* sizeof(struct EventDataType ));
- ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
- }
- if(isWebsocketSendable &&
- (server_sign == TRUE) &&
- ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq)
- {
- if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Install]) == 0)
- {
- /*
- * TODO:
- * 1.
- */
- }
- else if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Update]) == 0)
- {
- /*
- * TODO:
- * 1.
- */
- }
- else
- {
- /*
- * TODO:
- * 1.
- */
- }
- sendGet15118EVCertificateRequest();
- ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
- }
- if(isWebsocketSendable &&
- (server_sign == TRUE) &&
- (ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq == ON))
- {
- sendSecurityEventNotificationRequest();
- ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
- }
- if(isWebsocketSendable &&
- (server_sign == TRUE) &&
- (ShmOCPP20Data->SpMsg.bits.NotifyCustomerInformationReq == ON))
- {
- sendNotifyCustomerInformationRequest();
- ShmOCPP20Data->SpMsg.bits.NotifyCustomerInformationReq = OFF;
- }
- for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
- {
- // ClockAlign MeterValue
- 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))
- {
- //check Transaction active
- if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
- {
- cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
- }
- }// End for CHAdeMO
- }
- else if(gunType[gun_index] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
- }
- } // End for CCS
- }
- else if(gunType[gun_index] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
- }
- }// End for GB
- }
- else if(gunType[gun_index] == GUN_TYPE_DO)
- {
- tempIndex = gun_index;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
- }
- }
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
- }
- }//End for AC
- }
- }
- }
- //===============================
- // Each connector operation check
- //===============================
- for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
- {
- //==========================================
- // Check remote start without connector id
- //==========================================
- if(ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
- {
- int evseIdInt = -1;
- for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
- {
- if(!cpinitateMsg.bits[gun_index].isOnCharging && (strstr((char*)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[ConnectorStatusEnumType_Occupied]) != NULL))
- {
- evseIdInt = (gun_index+1);
- DEBUG_INFO("Detect connector of evse-%02d connected ready to start.\n", evseIdInt);
- checkRemoteStart(evseIdInt);
- ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = OFF;
- break;
- }
- }
- if(getDiffSecNow(clientTime.RemoteStartWait) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value))
- {
- DEBUG_WARN("Remote start request without evse id wait link over %s seconds.\n", (char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value);
- ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = OFF;
- }
- }
- //==========================================
- // csu trigger DataTransferReq
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
- {
- sendDataTransferRequest(gun_index);
- ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
- }
- //==============================================
- // Charger status notification & Transaction event report
- //==============================================
- //--- Check Mode Change ---//
- // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
- if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
- {
- //if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_AUTHORIZING)
- cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
- /*if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE) &&
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != AcPreviousSystemStatus[index]))
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- else
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) > 0)
- {
- sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic); //For synchronizing metervalues
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- }
- }
- }*/
- ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
- ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
- {
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
- if((access(filenmae,F_OK))!=-1)
- {
- DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
- sprintf(str,"rm -f %s",filenmae);
- system(str);
- }
- }
- }
- cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
- #if 1 // for TempStopTransaction
- if(((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
- (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
- {
- checkTempStopTransaction(gun_index);
- }
- #endif
- }
- }
- }
- else if(gunType[gun_index] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- if((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]*/ )
- {
- //if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_AUTHORIZING)
- cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
- /*if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE) &&
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != AcPreviousSystemStatus[index]))
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- else
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) > 0)
- {
- sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic); //For synchronizing metervalues
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- }
- }
- }*/
- CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
- CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
- {
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
- if((access(filenmae,F_OK))!=-1)
- {
- DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
- sprintf(str,"rm -f %s",filenmae);
- system(str);
- }
- }
- }
- cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
- #if 1 // for TempStopTransaction
- if(((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
- (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
- {
- checkTempStopTransaction(gun_index);
- }
- #endif
- }
- }
- }
- else if(gunType[gun_index] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
- {
- //if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_AUTHORIZING)
- cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
- /*if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE) &&
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]))
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- else
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) > 0)
- {
- sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic); //For synchronizing metervalues
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- }
- }
- }*/
- GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
- GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
- {
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
- if((access(filenmae,F_OK))!=-1)
- {
- DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
- sprintf(str,"rm -f %s",filenmae);
- system(str);
- }
- }
- }
- cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
- #if 1 // for TempStopTransaction
- if(((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
- (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
- {
- checkTempStopTransaction(gun_index);
- }
- #endif
- }
- }
- }
- else if(gunType[gun_index] == GUN_TYPE_DO)
- {
- tempIndex = gun_index;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
- {
- //if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_AUTHORIZING)
- cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
- /*if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CHARGING) &&
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE) &&
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]))
- {
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- else
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) > 0)
- {
- sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic); //For synchronizing metervalues
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- }
- }
- }*/
- DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
- DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_IDLE))) // complete
- {
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
- if((access(filenmae,F_OK))!=-1)
- {
- DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
- sprintf(str,"rm -f %s",filenmae);
- system(str);
- }
- }
- }
- 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);
- #if 1 // for TempStopTransaction
- if(((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)) &&
- (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
- {
- checkTempStopTransaction(gun_index);
- }
- #endif
- }
- }
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
- {
- //if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_AUTHORIZING)
- cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
- /*if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE) &&
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) && (AcPreviousSystemStatus[index] != 99))
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- else
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) > 0)
- {
- sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic); //For synchronizing metervalues
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- }
- }
- }*/
- AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
- AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
- {
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
- if((access(filenmae,F_OK))!=-1)
- {
- DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
- sprintf(str,"rm -f %s",filenmae);
- system(str);
- }
- }
- }
- cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
- #if 1 // for TempStopTransaction
- if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
- (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
- {
- checkTempStopTransaction(gun_index);
- }
- #endif
- }
- }// END
- }
- if(isWebsocketSendable && (server_sign == TRUE) && (getDiffSecNow(clientTime.StatusNotification[gun_index]) >= 5) && (ShmOCPP20Data->MsMsg.bits.ResetConf != ON) &&
- ((cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) || (cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq == ON) ||
- ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "true") == 0) &&
- (getDiffSecNow(clientTime.StatusNotification[gun_index]) >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].value)))))
- {
- sendStatusNotificationRequest(gun_index);
- refreshStartTimer(&clientTime.StatusNotification[gun_index]);
- }
- //==============================================
- // CSU Trigger or timer timeout refresh Smart Charging Profile
- //==============================================
- if((ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON) ||
- ((cpinitateMsg.bits[gun_index].isOnCharging) && (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].variableAttribute[0].value) > 0) && (getDiffSecNow(clientTime.CharingProfileRefresh[gun_index]) > atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_CharingProfileRefreshInterval].variableAttribute[0].value))))
- {
- checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
- checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index], 0, TRUE);
- ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
- refreshStartTimer(&clientTime.CharingProfileRefresh[gun_index]);
- }
- //==============================================
- // CSU transaction event
- //==============================================
- if(ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == ON || cpinitateMsg.bits[gun_index].TriggerTransactionEventReq == ON)
- {
- sendTransactionEventRequest(gun_index);
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
- cpinitateMsg.bits[gun_index].TriggerTransactionEventReq = OFF;
- //storeTempStopTransaction(gun_index);
- //memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
- }
- //==============================================
- // Meter report
- //==============================================
- if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
- {
- sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger, FALSE);
- cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
- }
- if(isWebsocketSendable && (cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON))
- {
- sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock, FALSE);
- cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
- }
- // Sample period MeterValue
- if((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0) &&
- (getDiffSecNow(clientTime.MeterValues[gun_index]) >= ((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)>3)?(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1):3)))
- {
- //check Transaction active
- if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
- {
- cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
- }
- }
- }// End for CHAdeMO
- }
- else if(gunType[gun_index] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
- {
- cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
- }
- }
- } // End for CCS
- }
- else if(gunType[gun_index] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
- {
- cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
- }
- }
- }// End for GB
- }
- else if(gunType[gun_index] == GUN_TYPE_DO)
- {
- tempIndex = gun_index;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING))
- {
- cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
- }
- }
- }
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
- {
- cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
- }
- }
- }//End for AC
- }
- if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
- {
- if(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0)
- {
- sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic, FALSE);
- }
- cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
- }
- refreshStartTimer(&clientTime.MeterValues[gun_index]);
- }
- if((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value) > 0) &&
- (getDiffSecNow(clientTime.SampledDataTxEnded[gun_index]) >= ((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value)>3)?(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value)- 1):3)))
- {
- //check Transaction active
- if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
- {
- cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
- }
- }
- }// End for CHAdeMO
- }
- else if(gunType[gun_index] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
- {
- cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
- }
- }
- } // End for CCS
- }
- else if(gunType[gun_index] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
- {
- cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
- }
- }
- }// End for GB
- }
- else if(gunType[gun_index] == GUN_TYPE_DO)
- {
- tempIndex = gun_index;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING))
- {
- cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
- }
- }
- }
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
- {
- cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
- }
- }
- }//End for AC
- }
- if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
- {
- if(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0)
- {
- sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic, TRUE);
- }
- cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
- }
- refreshStartTimer(&clientTime.SampledDataTxEnded[gun_index]);
- }
- //==============================================
- // Check Connector reserved
- //==============================================
- //===============================
- // Check if Reserve is expired
- //===============================
- if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0))
- {
- if(isOvertNow(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime))
- {
- DEBUG_INFO("reserve expired.\n");
- ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId = ShmOCPP20Data->ReserveNow[gun_index].id;
- sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Expired]);
- ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = ON;
- memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
- }
- }//END OF Check if Reserve is expired
- //==========================================
- // csu trigger FirmwareStatusNotificationReq
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
- {
- sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
- }
- //==========================================
- // csu cleared charging limit request
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq == ON))
- {
- sendClearedChargingLimitRequest(gun_index);
- }
- //==========================================
- // csu trigger CancelReservationConf
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
- {
- sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
- }
- //==========================================
- // csu notify EV charging need request
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq == ON))
- {
- sendNotifyEVChargingNeedsRequest(gun_index);
- ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq = OFF;
- }
- //==========================================
- // csu notify EV charging schedule request
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingScheduleReq == ON))
- {
- sendNotifyEVChargingScheduleRequest(gun_index);
- ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingScheduleReq = OFF;
- }
- //==========================================
- // csu trigger ChangeAvailabilityConf
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
- {
- //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
- }
- //==========================================
- // csu trigger UnlockConnectorConf
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
- {
- sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
- }
- //==========================================
- // csu trigger ReserveNowConf
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
- {
- sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
- }
- //==========================================
- // csu trigger ReserveNowConf
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq == ON))
- {
- sendReservationStatusUpdateRequest(gun_index);
- }
- //==========================================
- // csu trigger LogStatusNotificationReq
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq == ON))
- {
- if(isCancelUploadLog == TRUE)
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
- else
- sendLogStatusNotificationRequest((char *)ShmOCPP20Data->LogStatusNotification.status);
- }
- //==========================================
- // csu trigger SignCertificateReq
- //==========================================
- if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.SignCertificateReq == ON))
- {
- if((access("/Storage/OCPP/certCP.csr",F_OK) != -1) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0) )
- {
- sendSignCertificateRequest(CertificateSignedStatusEnumType_ChargingStationCertificate);
- }
- else if((access("/Storage/OCPP/certV2G.csr",F_OK) != -1) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0))
- {
- sendSignCertificateRequest(CertificateSignedStatusEnumType_V2GCertificate);
- }
- }
- }
- }
- //==========================================
- // send request routine
- //==========================================
- int sendAuthorizeRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37];
- char tempdata[128]={0};
- json_object *Authorize = json_object_new_object();
- json_object *idToken = json_object_new_object();
- DEBUG_INFO("sendAuthorizeRequest...\n");
- memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
- //Local Authorize
- if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "true")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
- {
- DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
- strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
- strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
- strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
- result = PASS;
- ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
- ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
- authorizeRetryTimes = 0;
- return result;
- }
- 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)) ||
- ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "true") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "true") == 0)))
- {
- // Query idtag from cache
- DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
- // Query idtag from list
- if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strstr((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) == NULL))
- DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
- if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strstr((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) == NULL))
- {
- if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
- {
- DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
- }
- if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
- {
- DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
- }
- // Return authorize result if does not connect to server
- if(!ShmOCPP20Data->OcppConnStatus)
- {
- DEBUG_INFO("Local Authorization Fail.\n");
- strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
- strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
- strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
- DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
- ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
- ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
- authorizeRetryTimes = 0;
- return result;
- }
- }
- else
- {
- DEBUG_INFO("Local Authorization get result.\n");
- strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
- strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
- if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
- sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
- else
- strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
- DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
- result = PASS;
- ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
- ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
- authorizeRetryTimes = 0;
- return result;
- }
- }
- //get data from shared memory
- strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
- json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
- json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
- if(strcmp((char*)ShmOCPP20Data->Authorize.idToken.type, IdTokenEnumTypeStr[IdTokenType_eMAID]) == 0)
- {
- memset(&ShmOCPP20Data->Authorize.Response_idTokenInfo,0,sizeof(struct IdTokenInfoType));
- int parseCertResult = FAIL;
- json_object *iso15118CertificateHashData = json_object_new_array();
- // Read CERTIFICATE_PnCAuth file content
- if(access(CERTIFICATE_PnCAuth,F_OK) != -1)
- {
- memset(ShmOCPP20Data->Authorize.certificate, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.certificate));
- FILE *fp=fopen(CERTIFICATE_PnCAuth,"r");
- char *line = NULL;
- size_t len = 0;
- while(getline(&line, &len, fp) != -1)
- {
- //memcpy(&ShmOCPP16Data->v2g_extend.Authorize.certificate[strlen((char*)ShmOCPP16Data->v2g_extend.Authorize.certificate)], line, (strlen(line)-1));
- strcat((char *)ShmOCPP20Data->Authorize.certificate, line);
- }
- fclose(fp);
- }
- if(strlen((char*)ShmOCPP20Data->Authorize.certificate) > 0)
- json_object_object_add(Authorize, "certificate", json_object_new_string((char*)ShmOCPP20Data->Authorize.certificate));
- char parseData[512] = {0};
- if(parseCertInfo(CERTIFICATE_PnCAuth, CERT_PARSE_HashAlgorithm, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[0].hashAlgorithm, parseData);
- if(parseCertInfo(CERTIFICATE_PnCAuth, CERT_PARSE_SerialNumber, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[0].serialNumber, parseData);
- if(parseCertInfo(CERTIFICATE_PnCAuth, CERT_PARSE_IssuerNameHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[0].issuerNameHash, parseData);
- if(parseCertInfo(CERTIFICATE_PnCAuth, CERT_PARSE_IssuerKeyHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[0].issuerKeyHash, parseData);
- if(parseCertInfo(CERTIFICATE_PnCAuth, CERT_PARSE_OcspUrl, parseData) == PASS && strlen((char*)parseData) >= 7)
- strcpy((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[0].responderURL, parseData);
- for(int idx=0; idx < 4; idx++)
- {
- if(strlen((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].hashAlgorithm) > 0)
- {
- json_object *OCSPRequestDataType = json_object_new_object();
- json_object_object_add(OCSPRequestDataType, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].hashAlgorithm));
- json_object_object_add(OCSPRequestDataType, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].issuerNameHash));
- json_object_object_add(OCSPRequestDataType, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].issuerKeyHash));
- json_object_object_add(OCSPRequestDataType, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].serialNumber));
- json_object_object_add(OCSPRequestDataType, "responderURL", json_object_new_string((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].responderURL));
- json_object_array_add(iso15118CertificateHashData, OCSPRequestDataType);
- parseCertResult = PASS;
- }
- }
- if(parseCertResult == PASS)
- {
- json_object_object_add(Authorize, "iso15118CertificateHashData", iso15118CertificateHashData);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->Authorize.Response_certificateStatus, "NoCertificateAvailable");
- sprintf((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "Invalid");
- ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON;
- }
- }
- json_object_object_add(Authorize, "idToken", idToken);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
- json_object_put(Authorize);
- LWS_Send(message);
- sprintf(tempdata, "Authorize,%d", gun_index);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
- return result;
- }
- int sendBootNotificationRequest()
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *BootNotification = json_object_new_object();
- json_object *chargingStation = json_object_new_object();
- json_object *modem = json_object_new_object();
- DEBUG_INFO("sendBootNotificationRequest...\n");
- // Fill BootNotification fields
- DB_getBooType();
- sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
- sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
- sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
- sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
- sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
- sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
- if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
- {
- json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
- json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
- json_object_object_add(chargingStation, "modem", modem);
- }
- json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
- json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
- json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
- json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
- json_object_object_add(BootNotification, "chargingStation", chargingStation);
- json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
- json_object_put(BootNotification);
- LWS_Send(message);
- sprintf(tempdata, "BootNotification,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendClearedChargingLimitRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *ClearedChargingLimit = json_object_new_object();
- DEBUG_INFO("sendClearedChargingLimitRequest...\n");
- json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
- json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
- json_object_put(ClearedChargingLimit);
- LWS_Send(message);
- sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
- return result;
- }
- int sendDataTransferRequest(int gun_index)
- {
- mtrace();
- char message[1000]={0};
- char guid[37]={0};
- char tempdata[65]={0};
- int result = FAIL;
- DEBUG_INFO("sendDataTransferRequest...\n");
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
- MESSAGE_TYPE_CALL,
- guid,
- ShmOCPP20Data->DataTransfer[gun_index].vendorId,
- ShmOCPP20Data->DataTransfer[gun_index].messageId,
- ShmOCPP20Data->DataTransfer[gun_index].data);
- LWS_Send(message);
- sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendFirmwareStatusNotificationRequest(char *status)
- {
- mtrace();
- int result = FAIL;
- char message[110]={0};
- char guid[37]={0};
- char tempdata[65]={0};
- json_object *FirmwareStatusNotification = json_object_new_object();
- DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
- sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
- json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
- json_object_put(FirmwareStatusNotification);
- LWS_SendNow(message);
- sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
- //record status
- if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
- DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
- DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
- DB_updateSecurityEventType(SecurityEventEnumType_FirmwareUpdated);
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
- DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
- DB_updateSecurityEventType(SecurityEventEnumType_FirmwareUpdated);
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
- }
- else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
- }
- return result;
- }
- int sendGet15118EVCertificateRequest()
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *Get15118EVCertificate = json_object_new_object();
- DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
- json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
- json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
- json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
- json_object_put(Get15118EVCertificate);
- LWS_Send(message);
- sprintf(tempdata, "Get15118EVCertificate,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendGetCertificateStatusRequest()
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *GetCertificateStatus = json_object_new_object();
- json_object *ocspRequestData = json_object_new_object();
- DEBUG_INFO("sendGetCertificateStatusRequest...\n");
- json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
- json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
- json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
- json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
- json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
- json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetCertificateStatus);
- LWS_Send(message);
- sprintf(tempdata, "GetCertificateStatus,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendHeartbeatRequest()
- {
- mtrace();
- int result = FAIL;
- char message[40096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- DEBUG_INFO("sendHeartbeatRequest...\n");
- random_uuid(guid);
- sprintf(message, "[%d,\"%s\",\"Heartbeat\",{}]"
- , MESSAGE_TYPE_CALL
- , guid );
- LWS_Send(message);
- sprintf(tempdata, "Heartbeat,%d", 0);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendLogStatusNotificationRequest(char *status)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *LogStatusNotification = json_object_new_object();
- DEBUG_INFO("sendLogStatusNotificationRequest...\n");
- ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
- sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
- json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
- json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
- json_object_put(LogStatusNotification);
- LWS_SendNow(message);
- sprintf(tempdata, "LogStatusNotification,%d", 0);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
- //record status
- if(strcmp(status,"BadMessage")==0)
- {
- LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
- }
- else if(strcmp(status,"Idle")==0)
- {
- LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
- }
- else if(strcmp(status,"NotSupportedOperation")==0)
- {
- LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
- }
- else if(strcmp(status,"PermissionDenied")==0)
- {
- LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
- }
- else if(strcmp(status,"Uploaded")==0)
- {
- LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
- }
- else if(strcmp(status,"UploadFailure")==0)
- {
- LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
- }
- else if(strcmp(status,"Uploading")==0)
- {
- LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
- }
- return result;
- }
- int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType, uint8_t isSampledDataTxEnd)
- {
- mtrace();
- int result = FAIL;
- char guid[37]={0};
- char tempdata[65]={0};
- int tempIndex = 0;
- DEBUG_INFO("sendMeterValuesRequest...\n");
- memset(queuedata, 0, ARRAY_SIZE(queuedata));
- memset(&ShmOCPP20Data->MeterValues[gun_index], 0, sizeof(struct MeterValues_20));
- //set value
- ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
- //UTC Date time
- struct timeval tmnow;
- struct tm *tm;
- char buf[28];//, usec_buf[6];
- gettimeofday(&tmnow, NULL);
- time_t t;
- t = time(NULL);
- /*UTC time and date*/
- tm = gmtime(&t);
- if(dataType == ReadingContextEnumType_Sample_Clock)
- {
- struct tm *tmTarget;
- struct timeb tbTarget;
- tbTarget.time = mktime(tm);
- tbTarget.time -= (atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value));
- tmTarget = gmtime(&tbTarget.time);
- strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tmTarget);
- }
- else
- {
- strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
- }
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
- struct ChargingInfoData *targetChargingInfoData = getTargetChargingInfoData(gun_index);
- //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
- //idx_sample=0;
- //********************************(1)Current.Import L1************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(targetChargingInfoData->PresentChargingCurrent*100))/100.0;
- if(gunType[gun_index] == GUN_TYPE_AC)
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
- else
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
- }
- //idx_sample=1;
- //********************************(2)Energy.Active.Import.Register ************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(targetChargingInfoData->PowerConsumption*100))/100.0;
- if(gunType[gun_index] == GUN_TYPE_AC)
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
- else
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
- }
- //idx_sample=2;
- //****************************************************(3)Energy.Active.Import.Interval*********************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
- if(dataType == ReadingContextEnumType_Sample_Clock)
- {
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (targetChargingInfoData->PowerConsumption - periousClockPowerConsumption[gun_index]);
- periousClockPowerConsumption[gun_index] = targetChargingInfoData->PowerConsumption;
- }
- else if(dataType == ReadingContextEnumType_Sample_Periodic)
- {
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (targetChargingInfoData->PowerConsumption - periousPeriodicPowerConsumption[gun_index]);
- periousPeriodicPowerConsumption[gun_index] = targetChargingInfoData->PowerConsumption;
- }
- else
- {
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = 0;
- }
- if(gunType[gun_index] == GUN_TYPE_AC)
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
- else
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
- }
- //idx_sample=3;
- //********************************(4)Power.Active.Import************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(targetChargingInfoData->PresentChargingPower*100))/100.0;
- if(gunType[gun_index] == GUN_TYPE_AC)
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
- else
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
- }
- //idx_sample=4;
- //***********************************************(5)VOLTAGE L1******************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(targetChargingInfoData->PresentChargingVoltage*100))/100.0;
- if(gunType[gun_index] == GUN_TYPE_AC)
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
- else
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
- }
- //***********************************************(6)SOC******************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- 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))
- {
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = targetChargingInfoData->EvBatterySoc;
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
- }
- }
- //********************************(7)Current.Import L2************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- // Only for AC 3 phase
- if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
- {
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ((uint32_t)(targetChargingInfoData->PresentChargingCurrentL2*100))/100.0;
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
- }
- }
- //********************************(8)Current.Import L3************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- // Only for AC 3 phase
- if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
- {
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ((uint32_t)(targetChargingInfoData->PresentChargingCurrentL3*100))/100.0;
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
- }
- }
- //***********************************************(9)VOLTAGE L2******************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
- {
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ((uint32_t)(targetChargingInfoData->PresentChargingVoltageL2*100))/100.0;
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
- }
- }
- //***********************************************(10)VOLTAGE L3******************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
- {
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ((uint32_t)(targetChargingInfoData->PresentChargingVoltageL3*100))/100.0;
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
- }
- }
- //***********************************************(11)Current.Offered******************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
- if(gunType[gun_index] == GUN_TYPE_AC)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- uint16_t currentOffer;
- if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
- {
- currentOffer = ShmSysConfigAndInfo->SysConfig.RatingCurrent;
- }
- else
- {
- currentOffer = ((ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent>ShmSysConfigAndInfo->SysConfig.RatingCurrent)?ShmSysConfigAndInfo->SysConfig.RatingCurrent:ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
- }
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = currentOffer;
- }
- }
- }
- else
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t)(targetChargingInfoData->AvailableChargingCurrent/10);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.uint , "A");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.multiplier = 0;
- }
- //***********************************************(12)Power.Offered******************************************************/
- if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
- (dataType == ReadingContextEnumType_Trigger))
- {
- //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t)(targetChargingInfoData->AvailableChargingPower*100);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].context, ReadingContextEnumTypeStr[dataType]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
- strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.uint , "W");
- ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.multiplier = 0;
- }
- // Message create ====================================================================================================
- random_uuid(guid);
- json_object *MeterValueReq = json_object_new_object();
- json_object *meterValues = json_object_new_array();
- json_object *sampledValues = json_object_new_array();
- json_object *sampledValuesBuffer = json_object_new_array();
- for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
- {
- json_object *meterValue = json_object_new_object();
- json_object *MeterValueBuffer = json_object_new_object();
- for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
- {
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
- {
- json_object *sampledValue = json_object_new_object();
- json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
- json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
- json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
- json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
- json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].signedMeterValue.signedMeterData) > 0)
- {
- json_object *signedMeterValue = json_object_new_object();
- json_object_object_add(signedMeterValue, "signedMeterData", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].signedMeterValue.signedMeterData));
- json_object_object_add(signedMeterValue, "signingMethod", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].signedMeterValue.signingMethod));
- json_object_object_add(signedMeterValue, "encodingMethod", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].signedMeterValue.encodingMethod));
- json_object_object_add(signedMeterValue, "publicKey", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].signedMeterValue.publicKey));
- json_object_object_add(sampledValue, "signedMeterValue", signedMeterValue);
- }
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
- {
- json_object *unitOfMeasure = json_object_new_object();
- json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
- json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
- json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
- }
- json_object_array_add(sampledValues, sampledValue);
- // For StopTxn data
- if((isSampledDataTxEnd == TRUE) &&
- (((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, (char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand ) != NULL) && (strlen((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value) > 0)) ||
- ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, (char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) != NULL) && (strlen((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value) > 0))))
- {
- json_object *sampledValue = json_object_new_object();
- json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
- json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
- json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
- json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
- json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].signedMeterValue.signedMeterData) > 0)
- {
- json_object *signedMeterValue = json_object_new_object();
- json_object_object_add(signedMeterValue, "signedMeterData", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].signedMeterValue.signedMeterData));
- json_object_object_add(signedMeterValue, "signingMethod", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].signedMeterValue.signingMethod));
- json_object_object_add(signedMeterValue, "encodingMethod", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].signedMeterValue.encodingMethod));
- json_object_object_add(signedMeterValue, "publicKey", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].signedMeterValue.publicKey));
- json_object_object_add(sampledValue, "signedMeterValue", signedMeterValue);
- }
- if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
- {
- json_object *unitOfMeasure = json_object_new_object();
- json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
- json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
- json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
- }
- json_object_array_add(sampledValuesBuffer, sampledValue);
- }
- }
- }
- json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
- json_object_object_add(meterValue, "sampledValue", sampledValues);
- json_object_array_add(meterValues, meterValue);
- // For StopTxn data
- if((isSampledDataTxEnd == TRUE) && (dataType != ReadingContextEnumType_Trigger) &&
- (json_object_array_length(sampledValuesBuffer) > 0))
- {
- json_object_object_add(MeterValueBuffer, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
- json_object_object_add(MeterValueBuffer, "sampledValue", sampledValuesBuffer);
- if(meterValueBufferDataQuantity(gun_index, dataType) < 200)
- meterValueBufferInsert(gun_index, dataType, (char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)json_object_to_json_string_ext(MeterValueBuffer, JSON_C_TO_STRING_PLAIN));
- else
- meterValueBufferReplace(200, gun_index, dataType, (char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)json_object_to_json_string_ext(MeterValueBuffer, JSON_C_TO_STRING_PLAIN));
- json_object_put(MeterValueBuffer);
- }
- else
- {
- json_object_put(sampledValuesBuffer);
- json_object_put(MeterValueBuffer);
- }
- idxMeter++;
- }
- json_object_object_add(MeterValueReq, "meterValue", meterValues);
- json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
- sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",%s]"
- ,MESSAGE_TYPE_CALL
- ,guid
- ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
- json_object_put(MeterValueReq);
- if((dataType != ReadingContextEnumType_Trigger) &&
- (dataType != ReadingContextEnumType_Sample_Clock))
- {
- // Transaction meter value send by TransactionEvent message
- memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
- if(isSampledDataTxEnd != TRUE)
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
- result = PASS;
- }
- else
- {
- // Put request guid to hash map
- sprintf(tempdata, "MeterValues,%d", (gun_index));
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- if((dataType != ReadingContextEnumType_Trigger) &&
- (dataType != ReadingContextEnumType_Sample_Clock))
- queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
- else
- {
- if(FirstHeartBeat)
- LWS_Send(queuedata);
- }
- }
- return result;
- }
- int sendNotifyChargingLimitRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *NotifyChargingLimit = json_object_new_object();
- json_object *chargingLimit = json_object_new_object();
- DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
- json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
- json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
- json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
- json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
- json_object_put(NotifyChargingLimit);
- LWS_Send(message);
- sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendNotifyCustomerInformationRequest()
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *NotifyCustomerInformation = json_object_new_object();
- DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
- json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
- json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
- json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
- json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
- json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
- json_object_put(NotifyCustomerInformation);
- LWS_Send(message);
- sprintf(tempdata, "NotifyCustomerInformation,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendNotifyDisplayMessagesRequest()
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *NotifyDisplayMessages = json_object_new_object();
- json_object *messageInfos = json_object_new_array();
- DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
- json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
- json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
- for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
- {
- if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
- {
- json_object *messageInfo = json_object_new_object();
- json_object *message = json_object_new_object();
- json_object *display = json_object_new_object();
- json_object *evse = json_object_new_object();
- json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
- json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
- json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
- json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
- json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
- json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
- json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
- json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
- json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
- json_object_object_add(messageInfo, "message", message);
- json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
- json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
- json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
- json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
- json_object_object_add(display, "evse",evse);
- json_object_object_add(messageInfo, "evse", display);
- json_object_array_add(messageInfos, messageInfo);
- }
- }
- json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
- json_object_put(NotifyDisplayMessages);
- LWS_Send(message);
- sprintf(tempdata, "NotifyDisplayMessages,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendNotifyEVChargingNeedsRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *NotifyEVChargingNeeds = json_object_new_object();
- json_object *chargingNeeds = json_object_new_object();
- json_object *acChargingParameters = json_object_new_object();
- json_object *dcChargingParameters = json_object_new_object();
- DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
- json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
- json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
- json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
- json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
- json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
- json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
- json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
- json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
- json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
- json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
- json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
- json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
- json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
- json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
- json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
- json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
- json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
- json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
- json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
- json_object_put(NotifyEVChargingNeeds);
- LWS_Send(message);
- sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendNotifyEVChargingScheduleRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *NotifyEVChargingSchedule = json_object_new_object();
- json_object *chargingSchedule = json_object_new_object();
- json_object *periods = json_object_new_array();
- DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
- json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
- json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
- json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
- json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
- json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
- json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
- json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
- {
- if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
- (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
- {
- json_object *Period = json_object_new_object();
- json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
- json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
- if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
- json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
- if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
- json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
- json_object_array_add(periods, Period);
- }
- }
- json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
- json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
- json_object_put(NotifyEVChargingSchedule);
- LWS_Send(message);
- sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendNotifyEventRequest()
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *NotifyEvent = json_object_new_object();
- json_object *eventDatas = json_object_new_array();
- DEBUG_INFO("sendNotifyEventRequest...\n");
- json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
- json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
- json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
- for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
- {
- if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
- {
- json_object *eventData = json_object_new_object();
- json_object *component = json_object_new_object();
- json_object *evse = json_object_new_object();
- json_object *variable = json_object_new_object();
- json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
- json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
- json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
- json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
- json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
- json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
- json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
- json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
- json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
- json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
- json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
- json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
- json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
- json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
- json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
- json_object_object_add(component, "evse",evse);
- json_object_object_add(eventData, "component", component);
- json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
- json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
- json_object_object_add(eventData, "variable", variable);
- json_object_array_add(eventDatas, eventData);
- }
- }
- json_object_object_add(NotifyEvent, "eventData", eventDatas);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
- json_object_put(NotifyEvent);
- LWS_Send(message);
- sprintf(tempdata, "NotifyEvent,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendNotifyMonitoringReportRequest()
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *NotifyMonitoringReport = json_object_new_object();
- json_object *monitors = json_object_new_array();
- DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
- json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
- json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
- json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
- json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
- for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
- {
- if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
- {
- json_object *monitor = json_object_new_object();
- json_object *component = json_object_new_object();
- json_object *evse = json_object_new_object();
- json_object *variable = json_object_new_object();
- json_object *variableMonitorings = json_object_new_array();
- json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
- json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
- json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
- json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
- json_object_object_add(component, "evse",evse);
- json_object_object_add(monitor, "component", component);
- json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
- json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
- json_object_object_add(monitor, "variable", variable);
- for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
- {
- if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
- {
- json_object *variableMonitoring = json_object_new_object();
- json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
- json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
- json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
- json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
- json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
- json_object_array_add(variableMonitorings, variableMonitoring);
- }
- }
- json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
- json_object_array_add(monitors, monitor);
- }
- }
- json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
- json_object_put(NotifyMonitoringReport);
- LWS_Send(message);
- sprintf(tempdata, "NotifyMonitoringReport,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendNotifyReportRequest()
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *NotifyReport = json_object_new_object();
- json_object *reportDatas = json_object_new_array();
- DEBUG_INFO("sendNotifyReportRequest...\n");
- json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
- json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
- json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
- json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
- for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
- {
- if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
- {
- json_object *reportData = json_object_new_object();
- json_object *component = json_object_new_object();
- json_object *evse = json_object_new_object();
- json_object *variable = json_object_new_object();
- json_object *variableAttributes = json_object_new_array();
- json_object *variableCharacteristics = json_object_new_object();
- json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
- json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
- json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
- json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
- json_object_object_add(component, "evse",evse);
- json_object_object_add(reportData, "component", component);
- json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
- json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
- json_object_object_add(reportData, "variable",variable);
- json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
- json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
- json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
- json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
- json_object_object_add(variableCharacteristics, "supportsMonitoring", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.supportsMonitoring));
- json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
- for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
- {
- if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
- {
- json_object *variableAttribute = json_object_new_object();
- json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
- json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
- json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
- json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
- json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
- json_object_array_add(variableAttributes, variableAttribute);
- }
- }
- json_object_object_add(reportData, "variableAttribute", variableAttributes);
- json_object_array_add(reportDatas, reportData);
- }
- }
- json_object_object_add(NotifyReport, "reportData", reportDatas);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
- json_object_put(NotifyReport);
- LWS_SendNow(message);
- sprintf(tempdata, "NotifyReport,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendPublishFirmwareStatusNotificationRequest()
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *PublishFirmwareStatusNotification = json_object_new_object();
- json_object *locations = json_object_new_array();
- DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
- json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
- json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
- for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
- {
- json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
- }
- json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
- json_object_put(PublishFirmwareStatusNotification);
- LWS_Send(message);
- sprintf(tempdata, "PublishFirmwareStatusNotification,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendReportChargingProfilesRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *ReportChargingProfiles = json_object_new_object();
- json_object *chargingProfiles = json_object_new_array();
- DEBUG_INFO("sendReportChargingProfilesRequest...\n");
- json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
- json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
- json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
- json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
- for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
- {
- json_object *chargingProfile = json_object_new_object();
- json_object *chargingSchedules = json_object_new_array();
- json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
- json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
- json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
- json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
- json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
- json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
- json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
- json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
- for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
- {
- json_object *chargingSchedule = json_object_new_object();
- json_object *chargingSchedulePeriods = json_object_new_array();
- json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
- json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
- json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
- json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
- json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
- {
- json_object *chargingSchedulePeriod = json_object_new_object();
- json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
- json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
- json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
- json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
- }
- json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
- json_object_array_add(chargingSchedules, chargingSchedule);
- }
- json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
- json_object_array_add(chargingProfiles, chargingProfile);
- }
- json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
- json_object_put(ReportChargingProfiles);
- LWS_Send(message);
- sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendReservationStatusUpdateRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *ReservationStatusUpdate = json_object_new_object();
- DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
- json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
- json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
- json_object_put(ReservationStatusUpdate);
- LWS_Send(message);
- sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
- }
- return result;
- }
- int sendSecurityEventNotificationRequest()
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- struct timeval tmnow;
- struct tm *tm;
- char buf[28];//, usec_buf[6];
- json_object *SecurityEventNotification = json_object_new_object();
- DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
- DB_getSecurityEventType();
- gettimeofday(&tmnow, NULL);
- time_t t;
- t = time(NULL);
- /*UTC time and date*/
- tm = gmtime(&t);
- strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
- #if 0 // remove temporally
- strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
- strcat(buf,".");
- sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
- strcat(buf,usec_buf);
- #endif
- printf("%s",buf);
- strcpy((char *)ShmOCPP20Data->SecurityEventNotification.timestamp, buf);
- if(strlen((char *)ShmOCPP20Data->SecurityEventNotification.techInfo)==0)
- sprintf((char*)ShmOCPP20Data->SecurityEventNotification.type,"%s", SecurityEventEnumTypeStr[SecurityEventEnumType_ResetOrReboot]);
- json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
- json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
- if(strlen((char *)ShmOCPP20Data->SecurityEventNotification.techInfo)>0)
- json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techInfo));
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
- json_object_put(SecurityEventNotification);
- LWS_Send(message);
- sprintf(tempdata, "SecurityEventNotification,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendSignCertificateRequest(CertificateSigningUseEnumType certType)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- json_object *SignCertificate = json_object_new_object();
- DEBUG_INFO("sendSignCertificateRequest...\n");
- // Read csr file content
- memset(ShmOCPP20Data->SignCertificate.csr, 0x00, ARRAY_SIZE(ShmOCPP20Data->SignCertificate.csr));
- FILE *fp=fopen(((certType == CertificateSignedStatusEnumType_V2GCertificate)?CSR_V2G:CSR_CP),"r");
- char *line = NULL;
- size_t len = 0;
- while(getline(&line, &len, fp) != -1)
- {
- if((strstr(line, "BEGIN CERTIFICATE REQUEST") == NULL) && (strstr(line, "END CERTIFICATE REQUEST") == NULL))
- {
- memcpy(&ShmOCPP20Data->SignCertificate.csr[strlen((char*)ShmOCPP20Data->SignCertificate.csr)], line, (strlen(line)-1));
- }
- }
- fclose(fp);
- json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
- sprintf((char*)ShmOCPP20Data->SignCertificate.certificateType, CertificateSigningUseEnumTypeStr[certType]);
- json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
- json_object_put(SignCertificate);
- LWS_Send(message);
- sprintf(tempdata, "SignCertificate,0");
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- return result;
- }
- int sendStatusNotificationRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[600]={0};
- char guid[37];
- int currentStatus = 0;
- struct timeval tmnow;
- struct tm *tm;
- char buf[28];//, usec_buf[6];
- char tempdata[65]={0};
- int tempIndex = 0;
- uint8_t isStateChanged = TRUE;
- DEBUG_INFO("sendStatusNotificationRequest...\n");
- gettimeofday(&tmnow, NULL);
- time_t t;
- t = time(NULL);
- /*UTC time and date*/
- tm = gmtime(&t);
- strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
- #if 0 // remove temporally
- strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
- strcat(buf,".");
- sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
- strcat(buf,usec_buf);
- #endif
- printf("%s",buf);
- ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
- ShmOCPP20Data->StatusNotification[gun_index].connectorId = 1;
- strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
- //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
- /*
- enum _SYSTEM_STATUS
- {
- S_BOOTING = 0,
- S_IDLE, = 1
- S_AUTHORIZING, =2
- S_REASSIGN_CHECK, =3
- S_REASSIGN, =4
- S_PRECHARGE, =5
- S_PREPARING_FOR_EV, =6
- S_PREPARING_FOR_EVSE, =7
- S_CHARGING, =8
- S_TERMINATING, =9
- S_COMPLETE, =10
- S_ALARM, =11
- S_FAULT =12
- }
- */
- //check Transaction active
- //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
- if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
- }
- else
- {
- currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
- }
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
- }
- else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
- ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
- ) //S_PRECHARGE
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
- }
- else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
- }
- else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
- }
- else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
- }
- 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
- {
- currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
- }
- else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
- {
- currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
- }
- else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
- {
- currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
- }
- } //end of the same index
- }//end of for CHAdeMO_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
- }
- else
- {
- currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
- }
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
- }
- else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
- ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
- ) //S_PRECHARGE
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
- }
- else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
- }
- else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
- }
- else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
- }
- 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
- {
- currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
- }
- else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
- {
- currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
- }
- else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
- {
- currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
- }
- } //end of the same index
- } // end of for CCS_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
- }
- else
- {
- currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
- }
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
- }
- else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
- ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
- ) //S_PRECHARGE
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
- }
- else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
- }
- else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
- }
- else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
- }
- 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
- {
- currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
- }
- else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
- {
- currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
- }
- else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
- {
- currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
- }
- } //end of the same index
- } // end of for GB_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_DO)
- {
- tempIndex = gun_index;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
- }
- else
- {
- currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
- }
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
- }
- else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
- ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
- ) //S_PRECHARGE
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
- }
- else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
- }
- else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
- }
- else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
- }
- 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
- {
- currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
- }
- 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
- {
- currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
- }
- else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
- {
- currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
- }
- } //end of the same index
- }
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
- {
- 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))
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
- }
- else
- {
- currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
- }
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
- }
- else if (/*(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || */(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
- }
- else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
- }
- else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
- }
- else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
- {
- currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
- }
- 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
- {
- currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
- }
- else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
- {
- currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
- }
- else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
- {
- currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
- }
- }//end of the same index
- }//end of for AC_QUANTITY
- }
- //it's option
- if((strstr((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]) != NULL) &&
- !cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq &&
- (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "true") != 0))
- {
- isStateChanged = FALSE;
- }
- cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
- strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
- random_uuid(guid);
- sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
- , MESSAGE_TYPE_CALL
- , guid
- , ShmOCPP20Data->StatusNotification[gun_index].connectorId
- , ShmOCPP20Data->StatusNotification[gun_index].evseId
- , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
- , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
- if((server_sign == TRUE) && isStateChanged)
- {
- cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
- cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
- LWS_Send(message);
- sprintf(tempdata, "StatusNotification,%d", (gun_index));
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- }
- else
- {
- cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
- cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
- result = PASS;
- }
- return result;
- }
- int sendTransactionEventRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[QUEUE_MESSAGE_LENGTH]={0};
- char guid[37]={0};
- char tempdata[128]={0};
- uint8_t tempIndex;
- json_object *TransactionEvent = json_object_new_object();
- json_object *transactionInfo = json_object_new_object();
- json_object *idToken = json_object_new_object();
- json_object *evse = json_object_new_object();
- json_object *meterValues = json_object_new_array();
- char TempStopTransaction[256];
- sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
- DEBUG_INFO("sendTransactionEventRequest...\n");
- if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
- {
- getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
- if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
- ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
- else
- ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
- ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = 1;
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
- }
- }
- else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
- }
- else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
- ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
- ) //S_PRECHARGE
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
- {
- random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartIdType]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- }
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- }
- else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartMethod == 2)
- {
- ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
- }
- else
- random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartIdType]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
- }
- else
- {
- storeTempStopTransaction(gun_index);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
- }
- }
- else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- if((access(TempStopTransaction,F_OK))!=-1)
- {
- remove(TempStopTransaction); // remove file "TempStopTransaction"
- }
- }
- else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- }
- 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
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- } //end of the same index
- }//end of for CHAdeMO_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
- if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
- ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
- else
- ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
- ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = 1;
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
- }
- }
- else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
- }
- else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
- ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
- ) //S_PRECHARGE
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
- {
- random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartIdType]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- }
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- }
- else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartMethod == 2)
- {
- ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
- }
- else
- random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartIdType]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
- }
- else
- {
- storeTempStopTransaction(gun_index);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
- }
- }
- else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- if((access(TempStopTransaction,F_OK))!=-1)
- {
- remove(TempStopTransaction); // remove file "TempStopTransaction"
- }
- }
- else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- }
- 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
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- } //end of the same index
- } // end of for CCS_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
- if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
- ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
- else
- ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
- ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = 1;
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
- }
- }
- else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
- }
- else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
- ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
- ) //S_PRECHARGE
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
- {
- random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartIdType]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- }
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- }
- else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartMethod == 2)
- {
- ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
- }
- else
- random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartIdType]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
- }
- else
- {
- storeTempStopTransaction(gun_index);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
- }
- }
- else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- if((access(TempStopTransaction,F_OK))!=-1)
- {
- remove(TempStopTransaction); // remove file "TempStopTransaction"
- }
- }
- else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- }
- 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
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- } //end of the same index
- } // end of for GB_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_DO)
- {
- tempIndex = gun_index;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
- if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
- ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
- else
- ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
- ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = 1;
- if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
- }
- }
- else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
- }
- else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
- ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
- ) //S_PRECHARGE
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
- {
- random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartIdType]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- }
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- }
- else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
- {
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartMethod == 2)
- {
- ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
- }
- else
- random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartIdType]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
- }
- else
- {
- storeTempStopTransaction(gun_index);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
- }
- }
- else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- if((access(TempStopTransaction,F_OK))!=-1)
- {
- remove(TempStopTransaction); // remove file "TempStopTransaction"
- }
- }
- else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- }
- 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
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- 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
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- } //end of the same index
- }
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
- if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
- ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
- else
- ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
- ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = 1;
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
- 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))
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
- }
- }
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
- }
- else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
- ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
- ) //S_PRECHARGE
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
- {
- random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartIdType]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- }
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- }
- else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == 2)
- {
- ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
- }
- else
- random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartIdType]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
- }
- else
- {
- storeTempStopTransaction(gun_index);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
- }
- }
- else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- if((access(TempStopTransaction,F_OK))!=-1)
- {
- remove(TempStopTransaction); // remove file "TempStopTransaction"
- }
- }
- else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
- }
- 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
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- }
- }//end of the same index
- }//end of for AC_QUANTITY
- }
- // Check if this message is triggered by TriggerMessage
- if(cpinitateMsg.bits[gun_index].TriggerTransactionEventReq == ON)
- {
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Trigger]);
- }
- // Clear meterValue buffer for the next transaction
- if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Started]) != NULL)
- {
- meterValueBufferClear(gun_index);
- sendMeterValuesRequest(gun_index, ReadingContextEnumType_Transaction_Begin, FALSE);
- }
- // Message
- json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
- json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
- json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
- json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
- json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
- if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
- json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
- if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
- json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
- if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
- json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
- json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
- json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
- if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
- json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
- if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0) && (strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL))
- json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
- //if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == 2)
- json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
- json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
- {
- json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
- json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
- json_object_object_add(TransactionEvent, "idToken", idToken);
- }
- json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
- json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
- json_object_object_add(TransactionEvent, "evse", evse);
- if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0) && (strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) == NULL))
- {
- for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
- {
- json_object *meterValue = json_object_new_object();
- json_object *sampledValues = json_object_new_array();
- json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
- for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
- {
- if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
- ((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0) ||
- (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) == 0) ||
- (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) == 0) ||
- (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) == 0)))
- {
- if(((strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Started]) != NULL) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, (char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) != NULL)) ||
- ((strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Started]) == NULL)))
- {
- json_object *sampledValue = json_object_new_object();
- json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
- json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
- json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
- json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
- json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
- {
- json_object *unitOfMeasure = json_object_new_object();
- json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
- json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
- json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
- }
- json_object_array_add(sampledValues, sampledValue);
- }
- }
- }
- json_object_object_add(meterValue, "sampledValue", sampledValues);
- json_object_array_add(meterValues, meterValue);
- }
- json_object_object_add(TransactionEvent, "meterValue", meterValues);
- }
- else if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL)
- {
- json_object *meterValues = json_object_new_array();
- meterValueBufferQuery(gun_index, meterValues);
- if(json_object_array_length(meterValues) > 0)
- {
- DEBUG_INFO("parsed meterValue: %s\n", json_object_to_json_string_ext(meterValues, JSON_C_TO_STRING_PLAIN));
- json_object_object_add(TransactionEvent, "meterValue", meterValues);
- }
- }
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
- json_object_put(TransactionEvent);
- sprintf(tempdata, "TransactionEvent,%d", gun_index);
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
- {
- result = PASS;
- }
- queue_operation(QUEUE_OPERATION_ADD, guid, message);
- if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Started]) != NULL)
- {
- OCPP_insert_transaction_msg(YES, message);
- refreshStartTimer(&clientTime.MeterValues[gun_index]);
- }
- else if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL)
- {
- OCPP_insert_transaction_msg(NO, message);
- memset(&ShmOCPP20Data->SessionTarget[gun_index], 0x00, sizeof(struct StructSessionTarget));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
- memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
- }
- return result;
- }
- //==========================================
- // send confirm routine
- //==========================================
- int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *CancelReservation = json_object_new_object();
- DEBUG_INFO("sendCancelReservationConfirmation...\n");
- json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
- json_object_put(CancelReservation);
- ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf = OFF;
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendCertificateSignedConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *CertificateSigned = json_object_new_object();
- json_object *statusInfo = json_object_new_object();
- DEBUG_INFO("sendCertificateSignedConfirmation...\n");
- json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
- if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode) > 0)
- {
- json_object_object_add(statusInfo, "reasonCode", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode));
- if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo) > 0)
- json_object_object_add(statusInfo, "statadditionalInfous", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo));
- }
- json_object_object_add(CertificateSigned, "statusInfo", statusInfo);
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
- json_object_put(CertificateSigned);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *ChangeAvailability = json_object_new_object();
- DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
- json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
- json_object_put(ChangeAvailability);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendClearCacheConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *ClearCache = json_object_new_object();
- DEBUG_INFO("sendClearCacheConfirmation...\n");
- json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
- json_object_put(ClearCache);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendClearChargingProfileConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[500]={0};
- DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
- sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
- LWS_Send(message);
- return result;
- }
- int sendClearDisplayMessageConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *ClearDisplayMessage = json_object_new_object();
- DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
- json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
- json_object_put(ClearDisplayMessage);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *ClearVariableMonitoring = json_object_new_object();
- json_object *clearMonitoringResults = json_object_new_array();
- DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
- for(int idx=0;idx<variableQuantity;idx++)
- {
- json_object *clearMonitoringResult = json_object_new_object();
- json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
- json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
- json_object_array_add(clearMonitoringResults, clearMonitoringResult);
- }
- json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
- json_object_put(ClearVariableMonitoring);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendCostUpdatedConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- DEBUG_INFO("sendCostUpdatedConfirmation...\n");
- sprintf(message,"[%d,\"%s\",{}]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendCustomerInformationConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *CustomerInformation = json_object_new_object();
- DEBUG_INFO("sendCustomerInformationConfirmation...\n");
- json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
- json_object_put(CustomerInformation);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *DataTransfer = json_object_new_object();
- DEBUG_INFO("sendDataTransferConfirmation...\n");
- json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
- json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
- json_object_put(DataTransfer);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendDeleteCertificateConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *DeleteCertificate = json_object_new_object();
- DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
- json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
- json_object_put(DeleteCertificate);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetBaseReportConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *GetBaseReport = json_object_new_object();
- DEBUG_INFO("sendGetBaseReportConfirmation...\n");
- json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetBaseReport);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *GetChargingProfiles = json_object_new_object();
- DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
- json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetChargingProfiles);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int evseIdInt, int nPeriod)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- int CompositeScheduleIndex = 0;
- json_object *GetCompositeSchedule = json_object_new_object();
- json_object *schedule = json_object_new_object();
- json_object *chargingSchedule = json_object_new_object();
- json_object *chargingSchedulePeriod = json_object_new_array();
- DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
- json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
- CompositeScheduleIndex = (evseIdInt > 0) ?(evseIdInt -1) : 0;
- json_object_object_add(schedule, "evseId", json_object_new_int(evseIdInt));
- if(nPeriod == 0)
- {
- if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
- {
- if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
- json_object_object_add(schedule, "scheduleStart", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
- if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
- json_object_object_add(schedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
- json_object_object_add(schedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
- //if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
- //json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
- //json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
- uint8_t isNullSchedulePeriod = TRUE;
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
- {
- if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
- (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
- {
- json_object *Period = json_object_new_object();
- json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
- json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
- if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
- json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
- if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
- json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
- json_object_array_add(chargingSchedulePeriod, Period);
- isNullSchedulePeriod = FALSE;
- }
- }
- if(isNullSchedulePeriod == TRUE)
- {
- json_object *Period = json_object_new_object();
- json_object_object_add(Period, "startPeriod", json_object_new_int(0));
- float limit = ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit[0]=='W'?modelnameInfo.ratedPower:(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent==0?ShmSysConfigAndInfo->SysConfig.RatingCurrent:ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
- json_object_object_add(Period, "limit", json_object_new_double(limit));
- json_object_array_add(chargingSchedulePeriod, Period);
- }
- json_object_object_add(schedule, "chargingSchedulePeriod", chargingSchedulePeriod);
- //json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
- //json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
- json_object_object_add(GetCompositeSchedule, "schedule", schedule);
- }
- }
- else
- {
- if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
- json_object_object_add(chargingSchedule, "scheduleStart", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
- if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
- json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
- json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
- if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
- json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
- //json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
- for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
- {
- if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
- (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
- {
- json_object *Period = json_object_new_object();
- json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
- json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
- if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
- json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
- if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
- json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
- json_object_array_add(chargingSchedulePeriod, Period);
- }
- }
- json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
- //json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
- //json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
- json_object_object_add(GetCompositeSchedule, "schedule", schedule);
- }
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetCompositeSchedule);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetGetDisplayMessagesConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *GetGetDisplayMessages = json_object_new_object();
- DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
- json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetGetDisplayMessages);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *GetInstalledCertificateIds = json_object_new_object();
- json_object *certificateHashDataChains = json_object_new_array();
- DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
- json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
- for(int idx=0;idx<certQuantity;idx++)
- {
- json_object *cert = json_object_new_object();
- json_object *certificateHashData = json_object_new_object();
- json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
- json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
- json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
- json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
- json_object_object_add(cert, "certificateHashData", certificateHashData);
- json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
- json_object_array_add(certificateHashDataChains, cert);
- }
- json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetInstalledCertificateIds);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetLocalListVersionConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *GetLocalListVersion = json_object_new_object();
- DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
- json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetLocalListVersion);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetLogConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *GetLog = json_object_new_object();
- DEBUG_INFO("sendGetLogConfirmation...\n");
- json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
- json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetLog);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetMonitoringReportConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *GetMonitoringReport = json_object_new_object();
- DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
- json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetMonitoringReport);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetReportConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *GetReport = json_object_new_object();
- DEBUG_INFO("sendGetReportConfirmation...\n");
- json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetReport);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetTransactionStatusConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *GetTransactionStatus = json_object_new_object();
- DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
- json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus.Response_ongoingIndicator));
- json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus.Response_messagesInQueue));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetTransactionStatus);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *GetVariables = json_object_new_object();
- json_object *getVariableResults = json_object_new_array();
- DEBUG_INFO("sendGetVariablesConfirmation...\n");
- for(int idx=0;idx<variableQuantity;idx++)
- {
- json_object *variableResult = json_object_new_object();
- json_object *component = json_object_new_object();
- json_object *variable = json_object_new_object();
- json_object *evse = json_object_new_object();
- if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType) > 0)
- json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
- json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
- if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue) > 0)
- json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
- if(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id > 0)
- {
- json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
- json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
- json_object_object_add(component, "evse", evse);
- }
- json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
- if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance) > 0)
- json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
- json_object_object_add(variableResult, "component", component);
- json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
- if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance) > 0)
- json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
- json_object_object_add(variableResult, "variable", variable);
- json_object_array_add(getVariableResults, variableResult);
- }
- json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
- json_object_put(GetVariables);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendInstallCertificateConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *InstallCertificate = json_object_new_object();
- DEBUG_INFO("sendInstallCertificateConfirmation...\n");
- json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
- json_object_put(InstallCertificate);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendPublishFirmwareConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *PublishFirmware = json_object_new_object();
- json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
- DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
- json_object_put(PublishFirmware);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *RemoteStartTransaction = json_object_new_object();
- json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
- if((strstr((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]) != NULL) &&
- (strlen((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId) > 0))
- json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
- DEBUG_INFO("sendRemoteStartConfirmation...\n");
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
- json_object_put(RemoteStartTransaction);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *RemoteStopTransaction = json_object_new_object();
- json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
- DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
- json_object_put(RemoteStopTransaction);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *ReserveNow = json_object_new_object();
- json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
- DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
- json_object_put(ReserveNow);
- LWS_Send(message);
- result = TRUE;
- ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
- return result;
- }
- int sendResetConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *Reset = json_object_new_object();
- DEBUG_INFO("sendResetConfirmation...\n");
- ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
- json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
- json_object_put(Reset);
- LWS_Send(message);
- if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
- {
- DB_updateBootType(BootReasonEnumType_RemoteReset);
- DB_updateSecurityEventType(SecurityEventEnumType_ResetOrReboot);
- }
- else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
- {
- DB_updateBootType(BootReasonEnumType_ScheduledReset);
- DB_updateSecurityEventType(SecurityEventEnumType_ResetOrReboot);
- }
- result = TRUE;
- return result;
- }
- int sendSendLocalListConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *SendLocalList = json_object_new_object();
- DEBUG_INFO("sendSendLocalListConfirmation...\n");
- json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
- json_object_put(SendLocalList);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *SetChargingProfile = json_object_new_object();
- DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
- json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
- json_object_put(SetChargingProfile);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendSetDisplayMessagesConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *SetDisplayMessage = json_object_new_object();
- DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
- json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
- json_object_put(SetDisplayMessage);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendSetMonitoringBaseConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *SetMonitoringBase = json_object_new_object();
- DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
- json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
- json_object_put(SetMonitoringBase);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendSetMonitoringLevelConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *SetMonitoringLevel = json_object_new_object();
- DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
- json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
- json_object_put(SetMonitoringLevel);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendSetNetworkProfileConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *SetNetworkProfile = json_object_new_object();
- DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
- json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
- json_object_put(SetNetworkProfile);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *SetVariableMonitoring = json_object_new_object();
- json_object *setMonitoringResults = json_object_new_array();
- DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
- for(int idx=0;idx<variableQuantity;idx++)
- {
- json_object *variableMonitorResult = json_object_new_object();
- json_object *component = json_object_new_object();
- json_object *variable = json_object_new_object();
- json_object *evse = json_object_new_object();
- json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
- json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
- json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
- json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
- json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
- json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
- json_object_object_add(component, "evse", evse);
- json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
- json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
- json_object_object_add(variableMonitorResult, "component", component);
- json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
- json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
- json_object_object_add(variableMonitorResult, "variable", variable);
- json_object_array_add(setMonitoringResults, variableMonitorResult);
- }
- json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
- json_object_put(SetVariableMonitoring);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *SetVariable = json_object_new_object();
- json_object *setVariableResults = json_object_new_array();
- DEBUG_INFO("sendSetVariableConfirmation...\n");
- for(int idx=0;idx<variableQuantity;idx++)
- {
- json_object *variableResult = json_object_new_object();
- json_object *component = json_object_new_object();
- json_object *variable = json_object_new_object();
- json_object *evse = json_object_new_object();
- json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
- json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
- if(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id > 0)
- {
- json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
- json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
- json_object_object_add(component, "evse", evse);
- }
- json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
- if(strlen((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance) > 0)
- json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
- json_object_object_add(variableResult, "component", component);
- json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
- if(strlen((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance)>0)
- json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
- json_object_object_add(variableResult, "variable", variable);
- json_object_array_add(setVariableResults, variableResult);
- }
- json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
- json_object_put(SetVariable);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendTriggerMessageConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *TriggerMessage = json_object_new_object();
- DEBUG_INFO("sendTriggerMessageConfirmation...\n");
- json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
- sprintf(message,"[%d,\"%s\",%s]",
- MESSAGE_TYPE_CALLRESULT,
- uuid,
- json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
- json_object_put(TriggerMessage);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *UnlockConnector = json_object_new_object();
- DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
- json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
- sprintf(message,"[%d,\"%s\",%s]",
- MESSAGE_TYPE_CALLRESULT,
- uuid,
- json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
- json_object_put(UnlockConnector);
- LWS_Send(message);
- result = TRUE;
- ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
- return result;
- }
- int sendUnpublishFirmwareConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *UnpublishFirmware = json_object_new_object();
- DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
- json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
- json_object_put(UnpublishFirmware);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendUpdateFirmwareConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[4096]={0};
- json_object *UpdateFirmware = json_object_new_object();
- DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
- sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
- json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
- sprintf(message,"[%d,\"%s\",%s]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
- json_object_put(UpdateFirmware);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendUnknownConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[256]={0};
- //[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
- DEBUG_INFO("sendUnknownConfirmation...\n");
- sprintf(message,"[%d,\"%s\",\"NotImplemented\",\"Requested Action is not known by receiver\",{}]", MESSAGE_TYPE_CALLERROR, uuid);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- //==========================================
- // send CallError routine
- //==========================================
- void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
- {
- mtrace();
- char message[220]={0};
- DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
- sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
- LWS_Send(message);
- }
- //==========================================
- // Handle server request routine Start
- //==========================================
- int handleCancelReservationRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int gunNO = 0;
- int reservationIdInt = -1;
- DEBUG_INFO("handleCancelReservationRequest...\n");
- json_object *CancelReservation;
- CancelReservation = json_tokener_parse(payload);
- if(!is_error(CancelReservation))
- {
- // Required data
- if(json_object_object_get(CancelReservation, "reservationId") != NULL)
- reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
- }
- json_object_put(CancelReservation);
- DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
- for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
- sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
- if(reservationIdInt != -1)
- {
- //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
- //check Transaction active
- //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
- {
- sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
- if(gunType[2] == GUN_TYPE_CHAdeMO)
- {
- gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
- }
- else
- {
- gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
- }
- ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
- ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
- sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
- ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
- goto end;
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
- {
- sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
- if(gunType[2] == GUN_TYPE_CCS)
- {
- gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
- }
- else
- {
- gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
- }
- ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
- ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
- sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
- ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
- goto end;
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
- {
- sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
- if(gunType[2] == GUN_TYPE_GBT)
- {
- gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
- }
- else
- {
- gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
- }
- ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
- ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
- sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
- ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
- goto end;
- }
- }
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId == reservationIdInt)
- {
- sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
- gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
- ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
- ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
- sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
- ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
- goto end;
- }
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
- {
- sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
- }
- else
- {
- gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
- }
- ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
- ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
- sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
- ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
- goto end;
- }
- }
- }
- //The reservationId does NOT match the reservationId
- sendCancelReservationConfirmation(uuid, gunNO);
- end:
- // Fill in ocpp packet uuid
- strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
- return result;
- }
- int handleCertificateSignedRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *CertificateSigned;
- DEBUG_INFO("handleCertificateSignedRequest...\n");
- CertificateSigned = json_tokener_parse(payload);
- if(!is_error(CertificateSigned))
- {
- memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
- memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
- // Required data
- sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateChain, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateChain")));
- // Optional data
- if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
- }
- else
- {
- if(strcmp((char*)ShmOCPP20Data->SignCertificate.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]) == 0)
- {
- sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]);
- }
- else if(strcmp((char*)ShmOCPP20Data->SignCertificate.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0)
- {
- sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]);
- }
- }
- if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]) == 0)
- {
- FILE *fp = fopen("/Storage/OCPP/tempCP.pem", "w");
- fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
- fclose(fp);
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- ShmOCPP20Data->MsMsg.bits.CertificateSignedReq = 1;
- if(certVerify(PRIVATE_KEY_CP, "/Storage/OCPP/tempCP.pem") == PASS)
- {
- strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
- system("rm -f /Storage/OCPP/certCP_fallback.pem");
- rename(CERTIFICATE_CP, "/Storage/OCPP/certCP_fallback.pem");
- rename("/Storage/OCPP/tempCP.pem", CERTIFICATE_CP);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->SecurityEventNotification.type, "InvalidChargePointCertificate");
- memset(ShmOCPP20Data->SecurityEventNotification.techInfo, 0x00, ARRAY_SIZE(ShmOCPP20Data->SecurityEventNotification.techInfo));
- ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = 1;
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0)
- {
- FILE *fp = fopen("/Storage/OCPP/tempV2G.pem", "w");
- fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
- fclose(fp);
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- ShmOCPP20Data->MsMsg.bits.CertificateSignedReq = 1;
- if(certVerify(PRIVATE_KEY_V2G, "/Storage/OCPP/tempV2G.pem") == PASS)
- {
- strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
- system("rm -f /Storage/OCPP/certV2G_fallback.pem");
- rename(CERTIFICATE_V2G, "/Storage/OCPP/certV2G_fallback.pem");
- rename("/Storage/OCPP/tempV2G.pem", CERTIFICATE_V2G);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->SecurityEventNotification.type, "InvalidChargePointCertificate");
- memset(ShmOCPP20Data->SecurityEventNotification.techInfo, 0x00, ARRAY_SIZE(ShmOCPP20Data->SecurityEventNotification.techInfo));
- ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = 1;
- }
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
- }
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- }
- else
- strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
- json_object_put(CertificateSigned);
- sendCertificateSignedConfirmation(uuid);
- return result;
- }
- int handleChangeAvailabilityRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int evseId = 0, gunIndex = 0;
- char operationalStatus[16]={0};
- char comfirmstr[20];
- //int specificId = FALSE;
- DEBUG_INFO("handleChangeAvailabilityRequest...\n");
- memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- json_object *ChangeAvailability;
- ChangeAvailability = json_tokener_parse(payload);
- if(!is_error(ChangeAvailability))
- {
- // Required data
- if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
- sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
- // Requested evse. (When omitted, the message refers to the Charging Station as a whole.)
- if(json_object_object_get(ChangeAvailability, "evse") != NULL)
- {
- if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id") != NULL)
- {
- evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
- if(evseId > 0){}
- //specificId = TRUE;
- else
- goto end;
- }
- if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
- {
- gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
- if(gunIndex != 1)
- goto end;
- }
- }
- }
- json_object_put(ChangeAvailability);
- if((evseId != 0) && (evseId <= gunTotalNumber))
- {
- ShmOCPP20Data->ChangeAvailability[evseId-1].evse.id = evseId;
- sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
- }
- else if(evseId == 0)
- {
- for(int i=0; i < gunTotalNumber; i++)
- {
- ShmOCPP20Data->ChangeAvailability[i].evse.id = i+1;
- sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
- }
- }
- /*if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
- {
- ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = 1;
- sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
- }
- else if(gunIndex == 0)
- {
- for(int i=0; i < gunTotalNumber; i++)
- {
- ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = 1;
- sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
- }
- }*/
- if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
- {
- //----------------------evseId is 0 ------------------------------------------------//
- if(evseId == 0)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
- {
- for(int i=0; i < gunTotalNumber; i++)
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((gunType[i] == GUN_TYPE_CHAdeMO)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- }
- }//END FOR CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if ((gunType[i] == GUN_TYPE_CCS)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- }
- }//END FOR CCS_QUANTITY
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- }
- }// END FOR GB_QUANTITY
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i))
- {
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- }
- }// END FOR DO_QUANTITY
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if ((gunType[i] == GUN_TYPE_AC)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- }
- }//END FOR AC_QUANTITY
- }// END FOR gunTotalNumber
- }
- else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
- {
- for(int i=0; i < gunTotalNumber; i++)
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- }
- }
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- //----------------------gunIndex is not 0 ------------------------------------------------//
- //check Transaction active
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((evseId > 0)&&(gunType[evseId-1] == GUN_TYPE_CHAdeMO))
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- else
- {
- DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- }
- }//END FOR CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if ((evseId > 0)&&(gunType[evseId-1] == GUN_TYPE_CCS))
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- else
- {
- DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- }
- }//END FOR CCS_QUANTITY
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if ((evseId > 0)&&(gunType[evseId-1] == GUN_TYPE_GBT))
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- else
- {
- DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- }
- }// END FOR GB_QUANTITY
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if ((evseId > 0)&&(gunType[evseId-1] == GUN_TYPE_DO))
- {
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- else
- {
- DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- }
- }// END FOR DO_QUANTITY
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if ((evseId > 0)&&(gunType[evseId-1] == GUN_TYPE_AC))
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
- goto end;
- }
- else
- {
- DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- }
- }//END FOR AC_QUANTITY
- }//END FOR AvailabilityEnumTypeStr[Inoperative]
- if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
- {
- //----------------------gunIndex is 0 ------------------------------------------------//
- if(evseId == 0)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
- {
- for(int i=0; i < gunTotalNumber; i++)
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- 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
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- }//END FOR CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- 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
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- }//END FOR CCS_QUANTITY
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- 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
- {
- //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- }// END FOR GB_QUANTITY
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- 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
- {
- //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- }// END FOR DO_QUANTITY
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- 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
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- }//END FOR CHAdeMO_QUANTITY
- }// END FOR gunTotalNumber
- }
- else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
- {
- for(int i=0; i < gunTotalNumber; i++)
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- 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
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
- goto end;
- }
- }//END FOR CHAdeMO_QUANTITY
- } // END FOR gunTotalNumber
- }
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- //----------------------gunIndex is not 0 ------------------------------------------------//
- //check Transaction active
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (((evseId > 0)&&(gunType[evseId-1] == GUN_TYPE_CHAdeMO) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- }//END FOR CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if ((((evseId > 0)&&(gunType[evseId-1] == GUN_TYPE_CCS)) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- }//END FOR CCS_QUANTITY
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (((evseId > 0)&&(gunType[evseId-1] == GUN_TYPE_GBT))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- }// END FOR GB_QUANTITY
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if (((evseId > 0)&&(gunType[evseId-1] == GUN_TYPE_DO))&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)) //S_FAULT
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- }// END FOR DO_QUANTITY
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (((evseId > 0)&&(gunType[evseId-1] == GUN_TYPE_AC)) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
- {
- sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
- goto end;
- }
- }//END FOR AC_QUANTITY
- }//END FOR AvailabilityEnumTypeStr[Operative]
- end:
- if((evseId > 0) && (evseId <= gunTotalNumber))
- {
- sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].Response_status, "%s", comfirmstr );
- if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
- ShmOCPP20Data->CsMsg.bits[evseId-1].ChangeAvailabilityReq = ON;
- }
- else if(evseId == 0)
- {
- sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
- if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
- {
- for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
- ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
- }
- }
- else
- {
- sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
- }
- sendChangeAvailabilityConfirmation(uuid, (evseId==0?evseId:evseId-1));
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- return result;
- }
- int handleClearCacheRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- char rmFileCmd[100]={0};
- struct stat stats;
- DEBUG_INFO("handleClearCacheRequest...\n");
- stat("/Storage/OCPP", &stats);
- // Check for directory existence
- if (S_ISDIR(stats.st_mode) == 1)
- {}
- else
- {
- DEBUG_INFO("\n OCPP directory not exist, create dir \n");
- sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
- system(rmFileCmd);
- }
- if(DB_cleanLocalCache() != PASS)
- {
- DEBUG_INFO("open AuthorizationCache file failed\n");
- sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
- }
- else
- {
- DEBUG_INFO("open AuthorizationCache file successful\n");
- sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
- }
- sendClearCacheConfirmation(uuid);
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- return result;
- }
- int handleClearChargingProfileRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int resultRename;
- int evseIdInt, chargingProfileIdInt, stackLevelInt;
- char chargingProfilePurposeStr[26]={0};
- int tempevseIdInt, tempchargingProfileIdInt, tempstackLevelInt;
- char tempchargingProfilePurposeStr[26]={0};
- char sstr[160]={0};
- char str[100]={0};
- int c = 0;
- char *loc;
- char fname[200]={0};
- char comfirmstr[20]={0};
- char word[1600]={0};
- int clearflag = FALSE;
- int chargingProfileIdIsNULL = FALSE;
- int evseIsNULL = FALSE;
- int chargingProfilePurposeIsNULL = FALSE;
- int stackLevelIsNULL = FALSE;
- //int GotoEnd = FALSE;
- FILE *fptr1, *fptr2;
- char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
- int n_chargingProfile=0;
- int isEmptyFile = FALSE;
- char sLineWord[1600]={0};
- char chargingProfiles[10][100]={0};
- int ChargeProfileCount = 0;
- int ch;
- evseIdInt = chargingProfileIdInt = stackLevelInt = 0;
- DEBUG_INFO("handleClearChargingProfileRequest...\n");
- json_object *ClearChargingProfile;
- ClearChargingProfile = json_tokener_parse(payload);
- if(!is_error(ClearChargingProfile))
- {
- // Optional data
- if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
- chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
- else
- chargingProfileIdIsNULL = TRUE;
- if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
- evseIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
- else
- evseIsNULL = TRUE;
- if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
- sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
- else
- chargingProfilePurposeIsNULL = TRUE;
- if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
- stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
- else
- stackLevelIsNULL = TRUE;
- }
- json_object_put(ClearChargingProfile);
- if(evseIsNULL == FALSE)
- {
- switch(evseIdInt)
- {
- case 0:
- if(chargingProfilePurposeIsNULL == TRUE)
- {
- int l = 0;
- strcpy(fname, ChargingStationMaxProfile_JSON);
- if((access(fname,F_OK))!=-1)
- {
- strcpy(chargingProfiles[l], fname);
- l = l + 1;
- }
- strcpy(fname, TxDefaultProfile_0_JSON);
- if((access(fname,F_OK))!=-1)
- {
- strcpy(chargingProfiles[l], fname);
- l = l + 1;
- }
- ChargeProfileCount = l;
- }
- else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
- {
- strcpy(fname, ChargingStationMaxProfile_JSON);
- if((access(fname,F_OK))!=-1)
- {
- strcpy(chargingProfiles[0], fname);
- ChargeProfileCount = 1;
- }
- }
- else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
- {
- strcpy(fname, TxDefaultProfile_0_JSON);
- if((access(fname,F_OK))!=-1)
- {
- strcpy(chargingProfiles[0], fname);
- ChargeProfileCount = 1;
- }
- }
- break;
- default:
- if(chargingProfilePurposeIsNULL == TRUE)
- {
- int m = 0;
- memset(fname, 0, ARRAY_SIZE(fname));
- sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", evseIdInt);
- if((access(fname,F_OK))!=-1)
- {
- strcpy(chargingProfiles[m], fname);
- m = m + 1;
- }
- memset(fname, 0, ARRAY_SIZE(fname));
- sprintf(fname, "/Storage/OCPP/TxProfile_%d_OCPP20.json", evseIdInt);
- if((access(fname,F_OK))!=-1)
- {
- strcpy(chargingProfiles[m], fname);
- m = m + 1;
- }
- ChargeProfileCount = m;
- }
- else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
- {
- //strcpy(fname, TxDefaultProfile_1_JSON);
- sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", evseIdInt);
- if((access(fname,F_OK))!=-1)
- {
- strcpy(chargingProfiles[0], fname);
- ChargeProfileCount = 1;
- }
- }
- else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
- {
- sprintf(fname, "/Storage/OCPP/TxProfile_%d_OCPP20.json", evseIdInt);
- if((access(fname,F_OK))!=-1)
- {
- strcpy(chargingProfiles[0], fname);
- ChargeProfileCount = 1;
- }
- }
- //strcpy(fname, ChargePointMaxProfile_JSON );
- break;
- }
- }
- else // Check all Charging Profiles
- {
- int i = 0;
- char fnametemp[200]={0};
- ChargeProfileCount = 0;
- //Check ChargePointMaxProfile.json exit
- if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
- {
- strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
- i = i + 1;
- }
- //Check TxDefaultProfile_%d.json
- for(int j=1; j <= gunTotalNumber; j++)
- {
- memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
- sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", j);
- if((access(fnametemp,F_OK))!=-1)
- {
- strcpy(chargingProfiles[i], fnametemp);
- i = i + 1;
- }
- }
- //Check TxProfile_%d.json
- for(int j=1; j <= gunTotalNumber; j++)
- {
- memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
- sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d_OCPP20.json", j);
- if((access(fnametemp,F_OK))!=-1)
- {
- strcpy(chargingProfiles[i], fnametemp);
- i = i + 1;
- }
- }
- ChargeProfileCount = i;
- }// End connectorIsNULL is TRUE
- if(ChargeProfileCount == 0)
- {
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
- goto end;
- }
- if(evseIsNULL == FALSE && (evseIdInt != 0) && ( (evseIdInt-1) > gunTotalNumber) )
- {
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
- goto end;
- }
- if((evseIsNULL == FALSE) && (evseIdInt == 0) )
- {
- memset(str, 0, ARRAY_SIZE(str));
- // clear temp file
- sprintf(str,"rm -f %s",temp);
- system(str);
- for(int k=0; k < ChargeProfileCount; k++)
- {
- memset(str, 0, ARRAY_SIZE(str));
- //clear file in C
- sprintf(str,"rm -f %s",chargingProfiles[k]);
- system(str);
- }
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
- goto end;
- }
- else if(evseIsNULL == TRUE)
- {
- for(int k=0; k < ChargeProfileCount; k++)
- {
- fptr1 = fopen(chargingProfiles[k], "r");
- fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
- //Check Charging Profile Count
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- //DEBUG_INFO("word=%s\n",word);
- if(strstr(word, "id")!= NULL)
- {
- //DEBUG_INFO("test id \n");
- n_chargingProfile = n_chargingProfile + 1;
- //DEBUG_INFO("id Found\n");
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- //int i= 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
- {
- //------------------------tempconnectorIdInt------------------------//
- loc = strstr(sLineWord, "evseId");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("evseId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("evseId")+2+c];
- c++;
- }
- sstr[c] = '\0';
- tempevseIdInt = atoi(sstr);
- printf("file's gun number is %d\n", tempevseIdInt);
- //--------------------------id--------------------//
- c = 0;
- loc = strstr(sLineWord, "id");
- memset(sstr ,0, ARRAY_SIZE(sstr));
- while (loc[strlen("id")+2+c] != ',')
- {
- sstr[c] = loc[strlen("id")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempchargingProfileIdInt = atoi(sstr);
- //stackLevel
- c = 0;
- loc = strstr(sLineWord, "stackLevel");
- memset(sstr ,0, ARRAY_SIZE(sstr));
- while (loc[strlen("stackLevel")+2+c] != ',')
- {
- sstr[c] = loc[strlen("stackLevel")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempstackLevelInt = atoi(sstr);
- c = 0;
- loc = strstr(sLineWord, "chargingProfilePurpose");
- memset(sstr ,0, ARRAY_SIZE(sstr));
- while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingProfilePurposeStr, sstr);
- if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
- {
- //------- not write to fptr2-------//
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
- //clearflag = TRUE;
- }
- else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
- {
- //------- not write to fptr2-------//
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
- }
- else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
- {
- //------- not write to fptr2-------//
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
- }
- else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
- {
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
- }
- else
- {
- fprintf(fptr2, sLineWord);//writing data into file
- }
- memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
- } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
- if(clearflag == TRUE)
- {
- fclose(fptr1);
- fclose(fptr2);
- sprintf(str,"rm -f %s",chargingProfiles[k]);
- system(str);
- // clear temp file
- sprintf(str,"rm -f %s",temp);
- system(str);
- }
- else
- {
- fclose(fptr1);
- fclose(fptr2);
- memset(str, 0, ARRAY_SIZE(str));
- sprintf(str,"rm -f %s",chargingProfiles[k]);
- system(str);
- resultRename = rename(temp, chargingProfiles[k]);
- if(resultRename == 0)
- {
- DEBUG_INFO("File ChargingProfile renamed successfully\n");
- }
- else
- {
- DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
- }
- if(comfirmstr[0]== 0)
- {
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
- }
- //Check chargingProfile is empty file
- /*------ Read the file ----------------*/
- fptr1=fopen(chargingProfiles[k],"r");
- ch=fgetc(fptr1);
- rewind(fptr1);
- memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
- if(ch!=EOF)
- {
- while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
- {
- str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
- if(sLineWord[0]=='\0')
- {
- isEmptyFile = TRUE;
- break;
- }
- else
- {
- isEmptyFile = FALSE;
- break;
- }
- }
- }
- else
- isEmptyFile = TRUE;
- fclose(fptr1);
- if(isEmptyFile == TRUE)
- {
- memset(str, 0, ARRAY_SIZE(str));
- sprintf(str,"rm -f %s",chargingProfiles[k]);
- system(str);
- }
- }
- }// End of while(int k=0; k < ChargePointCount; k++)
- }
- else if((evseIsNULL == FALSE) && (evseIdInt != 0) )
- {
- DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
- for(int k=0; k < ChargeProfileCount; k++)
- {
- fptr1 = fopen(chargingProfiles[k], "r");
- fptr2 = fopen(temp, "w+");
- //Check Charging Profile Count
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- //DEBUG_INFO("word=%s\n",word);
- if(strstr(word, "id")!= NULL)
- {
- n_chargingProfile = n_chargingProfile + 1;
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- //int i= 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
- {
- //*************************tempevseIdInt*********************************/
- loc = strstr(sLineWord, "evseId");
- c = 0;
- memset(sstr ,0, ARRAY_SIZE(sstr));
- while (loc[strlen("evseId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("evseId")+2+c];
- c++;
- }
- sstr[c] = '\0';
- tempevseIdInt = atoi(sstr);
- //id
- c = 0;
- loc = strstr(sLineWord, "id");
- memset(sstr ,0, ARRAY_SIZE(sstr));
- while (loc[strlen("id")+2+c] != ',')
- {
- sstr[c] = loc[strlen("id")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempchargingProfileIdInt = atoi(sstr);
- //stackLevel
- c = 0;
- loc = strstr(sLineWord, "stackLevel");
- memset(sstr ,0, ARRAY_SIZE(sstr));
- while (loc[strlen("stackLevel")+2+c] != ',')
- {
- sstr[c] = loc[strlen("stackLevel")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempstackLevelInt = atoi(sstr);
- c = 0;
- loc = strstr(sLineWord, "chargingProfilePurpose");
- memset(sstr ,0, ARRAY_SIZE(sstr));
- while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingProfilePurposeStr, sstr);
- if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
- {
- //------- not write to fptr2-------//
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
- //clearflag = TRUE;
- }
- else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
- {
- //------- not write to fptr2-------//
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
- }
- else if(stackLevelIsNULL == TRUE)
- {
- //Clear Whole File
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
- clearflag = TRUE;
- break;
- }
- else
- {
- fprintf(fptr2, sLineWord);//writing data into file
- }
- memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
- }
- if(clearflag == TRUE)
- {
- fclose(fptr1);
- fclose(fptr2);
- sprintf(str,"rm -f %s",chargingProfiles[k]);
- system(str);
- // clear temp file
- sprintf(str,"rm -f %s",temp);
- system(str);
- }
- else
- {
- fclose(fptr1);
- fclose(fptr2);
- sprintf(str,"rm -f %s",chargingProfiles[k]);
- system(str);
- resultRename = rename(temp, chargingProfiles[k]);
- if(resultRename == 0)
- {
- DEBUG_INFO("File ChargingProfile renamed successfully");
- }
- else
- {
- DEBUG_INFO("Error: unable to rename the ChargingProfile file");
- }
- if(comfirmstr[0]== 0)
- {
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
- }
- //Check chargingProfile is empty file
- /*------ Read the file ----------------*/
- fptr1=fopen(chargingProfiles[k],"r");
- ch=fgetc(fptr1);
- rewind(fptr1);
- memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
- if(ch!=EOF)
- {
- while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
- {
- str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
- if(sLineWord[0]=='\0')
- {
- isEmptyFile = TRUE;
- break;
- }
- else
- {
- isEmptyFile = FALSE;
- break;
- }
- }
- }
- else
- isEmptyFile = TRUE;
- fclose(fptr1);
- if(isEmptyFile == TRUE)
- {
- memset(str, 0, ARRAY_SIZE(str));
- sprintf(str,"rm -f %s",chargingProfiles[k]);
- system(str);
- }
- /*------- End of reading ---------------*/
- }
- } // while(int k=0; k < ChargeProfileCount; k++)
- }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
- end:
- if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
- {
- if(evseIdInt == 0)
- {
- for(uint8_t idx=0;idx<gunTotalNumber;idx++)
- {
- checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
- checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
- }
- }
- else
- {
- checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
- checkCompositeSchedule(evseIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[evseIdInt-1], 0, TRUE);
- }
- }
- sendClearChargingProfileConfirmation(uuid, comfirmstr);
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- return result;
- }
- int handleClearDisplayMessageRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *ClearDisplayMessage;
- DEBUG_INFO("handleClearDisplayMessageRequest...\n");
- sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
- ClearDisplayMessage = json_tokener_parse(payload);
- if(!is_error(ClearDisplayMessage))
- {
- // Required data
- if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
- {
- ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
- sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
- }
- }
- json_object_put(ClearDisplayMessage);
- sendCostUpdatedConfirmation(uuid);
- return result;
- }
- int handleClearVariableMonitoringRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int isSpecificIdfound = FALSE;
- char sqlCmd[128];
- char *errMsg = 0;
- json_object *ClearVariableMonitoring;
- DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
- ClearVariableMonitoring = json_tokener_parse(payload);
- if(!is_error(ClearVariableMonitoring))
- {
- // Required data
- if(json_object_array_length(json_object_object_get(ClearVariableMonitoring, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
- {
- for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitoring, "id"));idx++)
- {
- ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitoring, "id"), idx));
- ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
- isSpecificIdfound = FALSE;
- for(uint8_t idx_vm=0;idx_vm<10;idx_vm++)
- {
- if(ShmOCPP20Data->MonitoringComponentVariable[idx_vm].id == ShmOCPP20Data->ClearVariableMonitoring.id[idx])
- {
- isSpecificIdfound = TRUE;
- sprintf(sqlCmd, "delete from ocpp20_variable_monitoring where id=%d", ShmOCPP20Data->ClearVariableMonitoring.id[idx]);
- if (sqlite3_exec(db, sqlCmd, 0, 0, &errMsg) != SQLITE_OK)
- {
- DEBUG_INFO("SQL error: %s\n",errMsg);
- }
- }
- }
- if(isSpecificIdfound == TRUE)
- {
- strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_NotFound]);
- }
- }
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- for(uint8_t idx_vm=0;idx_vm<10;idx_vm++)
- {
- memset(&ShmOCPP20Data->MonitoringComponentVariable, 0x00, sizeof(struct SetMonitoringDataType));
- }
- DB_variableMonitoringLoadFromDb();
- sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitoring, "id")));
- }
- }
- json_object_put(ClearVariableMonitoring);
- return result;
- }
- int handleCostUpdatedRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *CostUpdate;
- DEBUG_INFO("handleCostUpdatedRequest...\n");
- CostUpdate = json_tokener_parse(payload);
- if(!is_error(CostUpdate))
- {
- // Required data
- if(json_object_object_get(CostUpdate, "totalCost") != NULL)
- {
- ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
- }
- if(json_object_object_get(CostUpdate, "transactionId") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
- }
- }
- json_object_put(CostUpdate);
- sendCostUpdatedConfirmation(uuid);
- return result;
- }
- int handleCustomerInformationRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *CustomerInformation;
- DEBUG_INFO("handleCustomerInformationRequest...\n");
- CustomerInformation = json_tokener_parse(payload);
- if(!is_error(CustomerInformation))
- {
- // Required data
- if(json_object_object_get(CustomerInformation, "requestId") != NULL)
- {
- ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
- }
- if(json_object_object_get(CustomerInformation, "report") != NULL)
- {
- ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
- }
- if(json_object_object_get(CustomerInformation, "clear") != NULL)
- {
- ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
- }
- // Optional data
- if(json_object_object_get(CustomerInformation, "idToken") != NULL)
- {
- if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
- }
- if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
- }
- }
- if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
- {
- if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
- }
- if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
- }
- if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
- }
- if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
- }
- }
- strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
- ShmOCPP20Data->SpMsg.bits.NotifyCustomerInformationReq = ON;
- }
- else
- strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
- json_object_put(CustomerInformation);
- sendCustomerInformationConfirmation(uuid);
- return result;
- }
- void createFirmwareVersionByDataTransfer(void)
- {
- json_object *FirmwareDataTransfer = json_object_new_object();
- // AC & DC model
- json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
- json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
- json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
- json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
- // DC model
- if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
- {
- if((gunType[1] != GUN_TYPE_UNKNOWN) ||
- (gunType[2] != GUN_TYPE_UNKNOWN) ||
- (gunType[3] != GUN_TYPE_UNKNOWN))
- {
- json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
- }
- if((ShmSysConfigAndInfo->SysConfig.ModelName[1]!='B') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='K') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='L') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='Z'))
- {
- // DS DM DW
- json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
- json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
- json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
- json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
- json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
- json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
- }
- else
- {
- json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
- json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
- json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
- json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
- json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
- json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
- json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
- json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
- json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
- json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
- json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
- json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
- json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
- if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
- json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
- if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
- json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
- if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
- json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
- if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
- json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
- if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
- json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
- if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
- json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
- if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
- json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
- if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
- json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
- if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
- json_object_object_add(FirmwareDataTransfer, "D11_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
- }
- }
- // 4G model
- if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
- {
- json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
- }
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
- json_object_put(FirmwareDataTransfer);
- }
- int handleDataTransferRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = PASS;
- DEBUG_INFO("handleDataTransferRequest...\n");
- if((uuid != NULL) && (payload != NULL))
- {
- json_object *DataTransfer;
- DataTransfer = json_tokener_parse(payload);
- if(!is_error(DataTransfer))
- {
- // Required data
- if(json_object_object_get(DataTransfer, "vendorId") != NULL)
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
- // Optional data
- if(json_object_object_get(DataTransfer, "messageId") != NULL)
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
- if(json_object_object_get(DataTransfer, "data") != NULL)
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
- result = PASS;
- }
- json_object_put(DataTransfer);
- if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
- {
- // Send all moudle firmware version on EVSE
- createFirmwareVersionByDataTransfer();
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
- }
- else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
- {
- system("/usr/bin/run_tmate_restart.sh &");
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
- }
- else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_ChargingPreference") != NULL)
- {
- json_object *data;
- data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
- if(!is_error(data))
- {
- if((json_object_object_get(data, "ConnectorId") != NULL) && (json_object_get_int(json_object_object_get(data, "ConnectorId")) > 0) && (json_object_get_int(json_object_object_get(data, "ConnectorId")) <= gunTotalNumber))
- {
- DEBUG_INFO("ChargeingPreference connector id: %d\n", json_object_get_int(json_object_object_get(data, "ConnectorId")));
- memset(&ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))], 0x00, sizeof(struct StructSessionTarget));
- if(json_object_object_get(data, "SOC") != NULL)
- {
- ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetSoc = json_object_get_int(json_object_object_get(data, "SOC"));
- DEBUG_INFO("ChargeingPreference target soc: %d\n", json_object_get_int(json_object_object_get(data, "SOC")));
- }
- if(json_object_object_get(data, "Energy") != NULL)
- {
- ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetEnergy = json_object_get_int(json_object_object_get(data, "Energy"));
- DEBUG_INFO("ChargeingPreference target energy: %d KWH\n", json_object_get_int(json_object_object_get(data, "Energy")));
- }
- if(json_object_object_get(data, "Duration") != NULL)
- {
- ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetDuration = json_object_get_int(json_object_object_get(data, "Duration"));
- DEBUG_INFO("ChargeingPreference target duration: %d minutes\n", json_object_get_int(json_object_object_get(data, "Duration")));
- }
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Connector id must > 0.");
- }
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- json_object_put(data);
- }
- else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
- {
- json_object *data;
- data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
- if(!is_error(data))
- {
- ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
- ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
- ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
- ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
- ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
- ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
- ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
- ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
- ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
- ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- json_object_put(data);
- }
- else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_ConfigQR") != NULL)
- {
- json_object *data;
- data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
- if(!is_error(data))
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
- if(json_object_object_get(data, "Content_Type") != NULL)
- {
- 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))
- {
- ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode = json_object_get_int(json_object_object_get(data, "Content_Type"));
- if(json_object_object_get(data, "Customization_Conent") != NULL)
- {
- sprintf((char*)ShmSysConfigAndInfo->SysConfig.QRCodeContent, "%s", json_object_get_string(json_object_object_get(data, "Customization_Conent")));
- }
- }
- else
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- }
- StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- json_object_put(data);
- }
- else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_DisplayLcdPage") != NULL)
- {
- json_object *data;
- data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
- if(!is_error(data))
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
- if(json_object_object_get(data, "ConnectorId") != NULL)
- {
- ShmSysConfigAndInfo->SysInfo.LcdOveride.connectorId = json_object_get_int(json_object_object_get(data, "ConnectorId"));
- }
- if(json_object_object_get(data, "Page_Index") != NULL)
- {
- ShmSysConfigAndInfo->SysInfo.LcdOveride.page_index = json_object_get_int(json_object_object_get(data, "Page_Index"));
- }
- if(json_object_object_get(data, "Duration") != NULL)
- {
- ShmSysConfigAndInfo->SysInfo.LcdOveride.duration = json_object_get_int(json_object_object_get(data, "Duration"));
- }
- ShmSysConfigAndInfo->SysInfo.LcdOveride.isOverideReq = ON;
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- json_object_put(data);
- }
- else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_CpConfiguration") != NULL)
- {
- json_object *data;
- data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
- if(!is_error(data))
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, " ");
- if(json_object_object_get(data, "MaxChargingCurrent") != NULL)
- {
- if(json_object_get_int(json_object_object_get(data, "MaxChargingCurrent")) >= 0)
- ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent = json_object_get_int(json_object_object_get(data, "MaxChargingCurrent"));
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- }
- if(json_object_object_get(data, "MaxChargingDuration") != NULL)
- {
- if(json_object_get_int(json_object_object_get(data, "MaxChargingDuration")) >= 0)
- ShmSysConfigAndInfo->SysConfig.MaxChargingDuration = json_object_get_int(json_object_object_get(data, "MaxChargingDuration"));
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- }
- if(json_object_object_get(data, "MaxChargingEnergy") != NULL)
- {
- if(json_object_get_int(json_object_object_get(data, "MaxChargingEnergy")) >= 0)
- ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy = json_object_get_int(json_object_object_get(data, "MaxChargingEnergy"));
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- }
- if(json_object_object_get(data, "MaxChargingPower") != NULL)
- {
- if(json_object_get_int(json_object_object_get(data, "MaxChargingPower")) >= 0)
- ShmSysConfigAndInfo->SysConfig.MaxChargingPower = json_object_get_int(json_object_object_get(data, "MaxChargingPower"));
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- }
- if(json_object_object_get(data, "OfflineMaxChargeEnergy") != NULL)
- {
- if(json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy")) >= 0)
- ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy"));
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- }
- if(json_object_object_get(data, "OfflinePolicy") != NULL)
- {
- if((json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 0) ||
- (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 2) ||
- (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 3))
- ShmSysConfigAndInfo->SysConfig.OfflinePolicy = json_object_get_int(json_object_object_get(data, "OfflinePolicy"));
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- }
- if(json_object_object_get(data, "isAuthentication") != NULL)
- {
- switch(json_object_get_int(json_object_object_get(data, "isAuthentication")))
- {
- case 0:
- case 1:
- ShmSysConfigAndInfo->SysConfig.AuthorisationMode = json_object_get_int(json_object_object_get(data, "isAuthentication"))^1;
- break;
- default:
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- break;
- }
- }
- if(strstr((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]) != NULL)
- StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
- }
- json_object_put(data);
- }
- else
- {
- // Can not find valid message id
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
- sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
- ,ShmOCPP20Data->DataTransfer[0].vendorId
- ,ShmOCPP20Data->DataTransfer[0].messageId
- ,ShmOCPP20Data->DataTransfer[0].data);
- }
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
- result = FAIL;
- }
- sendDataTransferConfirmation(uuid, 0);
- return result;
- }
- int handleDeleteCertificateRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *DeleteCertificate;
- DEBUG_INFO("handleDeleteCertificateRequest...\n");
- DeleteCertificate = json_tokener_parse(payload);
- if(!is_error(DeleteCertificate))
- {
- memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
- memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
- sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
- sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
- sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
- sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
- DEBUG_INFO("hashAlgorithm: %s\n", ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm);
- DEBUG_INFO("issuerNameHash: %s\n", ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash);
- DEBUG_INFO("issuerKeyHash: %s\n", ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash);
- DEBUG_INFO("serialNumber: %s\n", ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber);
- for(int i = 0; ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash[i]; i++)
- {
- ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash[i] = tolower(ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash[i]);
- }
- for(int i = 0; ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash[i]; i++)
- {
- ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash[i] = tolower(ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash[i]);
- }
- for(int i = 0; ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber[i]; i++)
- {
- ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber[i] = tolower(ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber[i]);
- }
- char temp[256] = {0};
- char compareData[256] = {0};
- int isMatch = TRUE;
- // Check CentralSystemRootCertificate
- if(access(ROOTCA_CS,F_OK) != -1)
- {
- DEBUG_INFO("Checking CentralSystemRootCertificate...\n");
- parseCertInfo(ROOTCA_CS, CERT_PARSE_SerialNumber, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strcmp(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber) != 0)
- isMatch = FALSE;
- if(isMatch == TRUE)
- {
- parseCertInfo(ROOTCA_CS, CERT_PARSE_IssuerNameHash, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strstr(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash) == NULL)
- isMatch = FALSE;
- }
- if(isMatch == TRUE)
- {
- parseCertInfo(ROOTCA_CS, CERT_PARSE_IssuerKeyHash, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strstr(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash) == NULL)
- isMatch = FALSE;
- }
- if(isMatch == TRUE)
- {
- DEBUG_INFO("Deleting CentralSystemRootCertificate...\n");
- sprintf(temp, "rm -f %s", ROOTCA_CS);
- system(temp);
- sprintf((char*)ShmOCPP20Data->DeleteCertificate.Response_status, "Accepted");
- goto End;
- }
- }
- // Check ManufacturerRootCertificate
- if(access(ROOTCA_MF,F_OK) != -1)
- {
- DEBUG_INFO("Checking ManufacturerRootCertificate...\n");
- isMatch = TRUE;
- parseCertInfo(ROOTCA_MF, CERT_PARSE_SerialNumber, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strcmp(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber) != 0)
- isMatch = FALSE;
- if(isMatch == TRUE)
- {
- parseCertInfo(ROOTCA_MF, CERT_PARSE_IssuerNameHash, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strstr(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash) == NULL)
- isMatch = FALSE;
- }
- if(isMatch == TRUE)
- {
- parseCertInfo(ROOTCA_MF, CERT_PARSE_IssuerKeyHash, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strstr(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash) == NULL)
- isMatch = FALSE;
- }
- if(isMatch == TRUE)
- {
- DEBUG_INFO("Deleting ManufacturerRootCertificate...\n");
- sprintf(temp, "rm -f %s", ROOTCA_MF);
- system(temp);
- sprintf((char*)ShmOCPP20Data->DeleteCertificate.Response_status, "Accepted");
- goto End;
- }
- }
- if(access(ROOTCA_V2G,F_OK) != -1)
- {
- DEBUG_INFO("Checking V2GRootCertificate...\n");
- isMatch = TRUE;
- parseCertInfo(ROOTCA_V2G, CERT_PARSE_SerialNumber, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strcmp(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber) != 0)
- isMatch = FALSE;
- if(isMatch == TRUE)
- {
- parseCertInfo(ROOTCA_V2G, CERT_PARSE_IssuerNameHash, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strstr(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash) == NULL)
- isMatch = FALSE;
- }
- if(isMatch == TRUE)
- {
- parseCertInfo(ROOTCA_V2G, CERT_PARSE_IssuerKeyHash, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strstr(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash) == NULL)
- isMatch = FALSE;
- }
- if(isMatch == TRUE)
- {
- DEBUG_INFO("Deleting V2GRootCertificate...\n");
- sprintf(temp, "rm -f %s", ROOTCA_V2G);
- system(temp);
- sprintf((char*)ShmOCPP20Data->DeleteCertificate.Response_status, "Accepted");
- goto End;
- }
- }
- if(access(ROOTCA_MO,F_OK) != -1)
- {
- DEBUG_INFO("Checking MORootCertificate...\n");
- isMatch = TRUE;
- parseCertInfo(ROOTCA_MO, CERT_PARSE_SerialNumber, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strcmp(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber) != 0)
- isMatch = FALSE;
- if(isMatch == TRUE)
- {
- parseCertInfo(ROOTCA_MO, CERT_PARSE_IssuerNameHash, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strstr(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash) == NULL)
- isMatch = FALSE;
- }
- if(isMatch == TRUE)
- {
- parseCertInfo(ROOTCA_MO, CERT_PARSE_IssuerKeyHash, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strstr(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash) == NULL)
- isMatch = FALSE;
- }
- if(isMatch == TRUE)
- {
- DEBUG_INFO("Deleting MORootCertificate...\n");
- sprintf(temp, "rm -f %s", ROOTCA_MO);
- system(temp);
- sprintf((char*)ShmOCPP20Data->DeleteCertificate.Response_status, "Accepted");
- goto End;
- }
- }
- // Check certCP
- if(access(CERTIFICATE_CP,F_OK) != -1)
- {
- DEBUG_INFO("Checking certCP...\n");
- isMatch = TRUE;
- parseCertInfo(CERTIFICATE_CP, CERT_PARSE_SerialNumber, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strcmp(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber) != 0)
- isMatch = FALSE;
- if(isMatch == TRUE)
- {
- parseCertInfo(CERTIFICATE_CP, CERT_PARSE_IssuerNameHash, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strstr(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash) == NULL)
- isMatch = FALSE;
- }
- if(isMatch == TRUE)
- {
- parseCertInfo(CERTIFICATE_CP, CERT_PARSE_IssuerKeyHash, compareData);
- for(int i = 0; compareData[i]; i++)
- {
- compareData[i] = tolower(compareData[i]);
- }
- if(strstr(compareData, (char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash) == NULL)
- isMatch = FALSE;
- }
- if(isMatch == TRUE)
- {
- DEBUG_INFO("Deleting certCP...\n");
- sprintf(temp, "rm -f %s", CERTIFICATE_CP);
- system(temp);
- sprintf((char*)ShmOCPP20Data->DeleteCertificate.Response_status, "Accepted");
- goto End;
- }
- }
- }
- else
- strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
- End:
- json_object_put(DeleteCertificate);
- ShmOCPP20Data->MsMsg.bits.DeleteCertificateReq = 1;
- sendDeleteCertificateConfirmation(uuid);
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- return result;
- }
- int handleGetBaseReportRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *GetBaseRepor;
- DEBUG_INFO("handleGetBaseReportRequest...\n");
- GetBaseRepor = json_tokener_parse(payload);
- if(!is_error(GetBaseRepor))
- {
- memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
- memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
- // Required data
- if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
- {
- ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
- }
- if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
- }
- if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_SummaryInventory]) == 0)
- strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
- else
- strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- }
- else
- strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
- json_object_put(GetBaseRepor);
- sendGetBaseReportConfirmation(uuid);
- return result;
- }
- int handleGetChargingProfilesRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int gun_index = -1;
- json_object *GetChargingProfiles;
- DEBUG_INFO("handleGetChargingProfilesRequest...\n");
- GetChargingProfiles = json_tokener_parse(payload);
- if(!is_error(GetChargingProfiles))
- {
- if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
- {
- 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;
- }
- if(gun_index >-1)
- {
- memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
- memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
- // Required data
- if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
- {
- ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
- }
- if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
- {
- if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
- }
- if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
- {
- ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
- }
- if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
- {
- for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
- {
- 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)));
- }
- }
- if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
- {
- for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
- {
- 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));
- }
- }
- }
- strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
- }
- else
- strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
- }
- json_object_put(GetChargingProfiles);
- sendGetChargingProfilesConfirmation(uuid, gun_index);
- return result;
- }
- int handleGetCompositeScheduleRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int evseIdInt, durationInt;
- char chargingRateUnitStr[4]={0};
- char comfirmstr[20];
- int confirmPeriods = 0;
- DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
- json_object *GetCompositeSchedule;
- GetCompositeSchedule = json_tokener_parse(payload);
- if(!is_error(GetCompositeSchedule))
- {
- // Required data
- if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
- evseIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
- else
- evseIdInt = -1;
- if(json_object_object_get(GetCompositeSchedule, "duration"))
- durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
- else
- durationInt = 86400;
- // Optional data
- if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
- sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
- }
- json_object_put(GetCompositeSchedule);
- memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
- if((evseIdInt == 0) ||
- ((evseIdInt > 0) && ((evseIdInt -1) < gunTotalNumber)))
- {
- int gun_index = (evseIdInt==0?0:evseIdInt-1);
- struct ChargingProfileType tmpProfile[1];
- memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
- memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
- if(strstr(chargingRateUnitStr, "W") != NULL || strlen(chargingRateUnitStr) == 0)
- {
- sprintf((char*)ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingRateUnit, "W");
- checkChargingStationMaxProfile(durationInt, &tmpProfile[0], 0, FALSE);
- checkCompositeSchedule(evseIdInt, durationInt, &tmpProfile[0], 0, FALSE);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingRateUnit, "A");
- checkChargingStationMaxProfile(durationInt, &tmpProfile[0], 0, TRUE);
- checkCompositeSchedule(evseIdInt, durationInt, &tmpProfile[0], 0, TRUE);
- }
- for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
- {
- DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
- DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
- }
- memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct ChargingScheduleType));
- strcpy((char *)ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.startDateTime, (char *)tmpProfile[0].chargingSchedule[0].startSchedule);
- for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
- {
- DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
- DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
- if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
- (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0) &&
- (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))
- {
- confirmPeriods = idx;
- break;
- }
- }
- if((confirmPeriods == 0) && (tmpProfile[0].id > 0))
- {
- confirmPeriods += 1;
- }
- sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
- }
- else
- {
- sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
- }
- sendGetCompositeScheduleConfirmation(uuid, comfirmstr, evseIdInt, confirmPeriods);
- return result;
- }
- int handleGetDisplayMessagesRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *GetDisplayMessages;
- DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
- GetDisplayMessages = json_tokener_parse(payload);
- if(!is_error(GetDisplayMessages))
- {
- memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
- memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
- // Required data
- if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
- {
- ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
- }
- // Optional data
- if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
- }
- if(json_object_object_get(GetDisplayMessages, "state") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
- }
- if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
- {
- for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
- {
- ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
- }
- strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
- ShmOCPP20Data->MsMsg.bits.GetDisplayMessagesReq = ON;
- }
- else
- strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
- }
- json_object_put(GetDisplayMessages);
- return result;
- }
- int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int certCnt = 0;
- unsigned char foundCertCnt = 0;
- json_object *GetInstalledCertificateIds;
- DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
- GetInstalledCertificateIds = json_tokener_parse(payload);
- if(!is_error(GetInstalledCertificateIds))
- {
- memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
- memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
- strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
- // Optional data
- if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
- {
- for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
- {
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
- DEBUG_INFO("Requested Certificate: %s\n", (char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx]);
- //sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, "Accepted");
- DEBUG_INFO("Access ROOTCA_CS result: %d\n", access(ROOTCA_CS,F_OK));
- // Check CSMSRootCertificate
- if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "CSMSRootCertificate")!= NULL)
- {
- if(access(ROOTCA_CS,F_OK) != -1)
- {
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateType, "CSMSRootCertificate");
- char parseData[512] = {0};
- if(parseCertInfo(ROOTCA_CS, CERT_PARSE_HashAlgorithm, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.hashAlgorithm, parseData);
- if(parseCertInfo(ROOTCA_CS, CERT_PARSE_SerialNumber, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.serialNumber, parseData);
- if(parseCertInfo(ROOTCA_CS, CERT_PARSE_IssuerNameHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.issuerNameHash, parseData);
- if(parseCertInfo(ROOTCA_CS, CERT_PARSE_IssuerKeyHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.issuerKeyHash, parseData);
- certCnt++;
- strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
- }
- else
- {
- DEBUG_INFO(">>> No CentralSystemRootCertificate was found.\n");
- //sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, "NotFound");
- }
- }
- // Check ManufacturerRootCertificate
- else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "ManufacturerRootCertificate") != NULL)
- {
- if(access(ROOTCA_MF,F_OK) != -1)
- {
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateType, "ManufacturerRootCertificate");
- char parseData[512] = {0};
- if(parseCertInfo(ROOTCA_MF, CERT_PARSE_HashAlgorithm, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.hashAlgorithm, parseData);
- if(parseCertInfo(ROOTCA_MF, CERT_PARSE_SerialNumber, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.serialNumber, parseData);
- if(parseCertInfo(ROOTCA_MF, CERT_PARSE_IssuerNameHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.issuerNameHash, parseData);
- if(parseCertInfo(ROOTCA_MF, CERT_PARSE_IssuerKeyHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.issuerKeyHash, parseData);
- certCnt++;
- strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
- }
- else
- {
- DEBUG_INFO(">>> No ManufacturerRootCertificate was found.\n");
- //sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, "NotFound");
- }
- }
- // Check MORootCertificate
- else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "MORootCertificate") != NULL)
- {
- if(access(ROOTCA_MO,F_OK) != -1)
- {
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateType, "MORootCertificate");
- char parseData[512] = {0};
- if(parseCertInfo(ROOTCA_MO, CERT_PARSE_HashAlgorithm, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.hashAlgorithm, parseData);
- if(parseCertInfo(ROOTCA_MO, CERT_PARSE_SerialNumber, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.serialNumber, parseData);
- if(parseCertInfo(ROOTCA_MO, CERT_PARSE_IssuerNameHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.issuerNameHash, parseData);
- if(parseCertInfo(ROOTCA_MO, CERT_PARSE_IssuerKeyHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.issuerKeyHash, parseData);
- certCnt++;
- strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
- }
- else
- {
- DEBUG_INFO(">>> No MORootCertificate was found.\n");
- //sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, "NotFound");
- }
- }
- // Check V2GRootCertificate
- else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "V2GRootCertificate") != NULL)
- {
- if(access(ROOTCA_V2G,F_OK) != -1)
- {
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateType, "V2GRootCertificate");
- char parseData[512] = {0};
- if(parseCertInfo(ROOTCA_V2G, CERT_PARSE_HashAlgorithm, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.hashAlgorithm, parseData);
- if(parseCertInfo(ROOTCA_V2G, CERT_PARSE_SerialNumber, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.serialNumber, parseData);
- if(parseCertInfo(ROOTCA_V2G, CERT_PARSE_IssuerNameHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.issuerNameHash, parseData);
- if(parseCertInfo(ROOTCA_V2G, CERT_PARSE_IssuerKeyHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.issuerKeyHash, parseData);
- certCnt++;
- strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
- }
- else
- {
- DEBUG_INFO(">>> No V2GRootCertificate was found.\n");
- //sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, "NotFound");
- }
- }
- // Check V2GCertificateChain
- else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "V2GCertificateChain") != NULL)
- {
- if(access(CERTIFICATE_V2G,F_OK) != -1)
- {
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateType, "V2GCertificateChain");
- char parseData[512] = {0};
- if(parseCertInfo(CERTIFICATE_V2G, CERT_PARSE_HashAlgorithm, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.hashAlgorithm, parseData);
- if(parseCertInfo(CERTIFICATE_V2G, CERT_PARSE_SerialNumber, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.serialNumber, parseData);
- if(parseCertInfo(CERTIFICATE_V2G, CERT_PARSE_IssuerNameHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.issuerNameHash, parseData);
- if(parseCertInfo(CERTIFICATE_V2G, CERT_PARSE_IssuerKeyHash, parseData) == PASS)
- sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[certCnt].certificateHashData.issuerKeyHash, parseData);
- certCnt++;
- strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
- }
- else
- {
- DEBUG_INFO(">>> No V2GCertificateChain was found.\n");
- //sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, "NotFound");
- }
- }
- else
- {
- DEBUG_INFO(">>> No %s was found.\n", (char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx]);
- }
- }
- }
- else
- strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
- }
- json_object_put(GetInstalledCertificateIds);
- sendGetInstalledCertificateIdsConfirmation(uuid, foundCertCnt);
- return result;
- }
- int handleGetLocalListVersionRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- DEBUG_INFO("handle GetLocalListVersionRequest\n");
- if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "false") == 0)
- {
- DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
- localversion = 0;
- }
- else
- {
- DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
- localversion = 0;
- DB_getListVerion();
- }
- ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
- sendGetLocalListVersionConfirmation(uuid);
- return result;
- }
- static char fnamePlusPath[100]={0};
- static char fnamePWithNoPath[60]={0};
- void checkUploadLog(void)
- {
- FILE *fp;
- /* Open the command for reading. */
- fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
- if (fp == NULL) {
- printf("Failed to run command\n" );
- exit(1);
- }
- int ftppathlen = 0;
- memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
- int i = 0;
- /* Read the output a line at a time - output it. */
- while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
- if(i==0)
- {
- ftppathlen = strlen(fnamePlusPath);
- printf("%s\n", fnamePlusPath);
- fnamePlusPath[ftppathlen]='\0';
- break;
- }
- i= i+1;
- }
- /* close */
- pclose(fp);
- for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
- {
- if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
- {
- fnamePlusPath[k]='\0';
- }
- }
- i=1;
- //char fname[60]={0};
- while(i < ftppathlen)
- {
- int len=ftppathlen-i;
- if(fnamePlusPath[len]== 47) // '/' ascll code: 47
- {
- printf("compare '/' all right\n");
- break;
- }
- i=i+1;
- }
- memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
- strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
- fnamePWithNoPath[i+1] = '\0';
- for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
- {
- if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
- {
- fnamePWithNoPath[j]='\0';
- }
- }
- FILE* fp1 = fopen(fnamePlusPath, "r");
- if (fp1)
- {
- printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
- // file exists
- fclose(fp1);
- }
- else
- {
- // file doesn't exist
- printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
- }
- }
- void* GetLogProcess(void* data)
- {
- th_GetLog = pthread_self();
- pthread_detach(pthread_self());
- mtrace();
- int requestId, retriesInt=0, retryIntervalInt=0;
- char logType[32], remoteLocation[1024]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
- 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};
- int port=0;
- int isSuccess = FALSE;
- char ftpbuf[1024]={0};
- char cmdBuf[2048];
- struct tm *tmNow;
- time_t CurrentTime;
- struct tm tmStart;
- struct tm tmStop;
- CurrentTime = time(NULL);
- tmNow=localtime(&CurrentTime);
- uint16_t targetYear, targetMonth;
- json_object *GetLog;
- DEBUG_INFO("GetGetProcess...\n");
- GetLog = json_tokener_parse(data);
- if(!is_error(GetLog))
- {
- // Required data
- if(json_object_object_get(GetLog, "requestId") != NULL)
- requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
- if(json_object_object_get(GetLog, "logType") != NULL)
- sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
- if(json_object_object_get(GetLog, "log") != NULL)
- {
- if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
- sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
- if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
- sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
- if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
- sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
- }
- // Optional data
- if(json_object_object_get(GetLog, "retries") != NULL)
- retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
- else
- retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
- if(json_object_object_get(GetLog, "retryInterval") != NULL)
- retryIntervalInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
- else
- retryIntervalInt = 30;
- }
- json_object_put(GetLog);
- ShmOCPP20Data->GetLog.requestId = requestId;
- if(strstr(logType, LogEnumTypeStr[LogEnumType_SecurityLog]))
- {
- /*
- * TODO:
- * 1. Pack security log
- */
- }
- else
- {
- // Pack log to compress file
- 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) &&
- (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))
- {
- // Pack system log
- memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
- sprintf(cmdBuf, "exec zip -9 --password %04d%02d%s /mnt/system.zip", tmNow->tm_year+1900, tmNow->tm_mon+1, ShmSysConfigAndInfo->SysConfig.SerialNumber);
- targetYear = tmStart.tm_year;
- targetMonth = tmStart.tm_mon;
- do
- {
- sprintf(cmdBuf, "%s /Storage/SystemLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
- sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*SystemLog*", cmdBuf, targetYear, targetMonth);
- if(targetMonth+1>=13)
- {
- targetYear += 1;
- targetMonth = 1;
- }
- else
- {
- targetMonth += 1;
- }
- }while((targetYear < (tmNow->tm_year+1900)) ||
- ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
- sprintf(cmdBuf, "%s /Storage/CCS*.zip", cmdBuf);
- system(cmdBuf);
- // Pack charging & event log
- memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
- sprintf(cmdBuf, "exec zip -9 /mnt/charging_event.zip");
- targetYear = tmStart.tm_year;
- targetMonth = tmStart.tm_mon;
- do
- {
- sprintf(cmdBuf, "%s /Storage/EventLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
- sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*Ocpp*MessageLog*", cmdBuf, targetYear, targetMonth);
- if(targetMonth+1>=13)
- {
- targetYear += 1;
- targetMonth = 1;
- }
- else
- {
- targetMonth += 1;
- }
- }while((targetYear < (tmNow->tm_year+1900)) ||
- ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
- sprintf(cmdBuf, "%s /Storage/ChargeLog/*.db", cmdBuf);
- sprintf(cmdBuf, "%s /Storage/EventLog/*.db", cmdBuf);
- system(cmdBuf);
- // Combine log file
- system("exec zip -9 /mnt/log.zip /mnt/system.zip /mnt/charging_event.zip");
- system("exec rm -f /mnt/system.zip /mnt/charging_event.zip");
- }
- else
- {
- system("exec /root/logPackTools 'log' 6");
- }
- }
- sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", ShmOCPP20Data->GetLog.Response_filename);
- system(cmdBuf);
- checkUploadLog();
- //****************location*******************/
- if(strcmp(remoteLocation,"")==0)
- {
- DEBUG_INFO("remoteLocation is <Empty>!\n");
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- goto end;
- }
- memset(protocol, 0, ARRAY_SIZE(protocol));
- memset(user, 0, ARRAY_SIZE(user) );
- memset(password, 0, ARRAY_SIZE(password));
- memset(host, 0, ARRAY_SIZE(host));
- memset(path, 0, ARRAY_SIZE(path));
- memset(ftppath, 0, ARRAY_SIZE(ftppath));
- memset(host1, 0, ARRAY_SIZE(host1));
- memset(path1, 0, ARRAY_SIZE(path1));
- /*location: ftp://user:password@host:port/path*/
- //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
- if((access(fnamePlusPath,F_OK))!=-1)
- {
- DEBUG_INFO("fnamePlusPath exist.\n");
- }
- else
- {
- DEBUG_INFO("fnamePlusPath not exist!\n");
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- goto end;
- }
- if(strchr(remoteLocation,'@')==NULL)
- {
- sscanf(remoteLocation,
- "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
- protocol, host, &port, path);
- strcpy(user,"anonymous");
- strcpy(password,"");
- }
- else
- {
- //DEBUG_INFO("pch=%s\n", pch);
- sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
- protocol, user, password, host, &port, path);
- }
- if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0)&&(strcmp(protocol,"https")!=0))
- {
- DEBUG_INFO("protocol is not ftp/http ! \n");
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- goto end;
- }
- if(strncmp(remoteLocation,"http", 4) == 0)
- {
- sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
- sprintf(ftppath,"/%s", path);
- do
- {
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- sleep(3);
- isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
- if(!isSuccess)
- {
- DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- sleep(retryIntervalInt);
- }
- else
- {
- DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- }
- retriesInt--;
- }while((isSuccess == 0)&&(retriesInt >= 0));
- }
- else
- {
- sscanf(host,"%[^/]%s",host1, path1);
- if(strlen(path) > 0)
- sprintf(ftppath,"/%s", path);
- else
- sprintf(ftppath,"/%s", path1);
- int ftppathlen=strlen(ftppath);
- int i=1;
- char filenametemp[50];
- while(i < ftppathlen)
- {
- int len=ftppathlen-i;
- if(ftppath[len]== 47) // '/' ascll code: 47
- {
- DEBUG_INFO("find '/' all right\n");
- break;
- }
- i=i+1;
- }
- memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
- strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
- filenametemp[i+1] = 0;
- memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
- if(port == 0)
- port = 21;
- do
- {
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- sleep(3);
- isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
- if(!isSuccess)
- {
- DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- sleep(retryIntervalInt);
- }
- else
- {
- DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- }
- retriesInt--;
- }while((!isSuccess)&&(retriesInt >= 0));
- }
- end:
- system("rm -f /mnt/*");
- sleep(5);
- LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- interLock.isGetLogGoing = OFF;
- pthread_exit(NULL);
- }
- int handleGetLogRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- char fName[258];
- time_t CurrentTime;
- struct tm *tm;
- pthread_t th_Status;
- DEBUG_INFO("handleGetLogRequest...\n");
- CurrentTime = time(NULL);
- tm = localtime(&CurrentTime);
- 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);
- sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
- if(interLock.isGetLogGoing)
- {
- sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_AcceptedCanceled]);
- isCancelUploadLog = TRUE;
- pthread_cancel(th_GetLog);
- interLock.isGetLogGoing = OFF;
- sleep(1);
- isCancelUploadLog = OFF;
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_AcceptedCanceled]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- sleep(1);
- }
- else
- sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
- sendGetLogConfirmation(uuid);
- if(!interLock.isGetLogGoing)
- {
- interLock.isGetLogGoing = ON;
- pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
- sleep(1);
- }
- else
- {
- DEBUG_WARN("Other GetDiagnostic request on going.\n");
- }
- return result;
- }
- int handleGetMonitoringReportRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- uint8_t cntCriteria = 0;
- int cntComponentVariable = 0;
- uint8_t cntFoundMonitoringVariable = 0;
- json_object *GetMonitoringReport;
- DEBUG_INFO("handleGetMonitoringReportRequest...\n");
- GetMonitoringReport = json_tokener_parse(payload);
- if(!is_error(GetMonitoringReport))
- {
- memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
- memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
- // Required data
- if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
- {
- ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
- }
- // Optional data
- if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
- {
- cntCriteria = json_object_array_length(json_object_object_get(GetMonitoringReport, "monitoringCriteria"));
- for(int idx=0; idx<cntCriteria; idx++)
- {
- sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idx], "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
- }
- }
- if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
- {
- cntComponentVariable = json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));
- if(cntComponentVariable <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
- {
- for(int idx=0;idx<cntComponentVariable;idx++)
- {
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
- {
- 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"), "id") != NULL)
- {
- 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"));
- }
- 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)
- {
- 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"));
- }
- }
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
- {
- 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")));
- }
- }
- }
- }
- }
- }
- json_object_put(GetMonitoringReport);
- //strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
- strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_EmptyResultSet]);
- if(cntComponentVariable>0)
- {
- uint8_t cntTypeSupport = 0;
- for(int idx_cv=0; idx_cv < cntComponentVariable; idx_cv++)
- {
- cntTypeSupport = 0;
- for(int idx=0; idx < 10; idx++)
- {
- if((strcmp((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].component.name, (char*)ShmOCPP20Data->GetMonitoringReport.componentVariable[idx_cv].component.name)==0) &&
- (strcmp((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].variable.name, (char*)ShmOCPP20Data->GetMonitoringReport.componentVariable[idx_cv].variable.name)==0))
- {
- if(strlen((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[0]) > 0)
- {
- for(int idx_cri=0; idx_cri<cntCriteria; idx_cri++)
- {
- if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idx_cri], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_ThresholdMonitoring]) == 0)
- {
- if(strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type, "Threshold") != NULL)
- {
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component, &ShmOCPP20Data->MonitoringComponentVariable[idx].component, sizeof(struct ComponentType));
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable, &ShmOCPP20Data->MonitoringComponentVariable[idx].variable, sizeof(struct VariableType));
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- cntTypeSupport++;
- break;
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idx_cri], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_DeltaMonitoring]) == 0)
- {
- if(strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type, "Delta") != NULL)
- {
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component, &ShmOCPP20Data->MonitoringComponentVariable[idx].component, sizeof(struct ComponentType));
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable, &ShmOCPP20Data->MonitoringComponentVariable[idx].variable, sizeof(struct VariableType));
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- cntTypeSupport++;
- break;
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idx_cri], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_PeriodicMonitoring]) == 0)
- {
- if(strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type, "Periodic") != NULL)
- {
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component, &ShmOCPP20Data->MonitoringComponentVariable[idx].component, sizeof(struct ComponentType));
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable, &ShmOCPP20Data->MonitoringComponentVariable[idx].variable, sizeof(struct VariableType));
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- cntTypeSupport++;
- break;
- }
- }
- }
- }
- else
- {
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component, &ShmOCPP20Data->MonitoringComponentVariable[idx].component, sizeof(struct ComponentType));
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable, &ShmOCPP20Data->MonitoringComponentVariable[idx].variable, sizeof(struct VariableType));
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[cntTypeSupport].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- cntTypeSupport++;
- }
- cntFoundMonitoringVariable++;
- }
- }
- }
- }
- else
- {
- for(int idx=0; idx < 10; idx++)
- {
- if(strlen((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[0]) > 0)
- {
- if((strlen((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].component.name)>0) && (strlen((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].variable.name)>0))
- {
- int isSameVariableFound = FALSE;
- for(int idx_cri=0; idx_cri<cntCriteria; idx_cri++)
- {
- if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idx_cri], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_ThresholdMonitoring]) == 0)
- {
- if(strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type, "Threshold") != NULL)
- {
- for(int idx_cv=0; idx_cv < 10; idx_cv++)
- {
- if((strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component.name)>0) && (strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable.name)>0))
- {
- if((strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].component.name, (char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component.name) != NULL) &&
- (strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].variable.name, (char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable.name) != NULL))
- {
- isSameVariableFound = TRUE;
- for(int idx_vm=1; idx_vm < 10; idx_vm++)
- {
- if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].type) == 0)
- {
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- }
- }
- break;
- }
- }
- else
- {
- if(isSameVariableFound==FALSE)
- {
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component, &ShmOCPP20Data->MonitoringComponentVariable[idx].component, sizeof(struct ComponentType));
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable, &ShmOCPP20Data->MonitoringComponentVariable[idx].variable, sizeof(struct VariableType));
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- }
- break;
- }
- }
- break;
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idx_cri], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_DeltaMonitoring]) == 0)
- {
- if(strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type, "Delta") != NULL)
- {
- for(int idx_cv=0; idx_cv < 10; idx_cv++)
- {
- if((strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component.name)>0) && (strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable.name)>0))
- {
- if((strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].component.name, (char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component.name) != NULL) &&
- (strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].variable.name, (char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable.name) != NULL))
- {
- isSameVariableFound = TRUE;
- for(int idx_vm=1; idx_vm < 10; idx_vm++)
- {
- if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].type) == 0)
- {
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- }
- }
- break;
- }
- }
- else
- {
- if(isSameVariableFound==FALSE)
- {
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component, &ShmOCPP20Data->MonitoringComponentVariable[idx].component, sizeof(struct ComponentType));
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable, &ShmOCPP20Data->MonitoringComponentVariable[idx].variable, sizeof(struct VariableType));
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- }
- break;
- }
- }
- break;
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idx_cri], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_PeriodicMonitoring]) == 0)
- {
- if(strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type, "Periodic") != NULL)
- {
- for(int idx_cv=0; idx_cv < 10; idx_cv++)
- {
- if((strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component.name)>0) && (strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable.name)>0))
- {
- if((strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].component.name, (char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component.name) != NULL) &&
- (strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].variable.name, (char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable.name) != NULL))
- {
- isSameVariableFound = TRUE;
- for(int idx_vm=1; idx_vm < 10; idx_vm++)
- {
- if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].type) == 0)
- {
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- }
- }
- break;
- }
- }
- else
- {
- if(isSameVariableFound==FALSE)
- {
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component, &ShmOCPP20Data->MonitoringComponentVariable[idx].component, sizeof(struct ComponentType));
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable, &ShmOCPP20Data->MonitoringComponentVariable[idx].variable, sizeof(struct VariableType));
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- }
- break;
- }
- }
- break;
- }
- }
- }
- }
- }
- else
- {
- if((strlen((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].component.name)>0) && (strlen((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].variable.name)>0))
- {
- int isSameVariableFound = FALSE;
- for(int idx_cv=0; idx_cv < 10; idx_cv++)
- {
- if((strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component.name)>0) && (strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable.name)>0))
- {
- if((strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].component.name, (char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component.name) != NULL) &&
- (strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx].variable.name, (char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable.name) != NULL))
- {
- isSameVariableFound = TRUE;
- for(int idx_vm=1; idx_vm < 10; idx_vm++)
- {
- if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].type) == 0)
- {
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[idx_vm].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- }
- }
- }
- }
- else
- {
- if(isSameVariableFound==FALSE)
- {
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].component, &ShmOCPP20Data->MonitoringComponentVariable[idx].component, sizeof(struct ComponentType));
- memcpy(&ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variable, &ShmOCPP20Data->MonitoringComponentVariable[idx].variable, sizeof(struct VariableType));
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].id = ShmOCPP20Data->MonitoringComponentVariable[idx].id;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].severity = ShmOCPP20Data->MonitoringComponentVariable[idx].severity;
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].transaction = ShmOCPP20Data->MonitoringComponentVariable[idx].transaction;
- strcpy((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].type,(char*)ShmOCPP20Data->MonitoringComponentVariable[idx].type);
- ShmOCPP20Data->NotifyMonitoringReport.monitor[idx_cv].variableMonitoring[0].value = ShmOCPP20Data->MonitoringComponentVariable[idx].value;
- strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- }
- }
- }
- }
- }
- cntFoundMonitoringVariable++;
- }
- }
- if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]) != 0)
- ShmOCPP20Data->GetMonitoringReport.requestId = 0;
- sendGetMonitoringReportConfirmation(uuid);
- return result;
- }
- int handleGetReportRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *GetReport;
- DEBUG_INFO("handleGetReportRequest...\n");
- GetReport = json_tokener_parse(payload);
- if(!is_error(GetReport))
- {
- memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
- memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
- // Required data
- if(json_object_object_get(GetReport, "requestId") != NULL)
- {
- ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
- }
- // Optional data
- if(json_object_object_get(GetReport, "componentCriteria") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
- }
- if(json_object_object_get(GetReport, "componentVariable") != NULL)
- {
- if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
- {
- for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
- {
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
- {
- 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"), "id") != NULL)
- {
- ShmOCPP20Data->GetReport.componentVariable[idx].component.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse"), "id"));
- }
- 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)
- {
- ShmOCPP20Data->GetReport.componentVariable[idx].component.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse"), "connectorId"));
- }
- }
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
- {
- 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")));
- }
- }
- }
- }
- }
- }
- json_object_put(GetReport);
- /*
- * TODO:
- * 1. Response result
- */
- strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- sendGetReportConfirmation(uuid);
- return result;
- }
- int handleGetTransactionStatusRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- uint8_t tempIndex;
- json_object *GetTransactionStatus;
- DEBUG_INFO("handleGetTransactionStatusRequest...\n");
- GetTransactionStatus = json_tokener_parse(payload);
- if(!is_error(GetTransactionStatus))
- {
- memset(&ShmOCPP20Data->GetTransactionStatus, 0, sizeof(struct GetTransactionStatus_20));
- memcpy(&ShmOCPP20Data->GetTransactionStatus.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus.guid));
- ShmOCPP20Data->GetTransactionStatus.Response_messagesInQueue = FALSE;
- ShmOCPP20Data->GetTransactionStatus.Response_ongoingIndicator = FALSE;
- if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->GetTransactionStatus.transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
- }
- if(strlen((char*)ShmOCPP20Data->GetTransactionStatus.transactionId)>0)
- {
- for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
- {
- if(strcmp((char*)ShmOCPP20Data->GetTransactionStatus.transactionId, (char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId)==0)
- {
- if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- tempIndex = ((gun_index==2) ? 1: 0);
- else
- tempIndex = gun_index;
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) &&
- ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)))
- ShmOCPP20Data->GetTransactionStatus.Response_ongoingIndicator = TRUE;
- }
- }
- else if(gunType[gun_index] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- tempIndex = ((gun_index==2) ? 1: 0);
- else
- tempIndex = gun_index;
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) &&
- ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)))
- ShmOCPP20Data->GetTransactionStatus.Response_ongoingIndicator = TRUE;
- }
- }
- else if(gunType[gun_index] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- tempIndex = ((gun_index==2) ? 1: 0);
- else
- tempIndex = gun_index;
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) &&
- ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)))
- ShmOCPP20Data->GetTransactionStatus.Response_ongoingIndicator = TRUE;
- }
- }
- else if(gunType[gun_index] == GUN_TYPE_DO)
- {
- tempIndex = gun_index;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- 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_TERMINATING)))
- ShmOCPP20Data->GetTransactionStatus.Response_ongoingIndicator = TRUE;
- }
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- tempIndex = 2;
- else
- tempIndex = gun_index;
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) &&
- ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)))
- ShmOCPP20Data->GetTransactionStatus.Response_ongoingIndicator = TRUE;
- }
- }
- }
- }
- }
- char rmFileCmd[100]={0};
- int TransactionQueueNum = 0;
- struct stat stats;
- stat("/Storage/OCPP", &stats);
- // Check for directory existence
- if (S_ISDIR(stats.st_mode) == 1)
- {
- //DEBUG_INFO("\n OCPP directory exist \n");
- }
- else
- {
- //DEBUG_INFO("\n OCPP directory not exist, create dir \n");
- sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
- system(rmFileCmd);
- }
- memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
- if((access("/Storage/OCPP/TransactionRelatedQueue20",F_OK))!=-1)
- {
- //DEBUG_INFO("TransactionRelatedQueue exist.\n");
- }
- else
- {
- FILE *fp = fopen("/Storage/OCPP/TransactionRelatedQueue20", "r");
- char line[QUEUE_MESSAGE_LENGTH]={0};
- if (fp == NULL) {
- DEBUG_INFO("cannot open file TransactionRelatedQueue!");
- }
- TransactionQueueNum = 0; // the number of packets in queue
- while(fgets(line, sizeof line, fp) != NULL) {
- if(strlen((char*)ShmOCPP20Data->GetTransactionStatus.transactionId)>0)
- {
- if(strstr(line, (char*)ShmOCPP20Data->GetTransactionStatus.transactionId) != NULL)
- ShmOCPP20Data->GetTransactionStatus.Response_messagesInQueue = TRUE;
- }
- TransactionQueueNum += 1; //the number of packets in queue
- }
- fclose(fp);
- }
- if((strlen((char*)ShmOCPP20Data->GetTransactionStatus.transactionId) == 0) && (TransactionQueueNum>0))
- ShmOCPP20Data->GetTransactionStatus.Response_messagesInQueue = TRUE;
- }
- json_object_put(GetTransactionStatus);
- sendGetTransactionStatusConfirmation(uuid);
- return result;
- }
- int handleGetVariablesRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int isUnknownComponent = TRUE;
- json_object *GetVariables;
- DEBUG_INFO("handleGetVariablesRequest...\n");
- GetVariables = json_tokener_parse(payload);
- if(!is_error(GetVariables))
- {
- memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
- memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
- // Required data
- if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
- {
- for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
- {
- if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
- {
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
- {
- 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")));
- strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
- }
- /*if(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType != NULL)
- {
- strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, "Actual");
- }*/
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
- {
- 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)
- {
- 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"));
- }
- 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)
- {
- 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"));
- }
- }
- memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
- {
- 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")));
- }
- memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
- }
- for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
- {
- if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
- (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance) == 0) &&
- (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
- (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance) == 0))
- {
- strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
- isUnknownComponent = FALSE;
- if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type) != 0) &&
- (json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_NotSupportedAttributeType]);
- break;
- }
- if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, "ChargingStation") == 0) &&
- (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, "SystemUptimeSec") == 0))
- {
- struct sysinfo s_info;
- int error = sysinfo(&s_info);
- if(error != 0)
- {
- DEBUG_WARN("System uptime get error: %d\n", error);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, "%ld", s_info.uptime);
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, "%ld", s_info.uptime);
- }
- }
- else if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, "ChargingStation") == 0) &&
- (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, "FreeVend") == 0))
- {
- sprintf((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, "%s", (ShmSysConfigAndInfo->SysConfig.AuthorisationMode?"true":"false"));
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
- strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type);
- }
- break;
- }
- else
- {
- if(strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != 0)
- {
- isUnknownComponent = FALSE;
- }
- strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownVariable]);
- memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
- }
- }
- if(isUnknownComponent == TRUE)
- {
- strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
- }
- }
- }
- }
- sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
- }
- json_object_put(GetVariables);
- return result;
- }
- int handleInstallCertificateRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = PASS;
- char tempCert[] = "/Storage/OCPP/tempInstallCertificate.pem";
- json_object *InstallCertificate;
- sprintf((char*)ShmOCPP20Data->InstallCertificate.Response_status, "Accepted");
- DEBUG_INFO("handleInstallCertificateRequest...\n");
- InstallCertificate = json_tokener_parse(payload);
- if(!is_error(InstallCertificate))
- {
- memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
- memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
- // Required data
- if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
- }
- if(json_object_object_get(InstallCertificate, "certificate") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
- }
- DEBUG_INFO("certificateType: %s\n", (char*)ShmOCPP20Data->InstallCertificate.certificateType);
- DEBUG_INFO("certificate: %s\n", (char*)ShmOCPP20Data->InstallCertificate.certificate);
- char temp[1024];
- FILE *fp = fopen(tempCert, "w");
- fprintf(fp, "%s", ShmOCPP20Data->InstallCertificate.certificate);
- fclose(fp);
- // Check the expired date (exp: notAfter=Oct 2 18:10:27 2048 GMT)
- char strExpDate[30];
- sprintf(temp ,"openssl x509 -noout -enddate -in /Storage/OCPP/tempInstallCertificate.pem");
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if(strstr(temp, "notAfter=") != NULL)
- {
- DEBUG_INFO("Certificate enddate info: %s\n", temp);
- sscanf(temp, "%*[^=]=%[^G]G", strExpDate);
- break;
- }
- }
- }
- DEBUG_INFO("ExpDate: %s\n", strExpDate);
- struct tm tmExpDate;
- struct timeb tbExpDate;
- strptime(strExpDate, "%b %d %H:%M:%S %Y", &tmExpDate);
- tbExpDate.time = mktime(&tmExpDate);
- if(DiffTimebWithNowSec(tbExpDate) >= 0)
- {
- DEBUG_INFO("The enddate is already expired...\n");
- sprintf((char*)ShmOCPP20Data->InstallCertificate.Response_status, "Rejected");
- goto End;
- }
- // Verify certificate with rootCA
- sprintf(temp ,"openssl verify -CAfile /root/cacert.pem /Storage/OCPP/tempInstallCertificate.pem");
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if((strstr(temp, "tempInstallCertificate.pem: OK") != NULL) || (strstr(temp, "self signed certificate") != NULL))
- {
- sprintf((char*)ShmOCPP20Data->InstallCertificate.Response_status, "Accepted");
- break;
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->InstallCertificate.Response_status, "Rejected");
- }
- }
- }
- if(strcmp((char*)ShmOCPP20Data->InstallCertificate.Response_status, "Accepted") != 0)
- {
- //=====================================================
- // Verify if the certificate is valid or not. (OCSP?)
- //=====================================================
- /*
- DEBUG_INFO("openssl CA verifying...FAIL --> Start OCSP process...\n");
- // Get ocsp url
- char ocspUrl[512];
- sprintf(temp ,"openssl x509 -noout -ocsp_uri -in %s", tempCert);
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if(strstr(temp, "://") != NULL)
- {
- strcpy(ocspUrl, temp);
- break;
- }
- }
- }
- // Get certificate chain for issuer
- * openssl s_client -connect [serverURL:port] -showcerts | sed -n '/-----BEGIN/,/-------END/p' > tempChain.pem
- *
- // Execute OCSP
- sprintf(temp ,"openssl ocsp -issuer tempChain.pem -cert /Storage/OCPP/tempInstallCertificate.pem -text -url %s", ocspUrl);
- fp = popen(temp, "r");
- if(fp)
- {
- while(fgets(temp, sizeof(temp), fp) != NULL)
- {
- if(strstr(temp, "tempInstallCertificate.pem: good") != NULL)
- {
- sprintf((char*)ShmOCPP16Data->InstallCertificate.Response_status, "Accepted");
- break;
- }
- }
- }
- system("rm -f /Storage/OCPP/tempChain.pem");
- pclose(fp);
- */
- sprintf((char*)ShmOCPP20Data->InstallCertificate.Response_status, "Accepted");
- if(strcmp((char*)ShmOCPP20Data->InstallCertificate.Response_status, "Accepted") != 0)
- {
- DEBUG_INFO("OCSP verifying...FAIL.\n");
- goto End;
- }
- else
- DEBUG_INFO("OCSP verifying...PASS.\n");
- }
- else
- DEBUG_INFO("openssl CA verifying...PASS.\n");
- }
- json_object_put(InstallCertificate);
- End:
- if(strcmp((char*)ShmOCPP20Data->InstallCertificate.Response_status, "Accepted") == 0)
- {
- if(strcmp((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_CSMSRootCertificate]) == 0)
- {
- if(access(ROOTCA_CS,F_OK) != -1)
- {
- DEBUG_INFO("Existed CSMSRootCertificate is found. Replacing...\n");
- rename(ROOTCA_CS, "/Storage/OCPP/CentralSystemRootCertificate_fallback.pem");
- rename(tempCert, ROOTCA_CS);
- }
- else
- {
- DEBUG_INFO("No existed CSMSRootCertificate Creating...\n");
- rename(tempCert, ROOTCA_CS);
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_MORootCertificate]) == 0)
- {
- if(access(ROOTCA_MF,F_OK) != -1)
- {
- DEBUG_INFO("Existed ManufacturerRootCertificate is found. Replacing...\n");
- rename(ROOTCA_MF, "/Storage/OCPP/ManufacturerRootCertificate_fallback.pem");
- rename(tempCert, ROOTCA_MF);
- }
- else
- {
- DEBUG_INFO("No existed ManufacturerRootCertificate. Creating...\n");
- rename(tempCert, ROOTCA_MF);
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_V2GRootCertificate]) == 0)
- {
- if(access(ROOTCA_V2G,F_OK) != -1)
- {
- DEBUG_INFO("Existed ManufacturerRootCertificate is found. Replacing...\n");
- rename(ROOTCA_V2G, "/Storage/OCPP/ManufacturerRootCertificate_fallback.pem");
- rename(tempCert, ROOTCA_V2G);
- }
- else
- {
- DEBUG_INFO("No existed ManufacturerRootCertificate. Creating...\n");
- rename(tempCert, ROOTCA_V2G);
- }
- }
- ShmOCPP20Data->MsMsg.bits.InstallCertificateReq = 1;
- }
- sendInstallCertificateConfirmation(uuid);
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- if(strcmp((char*)ShmOCPP20Data->InstallCertificate.Response_status, "Accepted") != 0)
- {
- sprintf((char*)ShmOCPP20Data->SecurityEventNotification.type, "InvalidCentralSystemCertificate");
- memset(ShmOCPP20Data->SecurityEventNotification.techInfo, 0x00, ARRAY_SIZE(ShmOCPP20Data->SecurityEventNotification.techInfo));
- ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = 1;
- }
- return result;
- }
- int handlePublishFirmwareRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *PublishFirmware;
- DEBUG_INFO("handlePublishFirmwareRequest...\n");
- PublishFirmware = json_tokener_parse(payload);
- if(!is_error(PublishFirmware))
- {
- memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
- memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
- // Required data
- if(json_object_object_get(PublishFirmware, "requestId") != NULL)
- {
- ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
- }
- if(json_object_object_get(PublishFirmware, "checksum") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->PublishFirmware.checksum, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
- }
- // Optional data
- if(json_object_object_get(PublishFirmware, "location") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
- }
- if(json_object_object_get(PublishFirmware, "retries") != NULL)
- {
- ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
- }
- if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
- {
- ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
- }
- }
- json_object_put(PublishFirmware);
- /*
- * TODO:
- * 1. Publish firmware preocess and response
- */
- strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
- sendPublishFirmwareConfirmation(uuid);
- return result;
- }
- int handleRequestStartTransactionRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int8_t evseId = -1;
- uint8_t tempIndex;
- uint8_t isOverConnectorMax = FALSE;
- uint8_t isPeriodOverMax = FALSE;
- uint8_t isTxProfile = TRUE;
- uint8_t isAllowStart = TRUE;
- uint8_t filename[128]={0};
- char cmdBuf[128];
- FILE *filePtr;
- json_object *RemoteStartTransaction;
- DEBUG_INFO("handleRequestStartTransactionRequest...\n");
- RemoteStartTransaction = json_tokener_parse(payload);
- if(!is_error(RemoteStartTransaction))
- {
- if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
- {
- if((0 < json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))) && (json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))<=gunTotalNumber))
- {
- evseId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
- }
- else
- {
- isOverConnectorMax = TRUE;
- DEBUG_WARN("Evse id shall not equal 0 and should be less than gunTotalNumber.\n");
- }
- }
- else
- {
- for(uint8_t idx=0;idx<gunTotalNumber;idx++)
- {
- if(!cpinitateMsg.bits[idx].isOnCharging && (strstr((char*)ShmOCPP20Data->StatusNotification[idx].connectorStatus, ConnectorStatusEnumTypeStr[ConnectorStatusEnumType_Occupied]) != NULL))
- {
- evseId = (idx+1);
- DEBUG_INFO("Remote start without evseId but detect connector of evse-%02d connected ready to start.\n", evseId);
- break;
- }
- }
- }
- if(isOverConnectorMax == FALSE)
- {
- if(evseId > 0)
- {
- DEBUG_INFO("Requested evseId id: %d\n", evseId);
- memset(&ShmOCPP20Data->RequestStartTransaction[evseId-1], 0, sizeof(struct RequestStartTransaction_20));
- memcpy(&ShmOCPP20Data->RequestStartTransaction[evseId-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[evseId-1].guid));
- // Required data
- if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
- {
- ShmOCPP20Data->RequestStartTransaction[evseId-1].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
- }
- if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
- {
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
- }
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
- }
- }
- // Optional data
- if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
- {
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
- }
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
- }
- }
- if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
- {
- // Check periods is over max configuration
- if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
- {
- isPeriodOverMax = TRUE;
- }
- // Check profile purpose is TxProfile
- if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
- {
- ShmOCPP20Data->RequestStartTransaction[evseId-1].chargingProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "id"));
- sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", evseId);
- }
- else
- {
- isTxProfile = FALSE;
- }
- }
- //check Transaction active
- if(gunType[evseId-1] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((evseId-1) == 2) ? 1: 0;
- }
- else
- {
- tempIndex = (evseId-1);
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken) == 0))
- {
- //Reserved
- DEBUG_INFO("CHAdeMO connector already reserved and idTag match.\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken) != 0))
- {
- //Reserved
- DEBUG_INFO("CHAdeMO connector already reserved and idTag does not match.\n");
- isAllowStart = FALSE;
- }
- else
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
- {
- DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n.");
- isAllowStart = FALSE;
- }
- }//END FOR ELSE
- }
- }// END FOR CHAdeMO_QUANTITY
- }
- else if(gunType[evseId-1] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((evseId-1) == 2) ? 1: 0;
- }
- else
- {
- tempIndex = (evseId-1);
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken) == 0))
- {
- //Reserved
- DEBUG_INFO("CCS connector already reserved and idTag match.\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken) != 0))
- {
- //Reserved
- DEBUG_INFO("CCS connector already reserved and idTag does not match.\n");
- isAllowStart = FALSE;
- }
- else
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
- {
- DEBUG_WARN("CCS connector not allow start cause busy.\n.");
- isAllowStart = FALSE;
- }
- }// END FOR ELSE
- }
- }// END FOR CCS_QUANTITY
- }
- else if(gunType[evseId-1] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((evseId-1) == 2) ? 1: 0;
- }
- else
- {
- tempIndex = (evseId-1);
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken) == 0))
- {
- //Reserved
- DEBUG_INFO("GBT connector already reserved and idTag match.\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken) != 0))
- {
- //Reserved
- DEBUG_INFO("GBT connector already reserved and idTag does not match.\n");
- isAllowStart = FALSE;
- }
- else
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
- {
- DEBUG_WARN("GBT connector not allow start cause busy.\n");
- isAllowStart = FALSE;
- }
- }// END FOR ELSE
- }
- } // END FOR GB_QUANTITY
- }
- else if(gunType[evseId-1] == GUN_TYPE_DO)
- {
- tempIndex = (evseId-1);
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
- {
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken) == 0))
- {
- //Reserved
- DEBUG_INFO("Dispenser connector already reserved and idTag match.\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken) != 0))
- {
- //Reserved
- DEBUG_INFO("Dispenser connector already reserved and idTag does not match.\n");
- isAllowStart = FALSE;
- }
- else
- {
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) || ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
- {
- DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
- isAllowStart = FALSE;
- }
- }// END FOR ELSE
- }
- } // END FOR GB_QUANTITY
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = (evseId-1);
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken) == 0))
- {
- //Reserved
- DEBUG_INFO("AC connector already reserved and idTag match.\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].idToken.idToken) != 0))
- {
- //Reserved
- DEBUG_INFO("AC connector already reserved and idTag does not match.\n");
- isAllowStart = FALSE;
- }
- else
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
- {
- DEBUG_WARN("AC connector not allow start cause busy.\n");
- isAllowStart = FALSE;
- }
- }//END FOR ELSE
- }
- }// END FOR AC_QUANTITY
- }
- }
- else
- {
- DEBUG_INFO("Connector id does not specific.\n");
- for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
- {
- memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
- memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
- // Required data
- if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
- {
- ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
- }
- if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
- {
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
- }
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
- }
- }
- // Optional data
- if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
- {
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
- }
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
- }
- }
- if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
- {
- // Check periods is over max configuration
- if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
- {
- isPeriodOverMax = TRUE;
- }
- // Check profile purpose is TxProfile
- if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
- {
- ShmOCPP20Data->RequestStartTransaction[gun_index].chargingProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "id"));
- sprintf((char*)filename, "/Storage/OCPP/TxProfile_Tmp_OCPP20.json");
- }
- else
- {
- isTxProfile = FALSE;
- }
- }
- }
- }
- }
- // Profile replace or add info
- if((isOverConnectorMax == FALSE) && !isPeriodOverMax && isTxProfile && isAllowStart)
- {
- if(evseId != -1)
- {
- if(strlen((char*)filename) > 0)
- {
- // Save profile to file
- sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_%d_OCPP20.json", evseId);
- system(cmdBuf);
- sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json.json", evseId);
- filePtr = fopen((char*)filename, "w");
- fprintf(filePtr, "{\"evseId\":%d,\"chargingProfile\":%s}\n", evseId, json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
- fclose(filePtr);
- }
- ShmOCPP20Data->CsMsg.bits[evseId-1].RequestStartTransactionReq = ON;
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
- random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[evseId-1].Response_transactionId);
- result = PASS;
- }
- else
- {
- uint8_t isHasIdleConnector = FALSE;
- for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
- {
- if(!cpinitateMsg.bits[gun_index].isOnCharging)
- {
- isHasIdleConnector = TRUE;
- break;
- }
- }
- if((isHasIdleConnector == TRUE) && !ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
- {
- DEBUG_INFO("Start wait connector link to EV in %s seconds.\n", ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value);
- if(strlen((char*)filename) > 0)
- {
- // Save profile to file
- sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_Tmp_OCPP20.json");
- system(cmdBuf);
- sprintf((char*)filename, "/Storage/OCPP/TxProfile_Tmp_OCPP20.json.json");
- filePtr = fopen((char*)filename, "w");
- fprintf(filePtr, "{\"evseId\":0,\"chargingProfile\":%s}\n", json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
- fclose(filePtr);
- }
- refreshStartTimer(&clientTime.RemoteStartWait);
- ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = ON;
- for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
- {
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
- random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId);
- }
- result = PASS;
- }
- else
- {
- DEBUG_INFO("There is not any connector is idle.\n");
- for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
- strcpy((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
- }
- }
- }
- else
- {
- if(isOverConnectorMax != FALSE)
- DEBUG_WARN("evseId id equal 0 or over maximun id.\n");
- if(isPeriodOverMax)
- DEBUG_WARN("Profile periods quantity is over spec.\n");
- if(!isTxProfile)
- DEBUG_WARN("Profile purpose is not TxProfile.\n");
- if(!isAllowStart)
- DEBUG_WARN("Target connector does not allow start.\n");
- sprintf((char*)ShmOCPP20Data->RequestStartTransaction[((evseId-1)<0?0:(evseId-1))].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
- }
- }
- json_object_put(RemoteStartTransaction);
- sendRemoteStartTransactionConfirmation(uuid, ((evseId-1)<0?0:(evseId-1)));
- return result;
- }
- int handleRequestStopTransactionRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int match = FALSE;
- int GunNO = 0;
- int tempIndex = 0;
- char transactionIdStr[37];
- int transactionIdIsNULL= TRUE;
- json_object *RemoteStopTransaction;
- DEBUG_INFO("handleRequestStopTransactionRequest...\n");
- if(server_pending == TRUE)
- {
- return 0;
- }
- RemoteStopTransaction = json_tokener_parse(payload);
- if(!is_error(RemoteStopTransaction))
- {
- if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
- {
- sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
- transactionIdIsNULL = FALSE;
- }
- }
- json_object_put(RemoteStopTransaction);
- if(transactionIdIsNULL == FALSE)
- {
- for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
- {
- if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
- {
- //check Transaction active
- if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
- {
- match = TRUE;
- GunNO = gun_index;
- }
- }
- }// END FOR CHAdeMO_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
- {
- match = TRUE;
- GunNO = gun_index;
- }
- }
- }// END FOR CCS_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
- {
- match = TRUE;
- GunNO = gun_index;
- }
- }
- }// END FOR GB_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_DO)
- {
- tempIndex = gun_index;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- 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
- {
- match = TRUE;
- GunNO = gun_index;
- }
- }
- }// END FOR GB_QUANTITY
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
- {
- match = TRUE;
- GunNO = gun_index;
- }
- }
- }// END FOR CHAdeMO_QUANTITY
- } // END FOR AC ELSE
- }// CHECK IF ResponseTransactionId == transactionIdInt
- }//END FOR
- if( match == TRUE)
- {
- ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
- strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
- }
- }
- else
- strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
- sendRemoteStopTransactionConfirmation(uuid, GunNO);
- return result;
- }
- int handleReserveNowRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int evseIdInt=0, reservationIdInt=0;
- int tempIndex = 0;
- json_object *ReserveNow;
- DEBUG_INFO("handleReserveNowRequest ...\n");
- ReserveNow = json_tokener_parse(payload);
- if(!is_error(ReserveNow))
- {
- if(json_object_object_get(ReserveNow, "evseId") != NULL)
- {
- evseIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
- evseIdInt = (evseIdInt==0)?1:evseIdInt;
- memset(&ShmOCPP20Data->ReserveNow[evseIdInt-1], 0x00, sizeof(struct ReserveNow_20));
- ShmOCPP20Data->ReserveNow[evseIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
- }
- // Required data
- if(json_object_object_get(ReserveNow, "id") != NULL)
- ShmOCPP20Data->ReserveNow[evseIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "id"));
- if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
- sprintf((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
- if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
- sprintf((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
- if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
- sprintf((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
- // Optional data
- if(json_object_object_get(ReserveNow, "connectorType") != NULL)
- sprintf((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
- if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
- sprintf((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
- if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
- sprintf((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
- result = PASS;
- }
- json_object_put(ReserveNow);
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
- if((evseIdInt > 0) && ((evseIdInt -1) <= gunTotalNumber))
- {
- //check Transaction active
- if(gunType[evseIdInt -1] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = (((evseIdInt -1)==2) ? 1: 0);
- }
- else
- {
- tempIndex = evseIdInt -1;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].InProgress == 1))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- }
- else
- {
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- }
- }
- 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'))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
- }
- else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
- }
- }
- 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
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
- }
- }
- else
- {
- //replace reservation
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- }
- }
- } // END FOR CHAdeMO_QUANTITY
- }
- else if(gunType[evseIdInt -1] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = (((evseIdInt -1)==2) ? 1: 0);
- }
- else
- {
- tempIndex = evseIdInt -1;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
- {
- //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].InProgress == 1))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- }
- else
- {
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- }
- }
- 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'))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
- }
- else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
- }
- }
- 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
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
- }
- }
- else
- {
- //replace reservation
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- }
- }
- } // END FOR CCS_QUANTITY
- }
- else if(gunType[evseIdInt -1] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = (((evseIdInt -1)==2) ? 1: 0);
- }
- else
- {
- tempIndex = evseIdInt -1;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
- {
- //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].InProgress == 1))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- }
- else
- {
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- }
- }
- 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'))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
- }
- else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
- }
- }
- 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
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
- }
- }
- else
- {
- //replace reservation
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- }
- }
- }// END FOR GB_QUANTITY
- }
- else if(gunType[evseIdInt -1] == GUN_TYPE_DO)
- {
- tempIndex = evseIdInt -1;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId)
- {
- //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
- 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
- {
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.InProgress == 1))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- }
- else
- {
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- }
- }
- 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'))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
- }
- else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
- }
- }
- 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
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
- }
- }
- else
- {
- //replace reservation
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- }
- }
- }// END FOR DO_QUANTITY
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = (evseIdInt -1);
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- 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))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- }
- else
- {
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- }
- }
- 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'))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
- }
- else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
- }
- }
- 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
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
- }
- }
- else
- {
- //replace reservation
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- }
- }
- } // END FOR AC_QUANTITY
- }
- }
- else if(evseIdInt == 0)
- {
- //check Transaction active
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
- {
- 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'))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- goto end;
- }
- 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
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
- goto end;
- }
- }
- }// END FOR CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
- {
- 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'))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- goto end;
- }
- 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
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
- goto end;
- }
- }
- } // END FOR CCS_QUANTITY
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
- {
- 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'))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- goto end;
- }
- 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
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
- goto end;
- }
- }
- } // END FOR GB_QUANTITY
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
- {
- 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'))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- goto end;
- }
- 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
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
- goto end;
- }
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- 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))
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
- goto end;
- }
- }
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
- goto end;
- }
- }
- }// END FOR AC_QUANTITY
- //The connectorId is 0
- ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
- strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
- strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
- result = TRUE;
- return result;
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
- }
- if(strcmp((char*)ShmOCPP20Data->ReserveNow[evseIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
- {
- strcpy((char *)ShmOCPP20Data->ReserveNow[evseIdInt-1].guid, uuid);
- result = TRUE;
- return result;
- }
- end:
- sendReserveNowConfirmation(uuid, (evseIdInt==0?evseIdInt:evseIdInt-1));
- return result;
- }
- int handleResetRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *Reset = json_object_new_object();
- DEBUG_INFO("handleResetRequest...\n");
- Reset = json_tokener_parse(payload);
- ShmOCPP20Data->Reset.evseId = 0;
- if(!is_error(Reset))
- {
- // Required data
- if(json_object_object_get(Reset, "type") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
- }
- if(json_object_object_get(Reset, "evseId") != NULL)
- {
- ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
- }
- }
- json_object_put(Reset);
- if((ShmOCPP20Data->Reset.evseId == 0) && ((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0)))
- {
- strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
- strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]);
- ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
- result = PASS;
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
- }
- if(strlen((char*)ShmOCPP20Data->Reset.Response_status) > 0)
- sendResetConfirmation(uuid);
- return result;
- }
- int handleSendLocalListRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int checkState_Faulted = FALSE;
- json_object *SendLocalList;
- DEBUG_INFO("handleSendLocalListRequest...\n");
- if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "false") == 0)
- {
- strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
- goto end;
- }
- SendLocalList = json_tokener_parse(payload);
- if(!is_error(SendLocalList))
- {
- memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
- // Required data
- if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
- {
- ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
- }
- if(json_object_object_get(SendLocalList, "updateType") != NULL)
- sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
- // Optional data
- if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
- {
- for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
- {
- // Required data
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
- {
- 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")));
- sprintf((char*)ShmOCPP20Data->SendLocalList.localAuthorizationList[idx].idToken.type, "%s", stringtrimspace((char *)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"))));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->SendLocalList.localAuthorizationList[idx].idTokenInfo.status, "%s", stringtrimspace((char *)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"))));
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
- 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"));
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
- {
- 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")));
- 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")));
- }
- }
- }
- }
- }
- json_object_put(SendLocalList);
- //check Charge Point state
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
- {
- checkState_Faulted = TRUE; //OCPP Status: Faulted
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
- {
- checkState_Faulted = TRUE; //OCPP Status
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
- {
- checkState_Faulted = TRUE; //OCPP Status: Faulted
- }
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
- {
- checkState_Faulted = TRUE; //OCPP Status: Faulted
- }
- }
- if(checkState_Faulted == TRUE)
- {
- strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
- goto end;
- }
- // Check update type
- if(strcmp((char*)ShmOCPP20Data->SendLocalList.updateType, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
- {
- //Local list full update
- DEBUG_INFO("Local list full update.\n");
- DB_getListVerion();
- /*if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
- {
- strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
- goto end;
- }*/
- DB_cleanLocalList();
- for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
- DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
- }
- else if(strcmp((char*)ShmOCPP20Data->SendLocalList.updateType, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
- {
- //Local list different update
- DEBUG_INFO("Local list different update.\n");
- DB_getListVerion();
- if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
- {
- strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
- goto end;
- }
- for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
- DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
- goto end;
- }
- strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
- end:
- sendSendLocalListConfirmation(uuid);
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- return result;
- }
- int handleSetChargingProfileRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- struct SetChargingProfile_20 SetProfileReq = {0};
- uint8_t isLostEvseId = FALSE;
- uint8_t isPeriodOverMax = FALSE;
- uint8_t isStackOverMax = FALSE;
- uint8_t isProfileOverMax = FALSE;
- uint8_t isEvseMismatch = FALSE;
- uint8_t isTransactiodIdMismatch = FALSE;
- uint8_t isInvalidLimit = FALSE;
- uint8_t isWrongFormat = FALSE;
- uint8_t replaceableProfileCnt = 0;
- uint8_t existProfileQuantity = 0;
- uint8_t filename[128]={0};
- uint8_t dataLine[4096]={0};
- FILE *filePtr;
- json_object *SetChargingProfile;
- DEBUG_INFO("handleSetChargingProfileRequest...\n");
- SetChargingProfile = json_tokener_parse(payload);
- if(!is_error(SetChargingProfile))
- {
- // Required data
- if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
- SetProfileReq.evseId = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
- else
- isLostEvseId = TRUE;
- if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id") != NULL)
- SetProfileReq.chargingProfile.id = json_object_get_int((json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id")));
- if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
- {
- sprintf((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")));
- if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "stackLevel") != NULL)
- {
- SetProfileReq.chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "stackLevel"));
- }
- if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose") != NULL)
- {
- strcpy((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")));
- }
- if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfileKind") != NULL)
- {
- strcpy((char*)SetProfileReq.chargingProfile.chargingProfileKind, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfileKind")));
- }
- if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "transactionId") != NULL)
- {
- strcpy((char*)SetProfileReq.chargingProfile.transactionId, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "transactionId")));
- }
- if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "recurrencyKind") != NULL)
- {
- strcpy((char*)SetProfileReq.chargingProfile.recurrencyKind, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "recurrencyKind")));
- }
- if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validFrom") != NULL)
- {
- strcpy((char*)SetProfileReq.chargingProfile.validFrom, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validFrom")));
- }
- if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validTo") != NULL)
- {
- strcpy((char*)SetProfileReq.chargingProfile.validTo, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validTo")));
- }
- if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule") != NULL)
- {
- int chargingScheduleCount = 0;
- int chargingSchedulePeriodCount = 0;
- if(json_object_is_type(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), 5))
- {
- chargingScheduleCount = json_object_array_length(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"));
- for(int idxSchedule=0;idxSchedule<chargingScheduleCount;idxSchedule++)
- {
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingRateUnit") != NULL)
- {
- strcpy((char*)SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit, json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingRateUnit")));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "duration") != NULL)
- {
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "duration"));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "minChargingRate") != NULL)
- {
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "minChargingRate"));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "startSchedule") != NULL)
- {
- strcpy((char*)SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].startSchedule, json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "startSchedule")));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod") != NULL)
- {
- chargingSchedulePeriodCount = json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"));
- if(chargingSchedulePeriodCount <= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
- {
- for(int idxPeriod=0;idxPeriod<chargingSchedulePeriodCount;idxPeriod++)
- {
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "startPeriod") != NULL)
- {
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "limit") != NULL)
- {
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "limit"));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "numberPhases") != NULL)
- {
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "phaseToUse") != NULL)
- {
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "phaseToUse"));
- }
- // Check invalid limit
- if((strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) == NULL) ||
- ((strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL) && (ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing != 1)))
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'A')
- {
- if(((0 < SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit) && (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit < (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit[0]=='A'?6:6*220*(SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases)))) ||
- (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit > (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit[0]=='W'?modelnameInfo.ratedPower:ShmSysConfigAndInfo->SysConfig.RatingCurrent)))
- {
- DEBUG_WARN("Profile chargingSchedule-%d period-%02d is invalid limit: %.2f %s with phase %d.\n", idxSchedule, idxPeriod,
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit,
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit,
- (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- DEBUG_WARN("Rated Power: %d, Rating Current: %d\n", modelnameInfo.ratedPower, ShmSysConfigAndInfo->SysConfig.RatingCurrent);
- isInvalidLimit = TRUE;
- }
- }
- else
- {
- if((SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit*(SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit[0]=='W'?1:220*(SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases)) > modelnameInfo.ratedPower) ||
- (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit*(SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit[0]=='W'?1:220*(SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases)) < (modelnameInfo.ratedPower*0.01)))
- {
- DEBUG_WARN("Profile period-%02d is invalid limit: %.2f %s with phase %d.\n", idxPeriod,
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit,
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit,
- (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
- DEBUG_WARN("Rated Power: %d \n", modelnameInfo.ratedPower);
- isInvalidLimit = TRUE;
- }
- }
- }
- }
- }
- else
- {
- isPeriodOverMax = TRUE;
- }
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "id") != NULL)
- {
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "id"));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffDescription") != NULL)
- {
- strcpy((char*)SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffDescription, json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffDescription")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "numEPriceLevels") != NULL)
- {
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.numEPriceLevels = json_object_get_int(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "numEPriceLevels"));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry") != NULL)
- {
- int cntEntry = json_object_array_length(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"));
- if(cntEntry<=1024)
- {
- for(int idxEntry=0; idxEntry<cntEntry; idxEntry++)
- {
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "ePriceLevel") != NULL)
- {
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].ePriceLevel = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "ePriceLevel"));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "relativeTimeInterval") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "relativeTimeInterval"), "start") != NULL)
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].relativeTimeInterval.start = json_object_get_int(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "relativeTimeInterval"), "start"));
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "relativeTimeInterval"), "duration") != NULL)
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].relativeTimeInterval.duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "relativeTimeInterval"), "duration"));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost") != NULL)
- {
- uint8_t cntConCost = json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"));
- if(cntConCost<=3)
- {
- for(uint8_t idxConCost=0; idxConCost<cntConCost; idxConCost++)
- {
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "startValue") != NULL)
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].consumptionCost[idxConCost].startValue = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"));
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost") != NULL)
- {
- uint8_t cntCost = json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"));
- if(cntConCost<=3)
- {
- for(uint8_t idxCost=0; idxCost<cntCost; idxCost++)
- {
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "costKind") != NULL)
- strcpy((char*)SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].consumptionCost[idxConCost].cost[idxCost].costKind, json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "costKind")));
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "amount") != NULL)
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].consumptionCost[idxConCost].cost[idxCost].amount = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "amount"));
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "amountMultiplier") != NULL)
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].consumptionCost[idxConCost].cost[idxCost].amountMultiplier = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "amountMultiplier"));
- }
- }
- }
- }
- }
- SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].ePriceLevel = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "ePriceLevel"));
- }
- }
- }
- }
- }
- }
- }
- else
- {
- isWrongFormat = TRUE;
- }
- }
- // Check periods is over max configuration
- if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
- {
- if(SetProfileReq.evseId == 0)
- {
- sprintf((char*)filename, ChargingStationMaxProfile_JSON);
- filePtr = fopen((char*)filename, "r");
- if (!filePtr)
- {
- DEBUG_INFO("%s not exist, create it.\n", ChargingStationMaxProfile_JSON);
- filePtr = fopen((char*)filename, "w+");
- }
- else
- {
- //Check Charging Profile Count
- //while(fscanf(filePtr, "%s", dataLine) != EOF)
- char *line = NULL;
- size_t len = 0;
- while(getline(&line, &len, filePtr) != -1)
- {
- json_object *obj = NULL;
- obj = json_tokener_parse(line);
- if(is_error(obj))
- {
- DEBUG_ERROR("Parse ChargingStationMaxProfile from file error.\n");
- }
- else
- {
- if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
- (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
- {
- existProfileQuantity += 1;
- }
- else
- replaceableProfileCnt += 1;
- }
- //DEBUG_INFO("word=%s\n",word);
- /*if(strstr((char*)dataLine, "id")!= NULL)
- {
- existProfileQuantity += 1;
- }*/
- }
- DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", existProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
- if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
- {
- isStackOverMax = TRUE;
- }
- }
- fclose(filePtr);
- }
- else
- isEvseMismatch = TRUE;
- }
- else if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
- {
- if((0 < SetProfileReq.evseId) && (SetProfileReq.evseId > gunTotalNumber))
- isEvseMismatch = TRUE;
- if(!isEvseMismatch)
- {
- if(SetProfileReq.evseId == 0)
- {
- int tmpExistProfileQuantity;
- for(int idxCon=1;idxCon<=gunTotalNumber;idxCon++)
- {
- tmpExistProfileQuantity = 0;
- sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
- filePtr = fopen((char*)filename, "r");
- if (!filePtr)
- {
- DEBUG_INFO("%s not exist, create it.\n", filename);
- filePtr = fopen((char*)filename, "w+");
- }
- else
- {
- //Check Charging Profile Count
- //while(fscanf(filePtr, "%s", dataLine) != EOF)
- char *line = NULL;
- size_t len = 0;
- while(getline(&line, &len, filePtr) != -1)
- {
- json_object *obj = NULL;
- obj = json_tokener_parse(line);
- if(is_error(obj))
- {
- DEBUG_ERROR("Parse ChargingStationMaxProfile from file error.\n");
- }
- else
- {
- if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
- (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
- {
- tmpExistProfileQuantity += 1;
- }
- else
- replaceableProfileCnt += 1;
- }
- //DEBUG_INFO("word=%s\n",word);
- /*if(strstr((char*)dataLine, "id")!= NULL)
- {
- tmpExistProfileQuantity += 1;
- }*/
- }
- }
- fclose(filePtr);
- DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", tmpExistProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
- if(tmpExistProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
- {
- isStackOverMax = TRUE;
- }
- //existProfileQuantity = (existProfileQuantity < tmpExistProfileQuantity) ? tmpExistProfileQuantity : existProfileQuantity;
- }
- }
- else
- {
- sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
- filePtr = fopen((char*)filename, "r");
- if (!filePtr)
- {
- DEBUG_INFO("%s not exist, create it.\n", filename);
- filePtr = fopen((char*)filename, "w+");
- }
- else
- {
- //Check Charging Profile Count
- //while(fscanf(filePtr, "%s", dataLine) != EOF)
- char *line = NULL;
- size_t len = 0;
- while(getline(&line, &len, filePtr) != -1)
- {
- json_object *obj = NULL;
- obj = json_tokener_parse(line);
- if(is_error(obj))
- {
- DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
- }
- else
- {
- if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
- (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
- {
- existProfileQuantity += 1;
- }
- else
- replaceableProfileCnt += 1;
- }
- //DEBUG_INFO("word=%s\n",word);
- /*if(strstr((char*)dataLine, "id")!= NULL)
- {
- existProfileQuantity += 1;
- }*/
- }
- DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", existProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
- if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
- {
- isStackOverMax = TRUE;
- }
- }
- fclose(filePtr);
- }
- }
- }
- else if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
- {
- if((SetProfileReq.evseId > 0) && (SetProfileReq.evseId <= gunTotalNumber))
- sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
- else
- isEvseMismatch = TRUE;
- if(!isEvseMismatch)
- {
- filePtr = fopen((char*)filename, "r");
- if (!filePtr)
- {
- DEBUG_INFO("%s not exist, create it.\n", filename);
- filePtr = fopen((char*)filename, "w+");
- }
- else
- {
- //Check Charging Profile Count
- //while(fscanf(filePtr, "%s", dataLine) != EOF)
- char *line = NULL;
- size_t len = 0;
- while(getline(&line, &len, filePtr) != -1)
- {
- json_object *obj = NULL;
- obj = json_tokener_parse(line);
- if(is_error(obj))
- {
- DEBUG_ERROR("Parse TxProfile from file error.\n");
- }
- else
- {
- if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
- (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
- {
- existProfileQuantity += 1;
- }
- else
- replaceableProfileCnt += 1;
- }
- //DEBUG_INFO("word=%s\n",word);
- /*if(strstr((char*)dataLine, "id")!= NULL)
- {
- existProfileQuantity += 1;
- }*/
- }
- DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", existProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
- if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
- {
- isStackOverMax = TRUE;
- }
- }
- fclose(filePtr);
- if(strcmp((char*)SetProfileReq.chargingProfile.transactionId, (char*)ShmOCPP20Data->TransactionEvent[SetProfileReq.evseId-1].transactionInfo.transactionId) != 0)
- isTransactiodIdMismatch = TRUE;
- }
- }
- else if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
- {
- /*
- * TODO:
- *
- */
- }
- else
- {}
- //------------------------------Start: Check ChargingProfileEntries Logic---------------------------------------//
- {
- FILE *fp;
- char dataLine[4096]={0};
- char fnametemp[128]={0};
- int tmpProfileQuantity;
- //Check ChargePointMaxProfile.json exit
- existProfileQuantity = 0;
- if((access(ChargingStationMaxProfile_JSON,F_OK))!=-1)
- {
- fp = fopen(ChargingStationMaxProfile_JSON, "r");
- //Check Charging Profile Count
- tmpProfileQuantity = 0;
- while(fscanf(fp, "%s", dataLine) != EOF)
- {
- if(strstr(dataLine, "id")!= NULL)
- {
- existProfileQuantity += 1;
- tmpProfileQuantity += 1;
- }
- memset(dataLine, 0, ARRAY_SIZE(dataLine));
- }
- fclose(fp);
- DEBUG_INFO("ChargePointMaxProfile_OCPP20.json has %d charging Profile\n", tmpProfileQuantity);
- }
- //Check TxDefaultProfile_%d.json
- for(int idxCon=1; idxCon <= gunTotalNumber; idxCon++)
- {
- memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
- sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
- if((access(fnametemp,F_OK))!=-1)
- {
- fp = fopen(fnametemp, "r");
- //Check Charging Profile Count
- tmpProfileQuantity = 0;
- while(fscanf(fp, "%s", dataLine) != EOF)
- {
- //DEBUG_INFO("word=%s\n",word);
- if(strstr(dataLine, "id")!= NULL)
- {
- existProfileQuantity += 1;
- tmpProfileQuantity += 1;
- }
- memset(dataLine, 0, ARRAY_SIZE(dataLine));
- }
- fclose(fp);
- DEBUG_INFO("%s has %d charging Profile\n",fnametemp, tmpProfileQuantity);
- }
- }
- //Check TxProfile_%d.json
- for(int idxCon=1; idxCon <= gunTotalNumber; idxCon++)
- {
- memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
- sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d_OCPP20.json", idxCon);
- if((access(fnametemp,F_OK))!=-1)
- {
- fp = fopen(fnametemp, "r");
- //Check Charging Profile Count
- tmpProfileQuantity = 0;
- while(fscanf(fp, "%s", dataLine) != EOF)
- {
- if(strstr(dataLine, "id")!= NULL)
- {
- existProfileQuantity += 1;
- tmpProfileQuantity += 1;
- }
- memset(dataLine, 0, ARRAY_SIZE(dataLine));
- }
- fclose(fp);
- DEBUG_INFO("%s has %d charging Profile\n",fnametemp, tmpProfileQuantity);
- }
- }
- DEBUG_INFO("All purpose profile quantity: %d\n", existProfileQuantity);
- DEBUG_INFO("Replaceable profile quantity: %d\n", replaceableProfileCnt);
- // To check total Profile quantity
- if((SetProfileReq.evseId > 0) || (strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL))
- {
- if((existProfileQuantity-replaceableProfileCnt) >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
- isProfileOverMax = TRUE;
- }
- else
- {
- if((existProfileQuantity+gunTotalNumber-replaceableProfileCnt) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
- isProfileOverMax = TRUE;
- }
- }
- //------------------------------End: Check ChargingProfileEntries Logic---------------------------------------//
- }
- // Profile replace or add info
- if(!isLostEvseId && !isPeriodOverMax && !isProfileOverMax && !isEvseMismatch && !isTransactiodIdMismatch && !isInvalidLimit && !isWrongFormat && !isStackOverMax)
- {
- FILE *infile;
- FILE *outfile;
- char tmpProfileName[] = "/Storage/OCPP/SetChargingProfiletemp_OCPP20.json";
- char rmFileCmd[128];
- int tempchargingProfileIdInt;
- int tempchargingProfileStackLevelInt;
- int chkChar;
- for(int idxCon=1; idxCon <= (SetProfileReq.evseId==0?gunTotalNumber:1); idxCon++)
- {
- if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) == 0)
- {
- sprintf((char*)filename, "%s", ChargingStationMaxProfile_JSON);
- }
- else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0)
- {
- if(SetProfileReq.evseId==0)
- sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
- else
- sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
- }
- else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) == 0)
- {
- sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
- }
- else
- {
- /*
- * TODO:
- *
- */
- }
- infile = fopen ((char*)filename, "r");
- outfile = fopen ((char*)tmpProfileName, "w");
- chkChar = fgetc(infile);
- rewind(infile);
- if(chkChar == EOF)
- {
- // Profile is empty
- if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
- json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
- fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
- fclose(infile);
- fclose(outfile);
- sprintf(rmFileCmd,"rm -f %s",filename);
- system(rmFileCmd);
- rename((char*)tmpProfileName, (char*)filename);
- }
- else
- {
- // Profile is not empty
- int ChargingProfileAdded = FALSE;
- while (fgets((char*)dataLine, ARRAY_SIZE(dataLine), infile) != NULL)
- {
- dataLine[strlen((char*)dataLine) - 1] = '\0'; // eat the newline fgets() stores
- json_object *tmpChargingProfile;
- tmpChargingProfile = json_tokener_parse((char*)dataLine);
- if(!is_error(tmpChargingProfile))
- {
- if(json_object_object_get(tmpChargingProfile, "chargingProfile") != NULL)
- {
- if(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id") != NULL)
- {
- tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id"));
- DEBUG_INFO("tempchargingProfileIdInt: %d\n", tempchargingProfileIdInt);
- DEBUG_INFO("SetProfileReq.chargingProfile.id: %d\n", SetProfileReq.chargingProfile.id);
- }
- if(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "stackLevel") != NULL)
- {
- tempchargingProfileStackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "stackLevel"));
- DEBUG_INFO("tempchargingProfileStackLevelInt: %d\n", tempchargingProfileStackLevelInt);
- DEBUG_INFO("SetProfileReq.chargingProfile.stackLevel: %d\n", SetProfileReq.chargingProfile.stackLevel);
- }
- }
- }
- json_object_put(tmpChargingProfile);
- if((tempchargingProfileIdInt == SetProfileReq.chargingProfile.id) || (tempchargingProfileStackLevelInt == SetProfileReq.chargingProfile.stackLevel))
- {
- if(ChargingProfileAdded == FALSE)
- {
- if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
- json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
- fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
- ChargingProfileAdded = TRUE;
- }
- }
- else
- {
- fprintf(outfile,"%s\n",dataLine);
- if(ChargingProfileAdded == FALSE)
- {
- if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
- json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
- fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
- ChargingProfileAdded = TRUE;
- }
- }
- } // end of while loop
- fclose(infile);
- fclose(outfile);
- sprintf(rmFileCmd,"rm -f %s",filename);
- system(rmFileCmd);
- rename((char*)tmpProfileName, (char*)filename);
- }
- }
- sleep(1);
- sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
- result = PASS;
- }
- else
- {
- if(isLostEvseId)
- DEBUG_WARN("Connector id is wrong.\n");
- if(isEvseMismatch)
- DEBUG_WARN("Connector id is mismatch.\n");
- if(isPeriodOverMax)
- DEBUG_WARN("Profile periods quantity is over spec.\n");
- if(isProfileOverMax)
- DEBUG_WARN("Profile quantity is over spec.\n");
- if(isTransactiodIdMismatch)
- DEBUG_WARN("Transaction id is mismatch.\n");
- if(isInvalidLimit)
- DEBUG_WARN("Limit value is invalid.\n");
- if(isStackOverMax)
- DEBUG_WARN("Profile stack is over spec.\n");
- if(isWrongFormat)
- DEBUG_WARN("Profile format is wrong.\n");
- sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
- }
- }
- json_object_put(SetChargingProfile);
- if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
- {
- if(SetProfileReq.evseId == 0)
- {
- for(uint8_t idx=0;idx<gunTotalNumber;idx++)
- {
- //ShmOCPP20Data->CSUMsg.bits[idx].ChargingProfileReq = ON;
- checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
- checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
- }
- }
- else
- {
- //ShmOCPP20Data->CSUMsg.bits[SetProfileReq.evseId-1].ChargingProfileReq = ON;
- checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
- checkCompositeSchedule(SetProfileReq.evseId, 86400, &ShmOCPP20Data->SmartChargingProfile[SetProfileReq.evseId-1], 0, TRUE);
- }
- }
- sendSetChargingProfileConfirmation(uuid, (SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1));
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- return result;
- }
- int handleSetDisplayMessageRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *SetDisplayMessage;
- DEBUG_INFO("handleSetDisplayMessageRequest...\n");
- SetDisplayMessage = json_tokener_parse(payload);
- if(!is_error(SetDisplayMessage))
- {
- memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
- memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
- // Required data
- if(json_object_object_get(SetDisplayMessage, "message") != NULL)
- {
- if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
- ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
- if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
- sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
- if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
- sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
- if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
- sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
- if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
- sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
- if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
- sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
- if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
- sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.format, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
- sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.language, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
- sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.content, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content")));
- }
- if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
- 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"));
- if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
- 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"));
- }
- }
- }
- }
- json_object_put(SetDisplayMessage);
- strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
- sendSetDisplayMessagesConfirmation(uuid);
- // Announce CSU there is display request come from server
- ShmOCPP20Data->MsMsg.bits.SetDisplayMessageReq = ON;
- return result;
- }
- int handleSetMonitoringBaseRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *SetMonitoringBase;
- DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
- SetMonitoringBase = json_tokener_parse(payload);
- strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
- if(!is_error(SetMonitoringBase))
- {
- memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
- memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
- // Required data
- if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
- sprintf((char*)ShmOCPP20Data->MonitoringBase, "%s", (char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase);
- FILE *outfile;
- outfile = fopen("/Storage/OCPP/MonitorSetting" , "w+");
- if(outfile == NULL)
- {
- DEBUG_INFO("Error opening file");
- strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
- }
- fprintf(outfile,"{\"severity\":\"%d\",\"monitoringBase\":\"%s\"}\n", ShmOCPP20Data->MonitoringLevel, (char*)ShmOCPP20Data->MonitoringBase);
- fclose(outfile);
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- }
- else
- strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Rejected]);
- }
- json_object_put(SetMonitoringBase);
- sendSetMonitoringBaseConfirmation(uuid);
- return result;
- }
- int handleSetMonitoringLevelRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *SetMonitoringLevel;
- DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
- SetMonitoringLevel = json_tokener_parse(payload);
- strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
- if(!is_error(SetMonitoringLevel))
- {
- memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
- memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
- // Required data
- if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
- {
- ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
- ShmOCPP20Data->MonitoringLevel = ShmOCPP20Data->SetMonitoringLevel.severity;
- FILE *outfile;
- outfile = fopen("/Storage/OCPP/MonitorSetting" , "w+");
- if(outfile == NULL)
- {
- DEBUG_INFO("Error opening file");
- strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
- }
- fprintf(outfile,"{\"severity\":\"%d\",\"monitoringBase\":\"%s\"}\n", ShmOCPP20Data->MonitoringLevel, (char*)ShmOCPP20Data->MonitoringBase);
- fclose(outfile);
- system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
- }
- else
- strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
- }
- json_object_put(SetMonitoringLevel);
- sendSetMonitoringLevelConfirmation(uuid);
- return result;
- }
- int handleSetNetworkProfileRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *SetNetworkProfile;
- DEBUG_INFO("handleSetNetworkProfileRequest...\n");
- SetNetworkProfile = json_tokener_parse(payload);
- if(!is_error(SetNetworkProfile))
- {
- memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
- memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
- // Required data
- if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
- ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
- if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
- {
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
- sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
- {
- if(strcmp(json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")), "JSON") == 0)
- {
- sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Rejected]);
- goto end;
- }
- }
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
- if((strncmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl,"wss", 3) == 0) || (strncmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl,"ws", 2) == 0))
- {
- char protocol[10], host[128], path[512], port[10];
- int check = sscanf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl,"%[^:]:%*2[/]%[^:]:%[^/]/%199[^\n]", protocol, host, port, path);
- if(check >= 3)
- {
- DEBUG_INFO("URL: %s\n", ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl);
- DEBUG_INFO("protocol: %s\n",protocol);
- DEBUG_INFO("host: %s\n",host);
- DEBUG_INFO("port: %s\n",port);
- DEBUG_INFO("path: %s\n",path);
- memcpy((char*)ShmOCPP20Data->OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Rejected]);
- goto end;
- }
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Rejected]);
- goto end;
- }
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Rejected]);
- goto end;
- }
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
- ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
- sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
- 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")));
- }
- if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
- {
- memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
- 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")));
- strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
- }
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
- {
- memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
- 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")));
- strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
- }
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
- {
- memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
- 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")));
- strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
- }
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
- 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"));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
- 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"));
- if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
- 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")));
- }
- DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
- }
- }
- json_object_put(SetNetworkProfile);
- /*
- * TODO:
- * 1. Process network configuration and response
- */
- if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
- {
- }
- else
- {
- }
- if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
- {
- }
- else
- {
- }
- if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
- {
- }
- else
- {
- }
- if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
- {
- }
- else
- {
- }
- if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
- {
- }
- else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
- {
- }
- else
- {
- }
- strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
- end:
- sendSetNetworkProfileConfirmation(uuid);
- return result;
- }
- int handleSetVariableMonitoringRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *SetVariableMonitoring;
- uint8_t variableQuantity = 0;
- DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
- SetVariableMonitoring = json_tokener_parse(payload);
- if(!is_error(SetVariableMonitoring))
- {
- memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
- memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
- // Required data
- for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
- {
- variableQuantity++;
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
- {
- 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"));
- ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
- {
- 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"));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
- {
- 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")));
- strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type, "Actual");
- strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
- {
- 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"));
- ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
- {
- 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"));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "name") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[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, "setMonitoringData"), idx), "component"), "name")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "instance") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[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, "setMonitoringData"), idx), "component"), "instance")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "evse") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "evse"), "id") != NULL)
- {
- ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[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, "setMonitoringData"), idx), "component"), "instance"), "id"));
- }
- if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "evse"), "connectorId") != NULL)
- {
- ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[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, "setMonitoringData"), idx), "component"), "instance"), "connectorId"));
- }
- }
- memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable"), "name") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[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, "setMonitoringData"), idx), "variable"), "name")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable"), "instance") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[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, "setMonitoringData"), idx), "variable"), "instance")));
- }
- memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
- }
- uint8_t isDuplicate = FALSE;
- for(uint8_t idx_vm=0;idx_vm<10;idx_vm++)
- {
- if((strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx_vm].component.name, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component.name) != NULL) &&
- (strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx_vm].variable.name, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable.name) != NULL) &&
- (strstr((char*)ShmOCPP20Data->MonitoringComponentVariable[idx_vm].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type) != NULL) &&
- (ShmOCPP20Data->MonitoringComponentVariable[idx_vm].severity == ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity))
- {
- isDuplicate = TRUE;
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
- {
- if(ShmOCPP20Data->MonitoringComponentVariable[idx_vm].id == ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id)
- {
- VariableMonitoringReplace((idx_vm+1), &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx]);
- strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, SetMonitoringStatusEnumTypeStr[SetMonitoringStatusEnumType_Accepted]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, SetMonitoringStatusEnumTypeStr[SetMonitoringStatusEnumType_Duplicate]);
- }
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, SetMonitoringStatusEnumTypeStr[SetMonitoringStatusEnumType_Duplicate]);
- }
- break;
- }
- else
- {
- // Do nothing
- }
- }
- if(isDuplicate == FALSE)
- {
- if(variableMonitoringQuantity() >= 10)
- {
- strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, SetMonitoringStatusEnumTypeStr[SetMonitoringStatusEnumType_Rejected]);
- }
- else
- {
- DB_variableMonitoringSaveToDb(&ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx]);
- strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, SetMonitoringStatusEnumTypeStr[SetMonitoringStatusEnumType_Accepted]);
- }
- }
- }
- }
- json_object_put(SetVariableMonitoring);
- sendSetVariableMonitoringConfirmation(uuid, variableQuantity);
- return result;
- }
- int handleSetVariablesRequest(char *uuid, char *payload)
- {
- mtrace();
- uint8_t result = FAIL;
- uint8_t isUnknownComponent = TRUE;
- uint8_t isNeedReconnect = FALSE;
- json_object *SetVariables;
- DEBUG_INFO("handleSetVariablesRequest...\n");
- SetVariables = json_tokener_parse(payload);
- if(!is_error(SetVariables))
- {
- memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
- memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
- // Required data
- for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
- {
- if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
- {
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
- {
- 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)
- {
- ShmOCPP20Data->SetVariables.setVariableData[idx].component.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse"), "id"));
- }
- 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)
- {
- ShmOCPP20Data->SetVariables.setVariableData[idx].component.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse"), "connectorId"));
- }
- }
- memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
- {
- 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")));
- }
- if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
- {
- 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")));
- }
- memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
- {
- 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")));
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
- }
- if(strlen((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType) == 0)
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, "Actual");
- }
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
- {
- 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")));
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
- for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
- {
- if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
- (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) &&
- (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
- (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))
- {
- isUnknownComponent = FALSE;
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- //DEBUG_INFO("Checking variable...[%s][%s], dataType: %s\n",ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.dataType);
- if(strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.dataType,DataEnumTypeStr[DataEnumType_decimal]) == 0)
- {
- if(isNumber(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,TRUE)!=YES)
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.dataType,DataEnumTypeStr[DataEnumType_integer]) == 0)
- {
- if(isNumber(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue, FALSE)!=YES)
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.dataType,DataEnumTypeStr[DataEnumType_dateTime]) == 0)
- {
- if(isMatchTimeFormat(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)!=YES)
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.dataType,DataEnumTypeStr[DataEnumType_boolean]) == 0)
- {
- // To make sure all boolean value is in uppercase
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"true") != NULL) ||
- (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"True") != NULL) ||
- (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"TRUE") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"true");
- }
- else if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"false") != NULL) ||
- (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"False") != NULL) ||
- (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"FALSE") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"false");
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- }
- if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType) == NULL) &&
- (json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_NotSupportedAttributeType]);
- break;
- }
- if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]) != NULL)
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "AuthCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "Enabled") != NULL))
- {
- char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
- for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
- tmp[tmpidx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
- if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "true" : "false");
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- if(strstr((char*)tmp, "true") != NULL)
- {
- ShmSysConfigAndInfo->SysConfig.AuthorisationMode = AUTH_MODE_ENABLE;
- }
- else
- {
- ShmSysConfigAndInfo->SysConfig.AuthorisationMode = AUTH_MODE_DISABLE;
- }
- //StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- }
- if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
- }
- else
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "WebSocketPingInterval") != NULL))
- {
- if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < 10) )
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- else
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "HeartbeatInterval") != NULL))
- {
- if((atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- }
- else
- HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "StatusNotificationPeriodically") != NULL))
- {
- char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
- for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
- tmp[tmpidx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
- if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "true" : "false");
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "StatusNotificationInterval") != NULL))
- {
- if((atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- }
- else
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "CharingProfileRefreshInterval") != NULL))
- {
- if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- else
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "MessageAttempts") != NULL))
- {
- if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- else
- {
- TransactionMessageAttemptsValue = atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "MessageAttemptInterval") != NULL))
- {
- if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- else
- {
- TransactionMessageRetryIntervalValue = atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "RfidEndianType") != NULL))
- {
- char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
- for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
- tmp[tmpidx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
- if((strstr((char*)tmp, "big") != NULL) || (strstr((char*)tmp, "little") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "big") != NULL)? "big" : "little");
- ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian = (strstr((char*)tmp, "big") != NULL)?1:0;
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "AuthorizeTimeout") != NULL))
- {
- if((atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) <=0) ||
- (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) ||
- (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) > (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.maxLimit))
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- else
- {
- TransactionMessageRetryIntervalValue = atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "Enable15118") != NULL))
- {
- char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
- for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
- tmp[tmpidx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
- if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "true" : "false");
- ShmSysConfigAndInfo->SysConfig.isEnable15118 = (strstr((char*)tmp, "true") != NULL)?1:0;
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SecurityCtrlr") != NULL) &&
- ((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "SecurityProfile") != NULL) || (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "BasicAuthPassword") != NULL)))
- {
- isNeedReconnect = TRUE;
- //StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
- //SetOcppConnStatus(FALSE);
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "AlignedDataCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "Interval") != NULL))
- {
- if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- }
- else
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "AlignedDataCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "SendDuringIdle") != NULL))
- {
- char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
- for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
- tmp[tmpidx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
- if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "true" : "false");
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "AlignedDataCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "SignReadings") != NULL))
- {
- char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
- for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
- tmp[tmpidx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
- if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "true" : "false");
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- else
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
- break;
- }
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SampledDataCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "TxUpdatedInterval") != NULL))
- {
- if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- }
- else
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "ChargingStation") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "FreeVend") != NULL))
- {
- char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
- for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
- tmp[tmpidx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
- if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "true" : "false");
- ShmSysConfigAndInfo->SysConfig.AuthorisationMode =((strstr((char*)tmp, "true") != NULL)? 1 : 0);
- //StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "ChargingStation") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "FreeVendIdtag") != NULL))
- {
- if(strlen((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) > 20)
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- }
- else
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "ChargingStation") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "OffLineMaxChargingPower") != NULL))
- {
- if(atoi((const char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) > modelnameInfo.ratedPower)
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
- }
- else
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
- }
- if((strstr((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]) != NULL) ||
- (strstr((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]) != NULL))
- {
- strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
- DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
- }
- break;
- }
- else
- {
- // When there is no matched variable, check the component name again
- if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL)
- {
- isUnknownComponent = FALSE;
- }
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownVariable]);
- }
- }
- if(isUnknownComponent == TRUE)
- {
- strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
- }
- }
- }
- }
- StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
- sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
- if(isNeedReconnect)
- {
- SetOcppConnStatus(FALSE);
- }
- }
- json_object_put(SetVariables);
- return result;
- }
- int handleTriggerMessageRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int evseIdIsNULL = FALSE;
- //int connectorIdIsNULL = FALSE;
- int evseIdInt =0;
- //int connectorIdInt =0;
- json_object *TriggerMessage;
- DEBUG_INFO("handleTriggerMessageRequest\n");
- TriggerMessage = json_tokener_parse(payload);
- if(!is_error(TriggerMessage))
- {
- memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
- memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
- // Required data
- if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
- sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
- // Optional data
- if(json_object_object_get(TriggerMessage, "evse") != NULL)
- {
- // Required data
- if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
- {
- ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
- evseIdInt = ShmOCPP20Data->TriggerMessage.evse.id;
- }
- else
- evseIdIsNULL = TRUE;
- // Optional data
- if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
- {
- ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
- //connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
- }
- //else
- //connectorIdIsNULL = TRUE;
- }
- else
- evseIdIsNULL = TRUE;
- }
- json_object_put(TriggerMessage);
- if((evseIdIsNULL == TRUE) || ((evseIdIsNULL == FALSE) && ((evseIdInt > 0) && (evseIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
- {
- if((strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
- (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
- {
- sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
- sendTriggerMessageConfirmation(uuid);
- return TRUE;
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
- sendTriggerMessageConfirmation(uuid);
- }
- }
- else if(evseIdIsNULL == FALSE && ((evseIdInt <= 0) || (evseIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
- {
- sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
- sendTriggerMessageConfirmation(uuid);
- return TRUE;
- }
- //==========================
- // Trigger message
- //==========================
- if( strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
- {
- if((strlen((char*)ShmOCPP20Data->FirmwareStatusNotification.status) == 0) ||
- ((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing)))
- {
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
- }
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- }
- else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
- {
- if(strlen((char*)ShmOCPP20Data->LogStatusNotification.status) == 0)
- sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Idle]);
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
- }
- else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
- {
- if(server_sign)
- {
- sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
- sendTriggerMessageConfirmation(uuid);
- return TRUE;
- }
- else
- {
- if(DB_updateBootType(BootReasonEnumType_Triggered))
- server_sign = FALSE;
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
- {
- refreshStartTimer(&clientTime.Heartbeat);
- clientTime.Heartbeat.tv_sec -= ShmOCPP20Data->BootNotification.Response_interval;
- }
- else if (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
- {
- if(evseIdIsNULL == FALSE)
- {
- if((evseIdInt > 0) && ((evseIdInt-1) < gunTotalNumber))
- {
- cpinitateMsg.bits[evseIdInt-1].TriggerMeterValueReq = ON;
- }
- }
- else
- {
- for(int idx=0;idx< gunTotalNumber;idx++)
- {
- cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
- }
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
- {
- if(evseIdIsNULL == FALSE)
- {
- if((evseIdInt > 0) && ((evseIdInt-1) < gunTotalNumber))
- {
- cpinitateMsg.bits[evseIdInt-1].TriggerStatusNotificationReq = ON;
- //clientTime.StatusNotification[connectorIdInt-1] = time((time_t*)NULL);
- }
- }
- else
- {
- for(int idx=0;idx< gunTotalNumber;idx++)
- {
- cpinitateMsg.bits[idx].TriggerStatusNotificationReq = ON;
- //clientTime.StatusNotification[idx] = time((time_t*)NULL);
- }
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0 )
- {
- ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
- if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
- {
- 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\" &");
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) == 0 )
- {
- ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
- if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
- {
- 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\" &");
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) == 0 )
- {
- if(evseIdIsNULL == FALSE)
- {
- if((evseIdInt > 0) && ((evseIdInt -1) < gunTotalNumber))
- {
- //ShmOCPP20Data->CpMsg.bits[connectorIdInt -1].TransactionEventReq = ON;
- cpinitateMsg.bits[evseIdInt -1].TriggerTransactionEventReq = ON;
- }
- }
- else
- {
- for(int idx=0;idx< gunTotalNumber;idx++)
- {
- //ShmOCPP20Data->CpMsg.bits[idx].TransactionEventReq = ON;
- cpinitateMsg.bits[idx].TriggerTransactionEventReq = ON;
- }
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) == 0 )
- {
- ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
- if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
- {
- 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\" &");
- }
- if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
- {
- 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\" &");
- }
- }
- else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) == 0 )
- {
- ShmOCPP20Data->MsMsg.bits.PublishFirmwareReq = ON;
- }
- return result;
- }
- int handleUnlockConnectorRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int evseIdInt =0;
- int tempIndex = 0;
- json_object *UnlockConnector;
- DEBUG_INFO("handleUnlockConnectorRequest ...\n");
- UnlockConnector = json_tokener_parse(payload);
- if(!is_error(UnlockConnector))
- {
- if(json_object_object_get(UnlockConnector, "evseId") != NULL)
- {
- evseIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
- ShmOCPP20Data->UnlockConnector[(evseIdInt>0?evseIdInt-1:0)].evseId = evseIdInt;
- //it should not be array!!
- }
- if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
- {
- if(json_object_get_int(json_object_object_get(UnlockConnector, "connectorId")) != 1)
- {
- sprintf((char*)ShmOCPP20Data->UnlockConnector[evseIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
- goto end;
- }
- }
- }
- json_object_put(UnlockConnector);
- DEBUG_INFO("Unlock evseIdInt = %d\n",evseIdInt);
- if(gunTotalNumber == 0)
- {
- sprintf((char*)ShmOCPP20Data->UnlockConnector[evseIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
- goto end;
- }
- else if((evseIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (evseIdInt <= 0))
- {
- sprintf((char*)ShmOCPP20Data->UnlockConnector[evseIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
- goto end;
- }
- else
- {
- memset(&ShmOCPP20Data->UnlockConnector[evseIdInt-1], 0, sizeof(struct UnlockConnector_20));
- memcpy(&ShmOCPP20Data->UnlockConnector[evseIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[evseIdInt-1].guid));
- //check Transaction active
- if(gunType[evseIdInt-1] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = (((evseIdInt -1)==2) ? 1: 0);
- }
- else
- {
- tempIndex = evseIdInt -1;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ))
- {
- //stop Transaction
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].UnlockConnectorReq = ON;
- }
- }
- }
- else if(gunType[evseIdInt-1] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = (((evseIdInt -1)==2) ? 1: 0);
- }
- else
- {
- tempIndex = evseIdInt -1;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ))
- {
- //stop Transaction
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].UnlockConnectorReq = ON;
- }
- }
- }
- else if(gunType[evseIdInt-1] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = (((evseIdInt -1)==2) ? 1: 0);
- }
- else
- {
- tempIndex = evseIdInt -1;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ))
- {
- //stop Transaction
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].UnlockConnectorReq = ON;
- }
- }
- }
- else if(gunType[evseIdInt-1] == GUN_TYPE_DO)
- {
- tempIndex = evseIdInt -1;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex ))
- {
- //stop Transaction
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].UnlockConnectorReq = ON;
- }
- }
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = evseIdInt-1;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ))
- {
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].UnlockConnectorReq = ON;
- }
- }
- }
- ShmOCPP20Data->UnlockConnector[evseIdInt-1].connectorId = evseIdInt;
- strcpy((char *)ShmOCPP20Data->UnlockConnector[evseIdInt-1].guid, uuid);
- result = TRUE;
- return result;
- }
- end:
- ShmOCPP20Data->CsMsg.bits[evseIdInt-1].UnlockConnectorConf = ON;
- return result;
- }
- int handleUnpublishFirmwareRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- json_object *UnpublishFirmware;
- DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
- UnpublishFirmware = json_tokener_parse(payload);
- if(!is_error(UnpublishFirmware))
- {
- memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
- memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
- // Required data
- if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
- sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
- }
- json_object_put(UnpublishFirmware);
- ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
- /*
- * TODO:
- * 1. Check unpublished status
- */
- sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
- sendUnpublishFirmwareConfirmation(uuid);
- return result;
- }
- static char UpdateFirmwarepayloadData[512]={0};
- void *UpdateFirmwareProcess(void *data)
- {
- pthread_detach(pthread_self());
- mtrace();
- char protocol[10], user[64],password[64],host[128], path[512], ftppath[512],host1[128],path1[512];
- int port=0;
- int isSuccess = 0;
- char ftpbuf[1024];
- char temp[1024];
- char * pch;
- DEBUG_INFO("handleUpdateFirmwareRequest...\n");
- json_object *UpdateFirmware;
- UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
- if(!is_error(UpdateFirmware))
- {
- // Required data
- if(json_object_object_get(UpdateFirmware, "requestId"))
- {
- ShmOCPP20Data->UpdateFirmware.requestId = json_object_get_int(json_object_object_get(UpdateFirmware, "requestId"));
- }
- if(json_object_object_get(UpdateFirmware, "firmware"))
- {
- if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location") != NULL)
- sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location")));
- if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate") != NULL)
- sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate")));
- if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime") != NULL)
- sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.installDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime")));
- if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate") != NULL)
- sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.signingCertificate, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate")));
- if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature") != NULL)
- sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.signature, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature")));
- }
- // Optional data
- if(json_object_object_get(UpdateFirmware, "retries"))
- {
- ShmOCPP20Data->UpdateFirmware.retries = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
- }
- if(json_object_object_get(UpdateFirmware, "retryInterval"))
- {
- ShmOCPP20Data->UpdateFirmware.retryInterval = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
- }
- }
- json_object_put(UpdateFirmware);
- memset(ftppath, 0, ARRAY_SIZE(ftppath));
- memset(path, 0, ARRAY_SIZE(path));
- // Wait retrieveData
- if(strlen((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime) > 10)
- {
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- do
- {
- sleep(1);
- }while(!isOvertNow(ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime));
- }
- system("rm -f /mnt/*");
- if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"http", 4) == 0)
- {
- sscanf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
- sprintf(ftppath,"/%s", path);
- DEBUG_INFO("locationstr: %s\n", ShmOCPP20Data->UpdateFirmware.firmware.location);
- DEBUG_INFO("protocol: %s\n",protocol);
- DEBUG_INFO("host: %s\n",host);
- DEBUG_INFO("path: %s\n",path);
- DEBUG_INFO("ftppath: %s\n",ftppath);
- int ftppathlen=strlen(ftppath);
- int i=1;
- char filenametemp[50];
- while(i < ftppathlen)
- {
- int len=ftppathlen-i;
- if(ftppath[len]== 47) // '/' ascll code: 47
- {
- DEBUG_INFO("compare '/' all right\n");
- break;
- }
- i=i+1;
- }
- memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
- strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
- filenametemp[i+1] = 0;
- do
- {
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- sleep(3);
- isSuccess = httpDownLoadFile(host, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
- if(!isSuccess)
- {
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- }
- else
- {
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- }
- ShmOCPP20Data->UpdateFirmware.retries--;
- }while((isSuccess == 0)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
- }
- else if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"ftp", 3) == 0)
- {
- memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
- memset(temp, 0, ARRAY_SIZE(temp));
- strcpy(ftpbuf, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
- int ftppathlen=strlen(ftpbuf);
- int i=1;
- char filenametemp[50];
- while(i < ftppathlen)
- {
- int len=ftppathlen-i;
- if(ftpbuf[len]== 47) // '/' ascll code: 47
- {
- DEBUG_INFO(" compare '/' all right\n");
- break;
- }
- i=i+1;
- }
- memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
- strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
- filenametemp[i+1] = 0;
- strncpy(temp, ftpbuf, ftppathlen-i+1);
- pch=strchr(temp,'@');
- if(pch==NULL)
- {
- sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
- protocol, host, &port, path);
- strcpy(user,"anonymous");
- strcpy(password,"");
- }
- else
- {
- sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
- protocol, user, password, host, &port, path);
- }
- sscanf(host,"%[^/]%s",host1, path1);
- sprintf(ftppath,"%s", path1);
- if(port == 0)
- {
- port = 21;
- }
- do
- {
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- sleep(3);
- isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
- if(!isSuccess)
- {
- //BulldogUtil.sleepMs(interval*1000);
- DEBUG_INFO("Update firmware request and download file fail.\n");
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- }
- else
- {
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- }
- ShmOCPP20Data->UpdateFirmware.retries--;
- }while((!isSuccess)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
- }
- else
- {
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- sleep(1);
- ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
- sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
- }
- if(strstr((char*)ShmOCPP20Data->FirmwareStatusNotification.status, FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]) != NULL)ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
- interLock.isUpdateFirmwareGoing = OFF;
- pthread_exit(NULL);
- }
- int handleUpdateFirmwareRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- pthread_t t;
- sendUpdateFirmwareConfirmation(uuid);
- memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
- strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
- memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
- if(!interLock.isUpdateFirmwareGoing)
- {
- interLock.isUpdateFirmwareGoing = ON;
- pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
- sleep(1);
- }
- else
- DEBUG_WARN("Other UpdateFirmware request on going.\n");
- ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
- return result;
- }
- int handleUnknownRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- DEBUG_INFO("handleUnknownRequest...\n");
- sendUnknownConfirmation(uuid);
- result = PASS;
- return result;
- }
- //==========================================
- // Handle server response routine
- //==========================================
- void handleAuthorizeResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleAuthorizeResponse...\n");
- json_object *Authorize;
- Authorize = json_tokener_parse(payload);
- if(!is_error(Authorize))
- {
- if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
- {
- // Required data
- sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
- // Optional data
- if(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
- sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
- else
- memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
- if(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority") != NULL)
- ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
- if(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1") != NULL)
- sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
- if(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "evseId") != NULL)
- {
- for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTokenInfo"), "evseId"));idx++)
- {
- 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));
- }
- }
- if(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2") != NULL)
- sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
- if(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
- 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")));
- else
- memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
- if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
- 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")));
- }
- if(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
- 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")));
- }
- }
- if(json_object_object_get(Authorize, "certificateStatus") != NULL)
- {
- strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
- }
- }
- json_object_put(Authorize);
- //Update idTag information to authorization cache if supported
- if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "true") == 0) &&
- /*(strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
- (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&*/
- strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
- {
- DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
- }
- ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
- ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
- authorizeRetryTimes = 0;
- }
- void handleBootNotificationResponse(char *payload, int gun_index)
- {
- mtrace();
- char statusStr[12]={0};
- char currentTimeStr[30]={0};
- int intervalInt = 0;
- DEBUG_INFO("handleBootNotificationResponse...\n");
- json_object *BootNotification;
- BootNotification = json_tokener_parse(payload);
- if(!is_error(BootNotification))
- {
- // Required data
- sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
- intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
- sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
- }
- json_object_put(BootNotification);
- DEBUG_INFO("statusStr: %s\n", statusStr);
- ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
- BootNotificationInterval = intervalInt;
- //write back to ShmOCPP20Data->BootNotification
- strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
- strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
- if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
- {
- if(intervalInt < (int)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.minLimit)
- {
- //Do nothing because the value is out of range.
- }
- else
- {
- sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value,"%d", HeartBeatWaitTime);
- HeartBeatWaitTime = intervalInt;
- DEBUG_INFO("BootNotificationResponse setting interval to %d...\n",intervalInt);
- }
- server_sign = TRUE;
- server_pending =FALSE;
- DB_updateBootType(BootReasonEnumType_PowerUp);
- ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = ON;
- }
- else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
- {
- server_pending = TRUE;
- }
- syncDateTimeRTC(ShmOCPP20Data->BootNotification.Response_currentTime);
- srand(time(NULL));
- refreshStartTimer(&clientTime.Heartbeat);
- clientTime.Heartbeat.tv_sec -= (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
- SetOcppConnStatus(TRUE);
- ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
- }
- void handleClearedChargingLimitResponse(char *payload, int gun_index)
- {
- mtrace();
- json_object *ClearedChargingLimit;
- DEBUG_INFO("handleClearedChargingLimitResponse...\n");
- ClearedChargingLimit = json_tokener_parse(payload);
- if(!is_error(ClearedChargingLimit))
- {
- // Required data
- if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
- sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
- }
- json_object_put(ClearedChargingLimit);
- ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
- ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitConf = ON;
- }
- void handleDataTransferResponse(char *payload, int gun_index)
- {
- mtrace();
- json_object *DataTrans;
- DEBUG_INFO("handleDataTransferResponse...\n");
- DataTrans = json_tokener_parse(payload);
- if(!is_error(DataTrans))
- {
- // Required data
- if(json_object_object_get(DataTrans,"status") != NULL)
- sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
- // Optional data
- if(json_object_object_get(DataTrans,"data") != NULL)
- sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
- }
- json_object_put(DataTrans);
- ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
- ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
- }
- void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
- ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
- }
- void handleGet15118EVCertificateResponse(char *payload, int gun_index)
- {
- mtrace();
- json_object *Get15118EVCertificate;
- DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
- Get15118EVCertificate = json_tokener_parse(payload);
- if(!is_error(Get15118EVCertificate))
- {
- // Required data
- if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
- sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
- // Optional data
- if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
- sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
- }
- json_object_put(Get15118EVCertificate);
- ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
- ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
- }
- void handleGetCertificateStatusResponse(char *payload, int gun_index)
- {
- mtrace();
- json_object *GetCertificateStatus;
- DEBUG_INFO("handleGetCertificateStatusResponse...\n");
- GetCertificateStatus = json_tokener_parse(payload);
- if(!is_error(GetCertificateStatus))
- {
- // Required data
- if(json_object_object_get(GetCertificateStatus,"status") != NULL)
- sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
- // Optional data
- if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
- sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
- if(json_object_object_get(GetCertificateStatus,"statusInfo") != NULL)
- {
- if(json_object_object_get(json_object_object_get(GetCertificateStatus,"statusInfo"), "reasonCode") != NULL)
- sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(GetCertificateStatus,"ocspResult"), "reasonCode")));
- if(json_object_object_get(json_object_object_get(GetCertificateStatus,"statusInfo"), "additionalInfo") != NULL)
- sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(GetCertificateStatus,"ocspResult"), "additionalInfo")));
- }
- }
- json_object_put(GetCertificateStatus);
- if(strstr((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, GetCertificateStatusEnumTypeStr[GetCertificateStatusEnumType_Accepted]) != NULL)
- {
- /*
- * TODO:
- * 1. If get certificate response accepted process something here
- */
- }
- ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
- ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
- }
- void handleHeartbeatResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleHeartbeatResponse...\n");
- json_object *Heartbeat;
- Heartbeat = json_tokener_parse(payload);
- if(!is_error(Heartbeat))
- {
- // Required data
- if(json_object_object_get(Heartbeat,"currentTime") != NULL)
- sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
- }
- json_object_put(Heartbeat);
- if(FirstHeartBeat == OFF)
- {
- FirstHeartBeat = ON;
- DEBUG_INFO("FirstHeartBeat \n");
- }
- HeartBeatWithNOResponse = 0;
- refreshStartTimer(&clientTime.Heartbeat);
- syncDateTimeRTC(ShmOCPP20Data->Heartbeat.Response_currentTime);
- }
- void handleLogStatusNotificationResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleLogStatusNotificationResponse...\n");
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
- ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
- }
- void handleMeterValuesResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleMeterValuesResponse...\n");
- isQueueSendable = ON;
- }
- void handleNotifyChargingLimitResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
- ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
- ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
- }
- void handleNotifyCustomerInformationResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleNotifyCustomerInformationResponse...\n");
- }
- void handleNotifyDisplayMessagesResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleNotifyDisplayMessagesResponse...\n");
- ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
- ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
- }
- void handleNotifyEVChargingNeedsResponse(char *payload, int gun_index)
- {
- mtrace();
- json_object *NotifyEVChargingNeeds;
- DEBUG_INFO("handleNotifyEVChargingNeedsResponse...\n");
- NotifyEVChargingNeeds = json_tokener_parse(payload);
- if(!is_error(NotifyEVChargingNeeds))
- {
- // Required data
- if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
- sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
- }
- json_object_put(NotifyEVChargingNeeds);
- //ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
- //ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
- ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq = OFF;
- ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsConf = ON;
- }
- void handleNotifyEVChargingScheduleResponse(char *payload, int gun_index)
- {
- mtrace();
- json_object *NotifyEVChargingSchedule;
- DEBUG_INFO("handleNotifyEVChargingScheduleResponse...\n");
- NotifyEVChargingSchedule = json_tokener_parse(payload);
- if(!is_error(NotifyEVChargingSchedule))
- {
- // Required data
- if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
- sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
- }
- json_object_put(NotifyEVChargingSchedule);
- ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingScheduleReq = OFF;
- ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingScheduleConf = ON;
- }
- void handleNotifyEventResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleNotifyEventResponse...\n");
- ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
- ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
- }
- void handleNotifyMonitoringReportResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleNotifyMonitoringReportResponse...\n");
- ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
- ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
- }
- void handleNotifyReportResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleNotifyReportResponse...\n");
- ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
- ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
- }
- void handlePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handlePublishFirmwareStatusNotificationResponse...\n");
- ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
- ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
- }
- void handleReportChargingProfilesResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleReportChargingProfilesResponse...gun_index: %d\n", gun_index);
- ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
- ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
- }
- void handleReservationStatusUpdateResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
- ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
- ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
- }
- void handleSecurityEventNotificationResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleSecurityEventNotificationResponse...\n");
- ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
- ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
- DB_updateSecurityEventType(SecurityEventEnumType_ResetOrReboot);
- }
- void handleSignCertificateResponse(char *payload, int gun_index)
- {
- mtrace();
- json_object *SignCertificate;
- DEBUG_INFO("handleSignCertificateResponse...\n");
- SignCertificate = json_tokener_parse(payload);
- if(!is_error(SignCertificate))
- {
- // Required data
- if(json_object_object_get(SignCertificate,"status") != NULL)
- sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
- // Optional data
- if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode") != NULL)
- {
- sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode")));
- if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo") != NULL)
- sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo")));
- }
- }
- json_object_put(SignCertificate);
- ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
- ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
- }
- void handleStatusNotificationResponse(char *payload, int gun_index)
- {
- mtrace();
- DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
- //cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
- //cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
- cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
- }
- void handleTransactionEventResponse(char *payload, int gun_index)
- {
- mtrace();
- json_object *TransactionEven;
- DEBUG_INFO("handleTransactionEventResponse...\n");
- TransactionEven = json_tokener_parse(payload);
- if(!is_error(TransactionEven))
- {
- // Required data
- // Optional data
- if(json_object_object_get(TransactionEven,"totalCost") != NULL)
- ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
- if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
- ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
- if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
- {
- if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
- if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
- if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
- ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
- if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
- if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
- {
- if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
- 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")));
- if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
- 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")));
- }
- }
- if(json_object_object_get(TransactionEven,"updatedPersonalMessage") != NULL)
- {
- if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "format") != NULL)
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.format, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "format")));
- if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "language") != NULL)
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.language, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "language")));
- if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "content") != NULL)
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.content, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "content")));
- }
- }
- json_object_put(TransactionEven);
- isQueueSendable = ON;
- ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
- }
- //==========================================
- // Handle Error routine
- //==========================================
- void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
- {
- mtrace();
- #ifdef SystemLogMessage
- DEBUG_INFO("errorCode: %s\n", errorCode);
- DEBUG_INFO("errorDescription: %s\n", errorDescription);
- DEBUG_INFO("errorDetails: %s\n", payload);
- #endif
- }
- //===============================================
- // Common routine
- //===============================================
- int initialConfigurationTable(void)
- {
- DEBUG_INFO("initialConfigurationTable...\n");
- memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
- DB_variableIsCreate();
- DB_variableLoadFromDb();
- if(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].value) != variableVersion)
- {
- DEBUG_WARN("EVSE variable version in local db older than firmware.\n");
- DB_variableClear();
- DB_variableIsCreate();
- DB_variableLoadFromDb();
- }
- DB_getNetworkProfileFromDb();
- DB_variableMonitoringLoadFromDb();
- for(uint8_t idx_vm=0;idx_vm<10;idx_vm++)
- {
- DEBUG_INFO("---------------------------------------------------------------------------------\n");
- DEBUG_INFO("MonitoringComponentVariable[%d].id = %d\n", idx_vm, ShmOCPP20Data->MonitoringComponentVariable[idx_vm].id);
- DEBUG_INFO("MonitoringComponentVariable[%d].value = %.2f\n", idx_vm, ShmOCPP20Data->MonitoringComponentVariable[idx_vm].value);
- DEBUG_INFO("MonitoringComponentVariable[%d].type = %s\n", idx_vm, ShmOCPP20Data->MonitoringComponentVariable[idx_vm].type);
- DEBUG_INFO("MonitoringComponentVariable[%d].severity = %d\n", idx_vm, ShmOCPP20Data->MonitoringComponentVariable[idx_vm].severity);
- DEBUG_INFO("MonitoringComponentVariable[%d].component.name = %s\n", idx_vm, ShmOCPP20Data->MonitoringComponentVariable[idx_vm].component.name);
- DEBUG_INFO("MonitoringComponentVariable[%d].variable.name = %s\n", idx_vm, ShmOCPP20Data->MonitoringComponentVariable[idx_vm].variable.name);
- DEBUG_INFO("---------------------------------------------------------------------------------\n");
- }
- return 0;
- }
- int TransactionMessageAttemptsGet(void)
- {
- return TransactionMessageAttemptsValue;
- }
- int FirstHeartBeatResponse(void)
- {
- return FirstHeartBeat;
- }
- int TransactionMessageRetryIntervalGet(void)
- {
- return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
- }
- int httpDownLoadFile(char *location, char *path, char *filename,char *url)
- {
- int result = TRUE;
- char rmFileCmd[100]={0};
- char FilePath[100]={0};
- char ftpbuf[200];
- int systemresult;
- sprintf(FilePath,"/mnt/%s",filename);
- system("ping 8.8.8.8 &");
- if((access(FilePath,F_OK))!=-1)
- {
- DEBUG_INFO("filename=%s exist.\n",FilePath);
- sprintf(rmFileCmd,"rm -f %s",FilePath);
- system(rmFileCmd);
- }
- memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
- sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
- DEBUG_INFO("Download command: %s\n",ftpbuf);
- systemresult = system(ftpbuf);
- if(systemresult != 0)
- {
- DEBUG_INFO("HTTP/HTTPS download fail!\n");
- result = FALSE;
- }
- system("pkill ping");
- return result;
- }
- int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
- {
- int result = TRUE;
- char rmFileCmd[100]={0};
- char FilePath[100]={0};
- char ftpbuf[200];
- int systemresult;
- sprintf(FilePath,"/mnt/%s",filename);
- system("ping 8.8.8.8 &");
- if((access(FilePath,F_OK))!=-1)
- {
- DEBUG_INFO("filename=%s exist.\n",FilePath);
- sprintf(rmFileCmd,"rm -f %s",FilePath);
- system(rmFileCmd);
- }
- memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
- sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120",filename, url);
- DEBUG_INFO("Download command: %s\n",ftpbuf);
- systemresult = system(ftpbuf);
- if(systemresult != 0)
- {
- sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
- DEBUG_INFO("Download command: %s\n",ftpbuf);
- systemresult = system(ftpbuf);
- if(systemresult != 0)
- {
- DEBUG_WARN("FTP download fail!\n");
- result = FALSE;
- }
- }
- system("pkill ping");
- return result;
- }
- int httpUploadFile(char *location, char *path, char *filename,char *url)
- {
- char rmFileCmd[100]={0};
- char FilePath[100]={0};
- char buf[512];
- int systemresult = 0;
- //DEBUG_INFO("filename=%s\n",filename);
- //DEBUG_INFO("url=%s\n",url);
- sprintf(FilePath,"%s","/mnt/upload_file.txt");
- if((access(FilePath,F_OK))!=-1)
- {
- DEBUG_INFO("filename=%s exist.\n",FilePath);
- sprintf(rmFileCmd,"rm -f %s",FilePath);
- system(rmFileCmd);
- }
- FILE *fp = fopen("/mnt/upload_file.txt", "w+");
- if(fp == NULL)
- {
- DEBUG_INFO("log is NULL\n");
- return FALSE;
- }
- else
- {
- fprintf(fp, "%s\n", url);
- fprintf(fp, "%s\n", filename);
- fclose(fp);
- }
- FILE *phpFP = popen("/bin/php-cgi /var/www/ocpp_upload.php", "r");
- if(phpFP == NULL)
- {
- DEBUG_INFO("PHP upload fail.\n");
- return FALSE;
- }
- else
- {
- while(fgets(buf, sizeof(buf), phpFP) != NULL)
- {
- if(strstr(buf, "result") != NULL)
- {
- sscanf(buf, "result: %d", &systemresult);
- DEBUG_INFO("PHP HTTP upload result: %d\n", systemresult);
- }
- }
- pclose(phpFP);
- }
- if(systemresult != 1)
- {
- DEBUG_WARN("HTTP POST upload error, change to PUT method\n");
- FILE *phpFP = popen("/bin/php-cgi /var/www/ocpp_upload_put.php", "r");
- if(phpFP == NULL)
- {
- DEBUG_WARN("PHP PUT upload fail.\n");
- return FALSE;
- }
- else
- {
- while(fgets(buf, sizeof(buf), phpFP) != NULL)
- {
- if(strstr(buf, "result") != NULL)
- {
- sscanf(buf, "result: %d", &systemresult);
- DEBUG_INFO("PHP HTTP PUT upload result: %d\n", systemresult);
- }
- }
- pclose(phpFP);
- }
- }
- if(systemresult != 1)
- {
- DEBUG_WARN("PHP PUT upload fail.\n");
- return FALSE;
- }
- return TRUE;
- }
- int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
- {
- int result = FALSE;
- char ftpbuf[200];
- int systemresult;
- /*
- // Domaind name transfer to IP address
- struct hostent* server;
- char *IPbuffer;
- server = gethostbyname(location);
- IPbuffer = inet_ntoa(*((struct in_addr*)server->h_addr_list[0]));*/
- memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
- sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s", user, password, location, port/*21*/, path, filename, fnamePlusPath);
- DEBUG_INFO("ftp command: %s\n",ftpbuf);
- systemresult = system(ftpbuf);
- if(systemresult != 0)
- {
- DEBUG_INFO("ftpput error!\n");
- }
- else
- {
- result = TRUE;
- DEBUG_INFO("ftpput OK!\n");
- }
- return result;
- }
- //=========================================
- // Routine
- //=========================================
- int GetOcppServerURL()
- {
- int result = FALSE;
- struct yuarel url;
- char urlStr[512];
- memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
- memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
- memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
- if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
- {
- memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
- if(yuarel_parse(&url, urlStr) != -1)
- {
- sprintf(OcppProtocol, "%s", url.scheme);
- sprintf(OcppHost, "%s", url.host);
- if(url.path == NULL)
- OcppTempPath[0] = '\0';
- else
- sprintf(OcppTempPath, "%s", url.path);
- if(url.port == 0)
- {
- if(strcmp(OcppProtocol, "wss") == 0)
- OcppPort = 443;
- else
- OcppPort = 80;
- }
- else
- OcppPort = url.port;
- result = TRUE;
- }
- }
- else
- {
- strcpy(OcppHost,"");
- }
- return result;
- }
- int GetOcppPath()
- {
- int result = FALSE;
- if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
- {
- if(OcppTempPath == NULL)
- {
- sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
- }
- else
- {
- sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
- }
- result = TRUE;
- }
- else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
- {
- if(OcppTempPath == NULL)
- {
- sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
- }
- else
- {
- sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
- }
- result = TRUE;
- }
- else
- {
- strcpy(OcppPath,"");
- }
- return result;
- }
- int GetOcppPort()
- {
- return OcppPort;
- }
- int GetOcppConnStatus(void)
- {
- return ShmOCPP20Data->OcppConnStatus;
- }
- void SetOcppConnStatus(uint8_t status)
- {
- ShmOCPP20Data->OcppConnStatus = status;
- ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
- }
- int GetHeartBeatWithNOResponse(void)
- {
- return HeartBeatWithNOResponse;
- }
- void SetHeartBeatWithNOResponse(void)
- {
- HeartBeatWithNOResponse = 0;
- }
- //Note: It is not real StopTransaction. It is temporary StopTransaction.
- void storeTempStopTransaction(int gun_index)
- {
- char TempStopTransaction[256];
- //char message[1024*20]={0};
- char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
- char guid[37]={0};
- json_object *TransactionEvent = json_object_new_object();
- json_object *transactionInfo = json_object_new_object();
- json_object *idToken = json_object_new_object();
- json_object *evse = json_object_new_object();
- json_object *meterValues = json_object_new_array();
- sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
- DEBUG_INFO("storeTempStopTransaction...\n");
- getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
- ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
- ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = 1;
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
- sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
- // Message
- json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
- json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
- json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
- json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo+1));
- json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
- if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
- json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
- if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
- json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
- if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
- json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
- json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
- json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
- if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
- json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
- json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
- if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
- json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
- json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
- if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
- {
- json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
- json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
- json_object_object_add(TransactionEvent, "idToken", idToken);
- }
- json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
- json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
- json_object_object_add(TransactionEvent, "evse", evse);
- meterValueBufferQuery(gun_index, meterValues);
- if(json_object_array_length(meterValues) > 0)
- {
- json_object_object_add(TransactionEvent, "meterValue", meterValues);
- }
- random_uuid(guid);
- sprintf(queuedata,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL
- , guid
- , "TransactionEvent"
- , json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
- json_object_put(TransactionEvent);
- // open file for writing
- FILE *outfile;
- outfile = fopen (TempStopTransaction, "w+");
- //DEBUG_INFO("data = %s\n", queuedata);
- fputs(queuedata, outfile);
- fputs("\n", outfile);
- fclose (outfile);
- }
- void checkTempStopTransaction(int gun_index)
- {
- FILE *fptr1;
- char ch;
- char str[QUEUE_MESSAGE_LENGTH]={0};
- char guid[37]={0};
- char tempdata[65]={0};
- char TempStopTransaction[256];
- sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
- fptr1 = fopen(TempStopTransaction, "r");
- if (!fptr1)
- {
- //DEBUG_INFO("TempStopTransaction20_%d not found or unable to open the input file!\n", (gun_index+1));
- return ;
- }
- ch=fgetc(fptr1);
- rewind(fptr1);
- if(ch!=EOF)
- {
- // copy all contents to the temporary file except the specific line
- while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
- {
- str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
- if(str[0]=='\0')
- {
- break;
- }
- strncpy(guid, str+4, 36); //copy guid
- sprintf(tempdata, "TransactionEvent,%d", (gun_index));
- if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
- {
- //DEBUG_INFO("StopTransaction mapitem pass\n");
- }
- queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
- memset(str,0,ARRAY_SIZE(str));
- }
- }
- // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
- fclose(fptr1);
- remove(TempStopTransaction); // remove the original file
- }
- int GetWebSocketPingInterval(void)
- {
- return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
- }
- int GetServerSign(void)
- {
- return server_sign;
- }
- uint8_t GetOcppSecurityProfile()
- {
- return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
- }
- void MergeCertificates()
- {
- char cmdBuf[2048]={0};
- if(access(ROOTCA_CS,F_OK) != -1)
- {
- sprintf(cmdBuf, "cat /root/cacert.pem %s > /root/certCA.pem", ROOTCA_CS);
- }
- else
- {
- sprintf(cmdBuf, "cat /root/cacert.pem > /root/certCA.pem");
- }
- system(cmdBuf);
- }
- void GetOcppChargerBoxId(uint8_t *data)
- {
- sprintf((char*)data, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
- }
- void GetOcppSecurityPassword(uint8_t *data)
- {
- sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
- }
- void SetServerSign(int value)
- {
- server_sign = value;
- }
- int GetBootNotificationInterval(void)
- {
- return BootNotificationInterval;
- }
- int GetInternetConn(void)
- {
- return ShmSysConfigAndInfo->SysInfo.InternetConn;
- }
- int GetBackendConnectionTimeout(void)
- {
- return ShmSysConfigAndInfo->SysConfig.BackendConnTimeout>=0?ShmSysConfigAndInfo->SysConfig.BackendConnTimeout:300;
- }
- int isConnectorInitMode(int gun_index)
- {
- int tempIndex = 0;
- int result = TRUE;
- //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
- if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
- {
- result = (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
- } //end of the same index
- }//end of for CHAdeMO_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_CCS)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
- {
- result = (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
- } //end of the same index
- } // end of for CCS_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_GBT)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
- {
- tempIndex = ((gun_index==2) ? 1: 0);
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
- {
- result = (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
- } //end of the same index
- } // end of for GB_QUANTITY
- }
- else if(gunType[gun_index] == GUN_TYPE_DO)
- {
- tempIndex = gun_index;
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
- {
- result = (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
- } //end of the same index
- }
- }
- else
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- tempIndex = 2;
- }
- else
- {
- tempIndex = gun_index;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
- {
- result = (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
- }//end of the same index
- }//end of for AC_QUANTITY
- }
- return result;
- }
- void refreshProcDogTimer()
- {
- ShmOCPP20Data->procDogTime = time((time_t*)NULL);
- }
- void InitialSystemValue(void)
- {
- localversion=0;
- BootNotificationInterval = 10;
- authorizeRetryTimes = 0;
- GunStatusInterval = 10;
- TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
- TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
- //Heart Beat
- HeartBeatWithNOResponse = 0;
- HeartBeatCountPerHour = 0;
- HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
- if(HeartBeatWaitTime == 0)
- FirstHeartBeat = TRUE;
- else
- FirstHeartBeat = FALSE;
- FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
- LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
- memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
- memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
- memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
- memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
- memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
- memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
- memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
- memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
- memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
- //Status && ConnectorPlugIn Setting
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- ChademoPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
- ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- CcsPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
- CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- GbPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
- GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- AcPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
- AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
- }
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
- {
- DoPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
- DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
- }
- for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
- {
- cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
- cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
- cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
- //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
- refreshStartTimer(&clientTime.StatusNotification[gun_index]);
- //memset(&ShmOCPP20Data->StatusNotification[gun_index], 0x00, sizeof(struct StatusNotification_20));
- memset(&ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, 0x00, sizeof(ShmOCPP20Data->StatusNotification[gun_index].connectorStatus));
- }
- refreshStartTimer(&clientTime.Heartbeat);
- sleep(1);
- }
- void LWS_Send(char *str)
- {
- //=====================================================
- // Check InternetConn 0: disconnected, 1: connected
- //====================================================
- if(GetOcppConnStatus() == 0)
- {
- DEBUG_INFO("offline now !!!\n");
- return;
- }
- // Only disable isWebsocketSendable operation initiated by charger
- if((strstr((char*)str, "\"Authorize\"") != NULL)
- || (strstr((char*)str, "\"BootNotification\"") != NULL)
- || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
- || (strstr((char*)str, "\"DataTransfer\"") != NULL)
- || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
- || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
- || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
- || (strstr((char*)str, "\"Heartbeat\"") != NULL)
- || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
- || (strstr((char*)str, "\"MeterValues\"") != NULL)
- || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
- || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
- || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
- || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
- || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
- || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
- || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
- || (strstr((char*)str, "\"NotifyReport\"") != NULL)
- || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
- || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
- || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
- || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
- || (strstr((char*)str, "\"SignCertificate\"") != NULL)
- || (strstr((char*)str, "\"StatusNotification\"") != NULL)
- || (strstr((char*)str, "\"TransactionEvent\"") != NULL))
- {
- isWebsocketSendable = OFF;
- }
- pthread_mutex_lock(&lock_send);
- memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
- sprintf((char *)SendBuffer, "%s", str);
- SendBufLen = strlen(str);
- pthread_mutex_unlock(&lock_send);
- lws_callback_on_writable(wsi_client);
- //lws_service(context, 0);
- //sleep(1);
- }
- void LWS_SendNow(char *str)
- {
- //=====================================================
- // Check InternetConn 0: disconnected, 1: connected
- //====================================================
- if(GetOcppConnStatus() == 0)
- {
- DEBUG_INFO("offline now !!!\n");
- return;
- }
- // Only disable isWebsocketSendable operation initiated by charger
- if((strstr((char*)str, "\"Authorize\"") != NULL)
- || (strstr((char*)str, "\"BootNotification\"") != NULL)
- || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
- || (strstr((char*)str, "\"DataTransfer\"") != NULL)
- || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
- || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
- || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
- || (strstr((char*)str, "\"Heartbeat\"") != NULL)
- || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
- || (strstr((char*)str, "\"MeterValues\"") != NULL)
- || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
- || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
- || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
- || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
- || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
- || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
- || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
- || (strstr((char*)str, "\"NotifyReport\"") != NULL)
- || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
- || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
- || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
- || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
- || (strstr((char*)str, "\"SignCertificate\"") != NULL)
- || (strstr((char*)str, "\"StatusNotification\"") != NULL)
- || (strstr((char*)str, "\"TransactionEvent\"") != NULL))
- {
- isWebsocketSendable = OFF;
- }
- pthread_mutex_lock(&lock_send);
- memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
- sprintf((char *)SendBuffer, "%s", str);
- SendBufLen = strlen(str);
- pthread_mutex_unlock(&lock_send);
- lws_callback_on_writable(wsi_client);
- lws_service(context, 0);
- //sleep(1);
- }
|