123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888 |
- #define _XOPEN_SOURCE 700
- #include <sys/types.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <sys/stat.h>
- #include <sys/time.h> // gettimeofday sleep usleep
- #include <fcntl.h>
- #include <stddef.h>
- #include <stdio.h>
- #include <string.h>
- #ifdef _WIN32
- #include <Windows.h>
- #else
- #include <unistd.h>
- #endif
- #include <stdarg.h>
- #include <ctype.h>
- #include "libwebsockets.h"
- #include <lws_config.h>
- #include "hashmap.h"
- #include "ShareMemory.h"
- #include "TransactionQueue.h"
- #include "define.h"
- #include "SystemLogMessage.h"
- //#include "config.h"
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <stdlib.h>
- /*for sendfile()*/
- #include <sys/sendfile.h>
- /*for O_RDONLY*/
- #include <fcntl.h>
- #include "sqlite3.h"
- #include <arpa/inet.h>
- //#define _GNU_SOURCE
- #include <time.h>
- #include "MessageHandler.h"
- #include <assert.h>
- #include <pthread.h>
- #include <mcheck.h>
- #define PASS 1
- #define FAIL -1
- #define FALSE 0
- #define TRUE 1 // Option 1
- //ChargePointMaxProfile
- #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile.json"
- //TxDefaultProfile
- #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0.json"
- #define TxDefaultProfile_1_JSON "/Storage/OCPP/TxDefaultProfile_1.json"
- #define TxDefaultProfile_2_JSON "/Storage/OCPP/TxDefaultProfile_2.json"
- //TxProfile
- #define TxProfile_1_JSON "/Storage/OCPP/TxProfile_1.json"
- #define TxProfile_2_JSON "/Storage/OCPP/TxProfile_2.json"
- #define ChargingProfile_0_JSON "/Storage/OCPP/chargingprofile_0.json"
- #define ChargingProfile_1_JSON "/Storage/OCPP/chargingprofile_1.json"
- #define ChargingProfile_2_JSON "/Storage/OCPP/chargingprofile_2.json"
- #define AuthorizationCache_JSON "/Storage/OCPP/AuthorizationCache.json"
- #define LocalAuthorizationList_JSON "/Storage/OCPP/LocalAuthorizationList.json"
- struct SysConfigAndInfo *ShmSysConfigAndInfo;
- struct StatusCodeData *ShmStatusCodeData;
- struct PsuData *ShmPsuData ;
- struct OCPP16Data *ShmOCPP16Data;
- // define Macro
- #define SystemLogMessage
- // OCPP Message Type
- #define MESSAGE_TYPE_CALL 2
- #define MESSAGE_TYPE_CALLRESULT 3
- #define MESSAGE_TYPE_CALLERROR 4
- //
- #define server_cycle_Status 120
- #define MACROSTR(k) #k
- //ConfigurationMaxKeys
- #define GetConfigurationMaxKeysNUM 43
- //char guid[37];
- pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
- char queuedata[2600]={0};
- //===============================
- // Configuration: unknownkey
- //===============================
- static char unknownkey[10][20]={0};
- static int UnknownKeynum = 0;
- //===============================
- // Gun Total Numbers
- //===============================
- //#define gunTotalNumber (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') ? (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY): AC_QUANTITY
- static int gunTotalNumber=0;
- //===============================
- // Local List Version
- //===============================
- static int localversion=0;
- static char idTagAuthorization[32]={0};
- //===============================
- // OCPP Path
- //===============================
- extern char OcppPath[160];
- extern char OcppProtocol[10];
- extern char OcppHost[50];
- extern char OcppTempPath[50];
- int OcppPort=0;
- //===============================
- // OCPP sign variable
- //===============================
- int server_sign = FALSE;
- int server_pending = FALSE;
- int PRE_SYS_MODE[CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY];
- int BootNotificationInterval = 0;
- static int SystemInitial = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
- //===============================
- // OCPP auth variable
- //===============================
- int authenrequest = FALSE;
- int authorizeRetryTimes = 0; //number of Retry times
- //===============================
- // OCPP StartTransaction transactionId variables
- //===============================
- static int TransactionId[CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY]={0};
- //===============================
- // OCPP other variables
- //===============================
- int isUpdateRequest = FALSE;
- static int HeartBeatWaitTime = 10;
- static int FirstHeartBeat = 0;
- static int FirmwareStatusNotificationStatus = 3; // Idle
- static int DiagnosticsStatusNotificationStatus = 0; // Idle
- static char CurrentChargingProfileScheduleStr[30]={0};
- //========================================
- // OCPP status/previous related variables
- //========================================
- static int GunStatusInterval = 10;
- int statusModeChage[CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY] = {FALSE};
- static int ChademoPreviousSystemStatus[CHAdeMO_QUANTITY];
- static int CcsPreviousSystemStatus[CCS_QUANTITY];
- static int GbPreviousSystemStatus[GB_QUANTITY];
- static int AcPreviousSystemStatus[AC_QUANTITY];
- int TransactionMessageAttemptsValue = 0;
- int TransactionMessageRetryIntervalValue = 0;
- static struct OCPPAuthLocalElemet
- {
- int listVersionInt;
- char idTagstr[20];
- char parentIdTag[20];
- char expiryDate[30];
- char idTagstatus[16];
- }idTagQuery;
- //=============================================
- // OCPP HeartBeat Response Not Receive Counts
- //============================================
- static int HeartBeatWithNOResponse = 0;
- static int HeartBeatCount = 0;
- extern struct lws *wsi_client;
- extern struct lws_context *context;
- extern unsigned char SendBuffer[4096];
- extern int SendBufLen;
- extern char *random_uuid( char buf[37] );
- extern void split(char **arr, char *str, const char *del);
- extern pthread_mutex_t mutex1;
- extern struct Charger_Info Charger;
- extern sqlite3 *db;
- int TransactionMessageAttemptsGet(void);
- int TransactionMessageRetryIntervalGet(void);
- int GetOcppConnStatus(void);
- void SetOcppConnStatus(uint8_t status);
- int updateSetting(char *key, char *value);
- int setKeyValue(char *key, char *value);
- void OCPP_get_TableAuthlocalAllData(void);
- void processUnkownKey(void);
- struct StructOCPPMeterValue
- {
- unsigned char TimeStamp[28];
- struct StructSampledValue SampledValue[10];
- };
- struct ClientTime
- {
- unsigned int Heartbeat;
- unsigned int StatusNotification[CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY];
- unsigned int StartTransaction;
- unsigned int StopTransaction;
- unsigned int MeterValues[CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY];
- }clientTime;
- typedef union
- {
- //Operations Initiated by Central System
- unsigned char CsMsgValue[CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY];
- struct
- {
- //CsMsgValue[0]
- unsigned char StatusNotificationReq :1; //bit 0,
- unsigned char StatusNotificationConf :1; //bit 0,
- unsigned char :6; //bit 2~7
- }bits[CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY];
- }CpinitiateMsg;
- CpinitiateMsg cpinitateMsg;
- //==========================================
- // Init all Enumeration & Mapping String
- //==========================================
- /*ChargePointErrorCode*/
- typedef enum {
- ConnectorLockFailure,
- EVCommunicationError,
- GroundFailure,
- HighTemperature,
- InternalError,
- LocalListConflict,
- NoError,
- OtherError,
- OverCurrentFailure,
- OverVoltage,
- PowerMeterFailure,
- PowerSwitchFailure,
- ReaderFailure,
- ResetFailure,
- UnderVoltage,
- WeakSignal
- } ChargePointErrorCode;
- #if 0
- static char *ChargePointErrorCodeStr[] = {
- 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
- /*ChargePointStatus*/
- typedef enum {
- Available =0,
- Preparing,
- Charging,
- SuspendedEVSE,
- SuspendedEV,
- Finishing,
- Reserved,
- Unavailable,
- Faulted
- } ChargePointStatus;
- static char * ChargePointStatusStr[] = {
- MACROSTR(Available),
- MACROSTR(Preparing),
- MACROSTR(Charging),
- MACROSTR(SuspendedEVSE),
- MACROSTR(SuspendedEV),
- MACROSTR(Finishing),
- MACROSTR(Reserved),
- MACROSTR(Unavailable),
- MACROSTR(Faulted)
- };
- /*AvailabilityType*/
- typedef enum {
- RegistrationStatus_Accepted,
- RegistrationStatus_Pending,
- RegistrationStatus_Rejected
- } RegistrationStatus;
- static char *RegistrationStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Pending),
- MACROSTR(Rejected)
- };
- /*AvailabilityType*/
- typedef enum {
- Inoperative,
- Operative
- } AvailabilityType;
- static char *AvailabilityTypeStr[] = {
- MACROSTR(Inoperative),
- MACROSTR(Operative)
- };
- /*AvailabilityStatus*/
- typedef enum {
- Accepted,
- Rejected,
- Scheduled
- } AvailabilityStatus;
- static char *AvailabilityStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(Scheduled)
- };
- /*ConfigurationStatus*/
- typedef enum {
- ConfigurationStatus_Accepted,
- ConfigurationStatus_Rejected,
- RebootRequired,
- NotSupported
- } ConfigurationStatus;
- static char *ConfigurationStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(RebootRequired),
- MACROSTR(NotSupported)
- };
- /*ClearCacheStatus*/
- typedef enum {
- ClearCacheStatus_Accepted,
- ClearCacheStatus_Rejected
- } ClearCacheStatus;
- static char *ClearCacheStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- /*ChargingProfilePurposeType*/
- typedef enum {
- ChargePointMaxProfile,
- TxDefaultProfile,
- TxProfile
- } ChargingProfilePurposeType;
- static char *ChargingProfilePurposeTypeStr[] = {
- MACROSTR(ChargePointMaxProfile),
- MACROSTR(TxDefaultProfile),
- MACROSTR(TxProfile)
- };
- /*ChargingProfileStatus*/
- typedef enum {
- ChargingProfileStatus_Accepted,
- ChargingProfileStatus_Rejected,
- ChargingProfileStatus_NotSupported
- } ChargingProfileStatus;
- static char *ChargingProfileStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(NotSupported)
- };
- /*ClearChargingProfileStatus*/
- typedef enum {
- ClearChargingProfileStatus_Accepted,
- ClearChargingProfileStatus_Unknown
- } ClearChargingProfileStatus;
- static char *ClearChargingProfileStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Unknown)
- };
- /*GetCompositeScheduleStatus*/
- typedef enum {
- GetCompositeScheduleStatus_Accepted,
- GetCompositeScheduleStatus_Rejected
- } GetCompositeScheduleStatus;
- static char *GetCompositeScheduleStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- /*ChargingRateUnitType*/
- typedef enum {
- ChargingRateUnitType_W,
- ChargingRateUnitType_A
- } ChargingRateUnitType;
- /*AuthorizationStatus*/
- typedef enum {
- AuthorizationStatus_Accepted ,
- AuthorizationStatus_Blocked ,
- AuthorizationStatus_Expired ,
- AuthorizationStatus_Invalid ,
- AuthorizationStatus_ConcurrentTx
- } AuthorizationStatus;
- /*UpdateType*/
- typedef enum {
- Differential ,
- Full
- } UpdateType;
- static char *UpdateTypeStr[] = {
- MACROSTR(Differential),
- MACROSTR(Full)
- };
- /*UpdateStatus*/
- typedef enum {
- UpdateStatus_Accepted ,
- UpdateStatus_Failed ,
- UpdateStatus_NotSupported ,
- UpdateStatus_VersionMismatch
- } UpdateStatus;
- static char *UpdateStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Failed),
- MACROSTR(NotSupported),
- MACROSTR(VersionMismatch)
- };
- /*RemoteStartStopStatus*/
- typedef enum {
- RemoteStartStopStatus_Accepted,
- RemoteStartStopStatus_Rejected
- } RemoteStartStopStatus;
- static char *RemoteStartStopStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- /*ReservationStatus*/
- typedef enum {
- ReservationStatus_Accepted,
- ReservationStatus_Faulted,
- ReservationStatus_Occupied,
- ReservationStatus_Rejected,
- ReservationStatus_Unavailable
- } ReservationStatus;
- static char *ReservationStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Faulted),
- MACROSTR(Occupied),
- MACROSTR(Rejected),
- MACROSTR(Unavailable)
- };
- /*ResetType*/
- typedef enum {
- Hard,
- Soft
- } ResetType;
- static char *ResetTypeStr[] = {
- MACROSTR(Hard),
- MACROSTR(Soft)
- };
- /*ResetStatus*/
- typedef enum {
- ResetStatus_Accepted,
- ResetStatus_Rejected
- } ResetStatus;
- static char *ResetStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- /*DiagnosticsStatus*/
- typedef enum {
- DiagnosticsStatus_Idle,
- DiagnosticsStatus_Uploaded,
- DiagnosticsStatus_UploadFailed,
- DiagnosticsStatus_Uploading
- } DiagnosticsStatus;
- static char * DiagnosticsStatusStr[] = {
- MACROSTR(Idle),
- MACROSTR(Uploaded),
- MACROSTR(UploadFailed),
- MACROSTR(Uploading)
- };
- /*FirmwareStatus*/
- typedef enum {
- FirmwareStatus_Downloaded,
- FirmwareStatus_DownloadFailed,
- FirmwareStatus_Downloading,
- FirmwareStatus_Idle,
- FirmwareStatus_InstallationFailed,
- FirmwareStatus_Installing,
- FirmwareStatus_Installed
- } FirmwareStatus;
- static char * FirmwareStatusStr[] = {
- MACROSTR(Downloaded),
- MACROSTR(DownloadFailed),
- MACROSTR(Downloading),
- MACROSTR(Idle),
- MACROSTR(InstallationFailed),
- MACROSTR(Installing),
- MACROSTR(Installed)
- };
- /*MessageTrigger*/
- typedef enum {
- BootNotification,
- DiagnosticsStatusNotification,
- FirmwareStatusNotification,
- Heartbeat,
- MeterValues,
- StatusNotification
- } MessageTrigger;
- static char * MessageTriggerStr[] = {
- MACROSTR(BootNotification),
- MACROSTR(DiagnosticsStatusNotification),
- MACROSTR(FirmwareStatusNotification),
- MACROSTR(Heartbeat),
- MACROSTR(MeterValues),
- MACROSTR(StatusNotification)
- };
- /*TriggerMessageStatus*/
- typedef enum {
- TriggerMessageStatus_Accepted ,
- TriggerMessageStatus_Rejected ,
- TriggerMessageStatus_NotImplemented
- } TriggerMessageStatus;
- static char * TriggerMessageStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected),
- MACROSTR(NotImplemented)
- };
- /*UnlockStatus*/
- typedef enum {
- Unlocked,
- UnlockFailed,
- UnlockStatus_NotSupported
- } UnlockStatus;
- static char * UnlockStatusStr[] = {
- MACROSTR(Unlocked),
- MACROSTR(UnlockFailed),
- MACROSTR(NotSupported)
- };
- /*StopTransactionReason*/
- typedef enum {
- EmergencyStop,
- EVDisconnected,
- HardReset,
- Local,
- Other,
- PowerLoss,
- Reboot,
- Remote,
- SoftReset,
- UnlockCommand,
- DeAuthorized
- } StopTransactionReason;
- #if 0
- static char * StopTransactionReasonStr[] = {
- MACROSTR(EmergencyStop),
- MACROSTR(EVDisconnected),
- MACROSTR(HardReset),
- MACROSTR(Local),
- MACROSTR(Other),
- MACROSTR(PowerLoss),
- MACROSTR(Reboot),
- MACROSTR(Remote),
- MACROSTR(SoftReset),
- MACROSTR(UnlockCommand),
- MACROSTR(DeAuthorized)
- };
- #endif
- /*CancelReservationStatus*/
- typedef enum {
- CancelReservationStatus_Accepted,
- CancelReservationStatus_Rejected
- } CancelReservationStatus;
- static char * CancelReservationStatusStr[] = {
- MACROSTR(Accepted),
- MACROSTR(Rejected)
- };
- /*ReadingContext*/
- typedef enum {
- ReadingContext_Interruption_Begin,
- ReadingContext_Interruption_End,
- ReadingContext_Other,
- ReadingContext_Sample_Clock,
- ReadingContext_Sample_Periodic ,
- ReadingContext_Transaction_Begin ,
- ReadingContext_Transaction_End,
- ReadingContext_Trigger
- } ReadingContext;
- static char * ReadingContextStr[] = {
- MACROSTR(Interruption.Begin),
- MACROSTR(Interruption.End),
- MACROSTR(Other),
- MACROSTR(Sample.Clock),
- MACROSTR(Sample.Periodic),
- MACROSTR(Transaction.Begin),
- MACROSTR(Transaction.End),
- MACROSTR(Trigger)
- };
- /*ValueFormat*/
- typedef enum {
- Raw,
- SignedData
- } ValueFormat;
- static char * ValueFormatStr[] = {
- MACROSTR(Raw),
- MACROSTR(SignedData)
- };
- /*Measurand*/
- typedef enum {
- Current_Export ,
- Current_Import,
- Current_Offered,
- Energy_Active_Export_Register,
- Energy_Active_Import_Register,
- Energy_Reactive_Export_Register,
- Energy_Reactive_Import_Register,
- Energy_Active_Export_Interval,
- Energy_Active_Import_Interval,
- Energy_Reactive_Export_Interval,
- Energy_Reactive_Import_Interval,
- Frequency,
- Power_Active_Export ,
- Power_Active_Import,
- Power_Factor,
- Power_Offered,
- Power_Reactive_Export,
- Power_Reactive_Import,
- RPM,
- SoC,
- Temperature ,
- Voltage
- } Measurand;
- static char * MeasurandStr[] = {
- 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.Reactive.Export.Interval),
- MACROSTR(Energy.Reactive.Import.Interval),
- MACROSTR(Frequency),
- MACROSTR(Power.Active.Export),
- MACROSTR(Power.Active.Import),
- MACROSTR(Power.Factor),
- MACROSTR(Power.Offered),
- MACROSTR(Power.Reactive.ExportMACROSTR),
- MACROSTR(Power.Reactive.Import),
- MACROSTR(RPM),
- MACROSTR(SoC),
- MACROSTR(Temperature),
- MACROSTR(Voltage)
- };
- /*Location*/
- typedef enum {
- Location_Body,
- Location_Cable,
- Location_EV,
- Location_Inlet ,
- Location_Outlet
- } Location;
- static char * LocationStr[] = {
- MACROSTR(Body),
- MACROSTR(Cable),
- MACROSTR(EV),
- MACROSTR(Inlet),
- MACROSTR(Outlet)
- };
- /*Phase*/
- typedef enum {
- L1,
- L2,
- L3,
- N,
- L1_N,
- L2_N,
- L3_N,
- L1_L2,
- L2_L3,
- L3_L1
- } Phase;
- static char * PhaseStr[] = {
- 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)
- };
- /*UnitOfMeasure*/
- typedef enum {
- UnitOfMeasure_Wh,
- UnitOfMeasure_kWh ,
- UnitOfMeasure_varh ,
- UnitOfMeasure_kvarh ,
- UnitOfMeasure_W ,
- UnitOfMeasure_kW ,
- UnitOfMeasure_VA ,
- UnitOfMeasure_kVA ,
- UnitOfMeasure_var ,
- UnitOfMeasure_kvar ,
- UnitOfMeasure_A ,
- UnitOfMeasure_V ,
- UnitOfMeasure_Celsius ,
- UnitOfMeasure_Fahrenheit ,
- UnitOfMeasure_K ,
- UnitOfMeasure_Percent
- } UnitOfMeasure;
- static char * UnitOfMeasureStr[] = {
- MACROSTR(Wh),
- MACROSTR(kWh),
- MACROSTR(varh),
- MACROSTR(kvarh),
- MACROSTR(W),
- MACROSTR(kW),
- MACROSTR(VA),
- MACROSTR(kVA),
- MACROSTR(var),
- MACROSTR(kvar),
- MACROSTR(A),
- MACROSTR(V),
- MACROSTR(Celsius),
- MACROSTR(Fahrenheit),
- MACROSTR(K),
- MACROSTR(Percent)
- };
- #if 0
- /*Configuration enum*/
- enum CoreProfile {
- AllowOfflineTxForUnknownId=0,
- AuthorizationCacheEnabled,
- AuthorizeRemoteTxRequests,
- BlinkRepeat,
- ClockAlignedDataInterval,
- ConnectionTimeOut,
- GetConfigurationMaxKeys,
- HeartbeatInterval,
- LightIntensity,
- LocalAuthorizeOffline,
- LocalPreAuthorize,
- MaxEnergyOnInvalidId,
- MeterValuesAlignedData,
- MeterValuesAlignedDataMaxLength,
- MeterValuesSampledData,
- MeterValuesSampledDataMaxLength,
- MeterValueSampleInterval,
- MinimumStatusDuration,
- NumberOfConnectors,
- ResetRetries,
- ConnectorPhaseRotation,
- ConnectorPhaseRotationMaxLength,
- StopTransactionOnEVSideDisconnect,
- StopTransactionOnInvalidId,
- StopTxnAlignedData,
- StopTxnAlignedDataMaxLength,
- StopTxnSampledData,
- StopTxnSampledDataMaxLength,
- SupportedFeatureProfiles,
- SupportedFeatureProfilesMaxLength,
- TransactionMessageAttempts,
- TransactionMessageRetryInterval,
- UnlockConnectorOnEVSideDisconnect,
- WebSocketPingInterval,
- _CoreProfile_CNT
- };
- #endif
- enum LocalAuthListManagementProfile{
- LocalAuthListEnabled=0,
- LocalAuthListMaxLength,
- SendLocalListMaxLength,
- _LocalAuthListManagementProfile_CNT
- };
- enum ReservationProfile{
- ReserveConnectorZeroSupported
- };
- enum SmartChargingProfile{
- ChargeProfileMaxStackLevel,
- ChargingScheduleAllowedChargingRateUnit,
- ChargingScheduleMaxPeriods,
- ConnectorSwitch3to1PhaseSupported,
- MaxChargingProfilesInstalled
- };
- enum ChargerSystemStatus{
- ChargerSystemStatus_Booting,
- ChargerSystemStatus_Idle,
- ChargerSystemStatus_Authorizing,
- ChargerSystemStatus_Preparing,
- ChargerSystemStatus_Charging,
- ChargerSystemStatus_Terminating,
- ChargerSystemStatus_Alarm,
- ChargerSystemStatus_Fault
- };
- enum GetConfigurationKey {
- GetConfiguration_AllowOfflineTxForUnknownId=0,
- GetConfiguration_AuthorizationCacheEnabled,
- GetConfiguration_AuthorizeRemoteTxRequests,
- GetConfiguration_BlinkRepeat,
- GetConfiguration_ClockAlignedDataInterval,
- GetConfiguration_ConnectionTimeOut,
- GetConfiguration_GetConfigurationMaxKeys,
- GetConfiguration_HeartbeatInterval,
- GetConfiguration_LightIntensity,
- GetConfiguration_LocalAuthorizeOffline,
- GetConfiguration_LocalPreAuthorize,
- GetConfiguration_MaxEnergyOnInvalidId,
- GetConfiguration_MeterValuesAlignedData,
- GetConfiguration_MeterValuesAlignedDataMaxLength,
- GetConfiguration_MeterValuesSampledData,
- GetConfiguration_MeterValuesSampledDataMaxLength,
- GetConfiguration_MeterValueSampleInterval,
- GetConfiguration_MinimumStatusDuration,
- GetConfiguration_NumberOfConnectors,
- GetConfiguration_ResetRetries,
- GetConfiguration_ConnectorPhaseRotation,
- GetConfiguration_ConnectorPhaseRotationMaxLength,
- GetConfiguration_StopTransactionOnEVSideDisconnect,
- GetConfiguration_StopTransactionOnInvalidId,
- GetConfiguration_StopTxnAlignedData,
- GetConfiguration_StopTxnAlignedDataMaxLength,
- GetConfiguration_StopTxnSampledData,
- GetConfiguration_StopTxnSampledDataMaxLength,
- GetConfiguration_SupportedFeatureProfiles,
- GetConfiguration_SupportedFeatureProfilesMaxLength,
- GetConfiguration_TransactionMessageAttempts,
- GetConfiguration_TransactionMessageRetryInterval,
- GetConfiguration_UnlockConnectorOnEVSideDisconnect,
- GetConfiguration_WebSocketPingInterval,
- GetConfiguration_LocalAuthListEnabled,
- GetConfiguration_LocalAuthListMaxLength,
- GetConfiguration_SendLocalListMaxLength,
- GetConfiguration_ReserveConnectorZeroSupported,
- GetConfiguration_ChargeProfileMaxStackLevel,
- GetConfiguration_ChargingScheduleAllowedChargingRateUnit,
- GetConfiguration_ChargingScheduleMaxPeriods,
- GetConfiguration_ConnectorSwitch3to1PhaseSupported,
- GetConfiguration_MaxChargingProfilesInstalled,
- };
- //GetConfiguration Array
- struct StructConfigurationKeyItems staticKeyArray[GetConfigurationMaxKeysNUM]={0};
- struct StructConfigurationKey staticResponseConfigurationKeyArray[GetConfigurationMaxKeysNUM]={0};
- struct StructConfigurationKeyItems staticResponseUnknownKey[10]={0};
- struct StructLocalAuthorizationList staticLocalAuthorizationList[500]={0};
- //==========================================
- // Init all share memory
- //==========================================
- int InitShareMemory()
- {
- int result = PASS;
- int MeterSMId;
- //creat ShmSysConfigAndInfo
- if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
- {
- #ifdef SystemLogMessage
- DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
- #endif
- result = FAIL;
- }
- else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- #ifdef SystemLogMessage
- DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
- #endif
- result = FAIL;
- }
- else
- {}
- if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
- {
- #ifdef SystemLogMessage
- DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
- #endif
- result = FAIL;
- }
- else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- #ifdef SystemLogMessage
- DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
- #endif
- result = FAIL;
- }
- else
- {}
- //creat ShmPsuData
- if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
- {
- #ifdef SystemLogMessage
- DEBUG_ERROR("shmget ShmPsuData NG\n");
- #endif
- result = FAIL;
- }
- else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- #ifdef SystemLogMessage
- DEBUG_ERROR("shmat ShmPsuData NG\n");
- #endif
- result = FAIL;
- }
- else
- {}
- //creat ShmOCPP16Data
- if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
- {
- #ifdef SystemLogMessage
- DEBUG_ERROR("shmget ShmOCPP16Data NG");
- #endif
- result = FAIL;
- }
- else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- #ifdef SystemLogMessage
- DEBUG_ERROR("shmat ShmOCPP16Data NG");
- #endif
- result = FAIL;
- }
- else
- {}
- /****************************** For Initial Settings************************************************/
- gunTotalNumber = (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') ? (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY): AC_QUANTITY;
- for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
- {
- cpinitateMsg.bits[gun_index].StatusNotificationReq = 0;
- cpinitateMsg.bits[gun_index].StatusNotificationConf = 0;
- clientTime.MeterValues[gun_index] = time((time_t*)NULL);
- }
- // Charger PRE_SYS_MODE
- memset(PRE_SYS_MODE, 0, sizeof(PRE_SYS_MODE));
- memset( (void *)unknownkey, 0, sizeof(unknownkey));
- clientTime.Heartbeat=time((time_t*)NULL);
- for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
- {
- clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
- clientTime.MeterValues[gun_index] = time((time_t*)NULL);
- }
- ShmOCPP16Data->GetConfiguration.ResponseUnknownKey = NULL;
- ShmOCPP16Data->SendLocalList.LocalAuthorizationList = NULL;
- // allocate Configuration memory address
- ShmOCPP16Data->GetConfiguration.Key = staticKeyArray;
- ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey = staticResponseConfigurationKeyArray;
- ShmOCPP16Data->GetConfiguration.ResponseUnknownKey = staticResponseUnknownKey;
- ShmOCPP16Data->SendLocalList.LocalAuthorizationList = staticLocalAuthorizationList;
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
- {
- SystemInitial = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
- DEBUG_INFO("DC ...\n");
- }
- else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
- {
- SystemInitial = AC_QUANTITY;
- DEBUG_INFO("AC ...\n");
- }
- //Status Setting
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- CcsPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- GbPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
- }
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
- }
- return result;
- }
- int ProcessShareMemory()
- {
- if(InitShareMemory() == FAIL)
- {
- #ifdef SystemLogMessage
- DEBUG_ERROR("InitShareMemory NG\n");
- #endif
- if(ShmStatusCodeData!=NULL)
- {
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
- }
- sleep(5);
- return FAIL;
- }
- return PASS;
- }
- //---------------------------------------------
- // new:
- // enum SYSTEM_STATUS
- // {
- // SYS_MODE_BOOTING = 0,
- // SYS_MODE_IDLE = 1,
- // SYS_MODE_AUTHORIZING = 2,
- // SYS_MODE_MODE_REASSIGN_CHECK = 3,
- // SYS_MODE_REASSIGN = 4,
- // SYS_MODE_PREPARING = 5,
- // SYS_MODE_PREPARE_FOR_EV = 6,
- // SYS_MODE_PREPARE_FOR_EVSE = 7,
- // SYS_MODE_CHARGING = 8,
- // SYS_MODE_TERMINATING = 9,
- // SYS_MODE_COMPLETE = 10,
- // SYS_MODE_ALARM = 11,
- // SYS_MODE_FAULT = 12,
- // SYS_MODE_RESERVATION = 13,
- // SYS_MODE_BOOKING = 14,
- // SYS_MODE_MAINTAIN = 15,
- // SYS_MODE_DEBUG = 16,
- // SYS_MODE_CCS_PRECHARGE_STEP0 = 17,
- // SYS_MODE_CCS_PRECHARGE_STEP1 = 18,
- // SYS_MODE_UPDATE = 19
- // };
- //
- //
- //-----------------------------------------
- void CheckSystemValue(void)
- {
- int meterValueSend[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY]={0};
- int IdleModeCnt = 0;
- char filenmae[100]={0};
- char str[100]={0};
- //===============================
- // send Heartbeat
- //===============================
- if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= HeartBeatWaitTime))
- {
- printf("Heartbeat !!!\n");
- //parameter for test
- sendHeartbeatRequest(0);
- //==============================================
- // Reset Waiting Time
- //==============================================
- clientTime.Heartbeat=time((time_t*)NULL);
- HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
- }
- //==============================================
- // Update firmware request
- //==============================================
- if(isUpdateRequest == TRUE )
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for(int gun_index=0;gun_index < (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY) ;gun_index++)
- {
- //check SystemStatus
- /*************************DC*******************************/
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)) //S_IDLE
- {
- IdleModeCnt = IdleModeCnt + 1;
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE)) //S_IDLE
- {
- IdleModeCnt = IdleModeCnt + 1;
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == 1)) //S_IDLE
- {
- IdleModeCnt = IdleModeCnt + 1;
- }
- }
- }
- if(IdleModeCnt == (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY ))
- {
- isUpdateRequest = FALSE;
- }
- }
- else
- {
- /*************************AC*******************************/
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == 1) //S_IDLE
- {
- IdleModeCnt = IdleModeCnt + 1;
- }
- }
- if(IdleModeCnt == AC_QUANTITY)
- {
- isUpdateRequest = FALSE;
- }
- }
- }
- for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
- {
- //===============================
- // CSU Trigger Reset Conf
- //===============================
- if((server_sign == TRUE) &&(ShmOCPP16Data->MsMsg.bits.ResetConf == 1))
- {
- sendResetConfirmation((char *)ShmOCPP16Data->Reset.guid, (char *)ShmOCPP16Data->Reset.ResponseStatus);
- if(strcmp((const char *)ShmOCPP16Data->Reset.Type, "Soft") == 0)
- {
- server_sign = FALSE;
- }
- }
- //===============================
- // CSU Trigger Authorize Request
- //===============================
- if((server_sign == TRUE) && (ShmOCPP16Data->SpMsg.bits.AuthorizeReq == 1)&&(authorizeRetryTimes < 3)/*authenrequest == FALSE*/)
- {
- //if(strcmp((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemData, "TRUE") == 0)// [If AuthorizeRemoteTxRequests = true
- //{
- sendAuthorizeRequest(0);
- authorizeRetryTimes = authorizeRetryTimes + 1;
- // authenrequest = TRUE
- if(authorizeRetryTimes < 3)
- ShmOCPP16Data->SpMsg.bits.AuthorizeReq = 0;
- //}
- }
- else if((server_sign == TRUE) && (ShmOCPP16Data->SpMsg.bits.AuthorizeReq == 1)&&(authorizeRetryTimes >= 3))
- {
- authorizeRetryTimes = 0;
- ShmOCPP16Data->OcppConnStatus = 0; // ocpp offline
- server_sign = FALSE;
- }
- else if((server_sign == FALSE) &&(strcmp((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemData, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData, "TRUE") == 0)&&(ShmOCPP16Data->OcppConnStatus == 0)&& (ShmOCPP16Data->SpMsg.bits.AuthorizeReq == 1))
- {
- sendAuthorizeRequest(0);
- }
- //===============================
- // CSU Trigger Smart Charging Profilw
- //===============================
- if((server_sign == TRUE) && (ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq == 1))
- {
- ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq = 0;
- GetChargingProfileRequest(gun_index);
- ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf = 1;
- }
- //==============================================
- // Charger start transaction
- //==============================================
- if(/*(server_sign == TRUE) &&*/ (ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq == 1))
- {
- sendStartTransactionRequest(gun_index);
- ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq =0;
- clientTime.StartTransaction = time((time_t*)NULL);
- clientTime.MeterValues[gun_index] = time((time_t*)NULL);
- }
- //==============================================
- // Charger stop transaction
- //==============================================
- if(/*(server_sign == TRUE) &&*/ ((ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 1)))
- {
- sendStopTransactionRequest(gun_index);
- ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq =0;
- clientTime.StopTransaction = time((time_t*)NULL);
- }
- //==============================================
- // Charger status report
- //==============================================
- /* Check Mode Change */
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]/*PRE_SYS_MODE[gun_index]*/ )
- {
- PRE_SYS_MODE[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
- ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
- cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
- statusModeChage[gun_index] = TRUE;
- }
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != CcsPreviousSystemStatus[index]/*PRE_SYS_MODE[gun_index]*/ )
- {
- PRE_SYS_MODE[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
- CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
- cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
- statusModeChage[gun_index] = TRUE;
- }
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)/*&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '4')*/)
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]/*PRE_SYS_MODE[gun_index]*/ )
- {
- PRE_SYS_MODE[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
- GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
- cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
- statusModeChage[gun_index] = TRUE;
- }
- }
- }
- }
- else //AC
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]/*PRE_SYS_MODE[gun_index]*/ )
- {
- PRE_SYS_MODE[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
- AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
- cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
- statusModeChage[gun_index] = TRUE;
- }
- }
- }// END OF FOR
- }// END OF ELSE
- if(((SystemInitial != 0)&& (server_sign == TRUE))||
- ((server_sign == TRUE) && ((statusModeChage[gun_index] == TRUE) ||
- ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > (server_cycle_Status + (GunStatusInterval*gun_index)))
- || ((cpinitateMsg.bits[gun_index].StatusNotificationReq == 1)&&((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 30)))))
- {
- if(SystemInitial != 0)
- SystemInitial = SystemInitial -1;
- sendStatusNotificationRequest(gun_index);
- clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
- statusModeChage[gun_index] = FALSE;
- }
- //==============================================
- // Meter report
- //==============================================
- if(/*(server_sign == TRUE) &&*/ ((time((time_t*)NULL) - clientTime.MeterValues[gun_index])> (atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData)- 1 ) ) )
- {
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- 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 == gun_index)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING))
- {
- meterValueSend[gun_index] =1;
- }
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
- {
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.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);
- }
- }
- }// End for CHAdeMO
- 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 == gun_index)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING))
- {
- meterValueSend[gun_index] =1;
- }
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
- {
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.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);
- }
- }
- } // End for CCS
- 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 == gun_index)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING))
- {
- meterValueSend[gun_index] =1;
- }
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
- {
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.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);
- }
- }
- }// End for GB
- }
- else
- {
- 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 == gun_index)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING))
- {
- meterValueSend[gun_index] =1;
- }
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
- {
- sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.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);
- }
- }
- }//End for AC
- }//END OF ELSE
- // sleep(1);
- clientTime.MeterValues[gun_index] = time((time_t*)NULL);
- if(meterValueSend[gun_index] == 1)
- sendMeterValuesRequest(gun_index);
- }
- //==============================================
- // Check Connector reserved
- //==============================================
- //===============================
- // Check if Reserve is expired
- //===============================
- if((server_sign == TRUE) && (ShmOCPP16Data->ReserveNow[gun_index].ExpiryDate[0] != 0) )
- {
- double diff_t;
- struct tm tp;
- // current time
- time_t t = time(NULL);
- strptime((char *)ShmOCPP16Data->ReserveNow[gun_index].ExpiryDate, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- time_t utc = mktime(&tp);
- diff_t = difftime(utc, t);
- if(diff_t <= 0)
- {
- DEBUG_INFO("reserve expired !!! \n");
- memset(ShmOCPP16Data->ReserveNow[gun_index].ExpiryDate,0,sizeof(ShmOCPP16Data->ReserveNow[gun_index].ExpiryDate));
- }
- }//END OF Check if Reserve is expired
- //==========================================
- // csu trigger FirmwareStatusNotificationReq
- //==========================================
- if((server_sign == TRUE) && (ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq == 1))
- {
- sendFirmwareStatusNotificationRequest((char *)ShmOCPP16Data->FirmwareStatusNotification.Status);
- }
- //==========================================
- // csu trigger CancelReservationConf
- //==========================================
- if((server_sign == TRUE) && (ShmOCPP16Data->CsMsg.bits[gun_index].CancelReservationConf == 1))
- {
- sendCancelReservationConfirmation((char *)ShmOCPP16Data->CancelReservation[gun_index].guid,(char *)ShmOCPP16Data->CancelReservation[gun_index].ResponseStatus);
- }
- //==========================================
- // csu trigger ChangeAvailabilityConf
- //==========================================
- if((server_sign == TRUE) && (ShmOCPP16Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == 1))
- {
- //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP16Data->ChangeAvailability[gun_index].ResponseStatus);
- }
- //==========================================
- // csu trigger UnlockConnectorConf
- //==========================================
- if((server_sign == TRUE) && (ShmOCPP16Data->CsMsg.bits[gun_index].UnlockConnectorConf == 1))
- {
- sendUnlockConnectorConfirmation((char *)ShmOCPP16Data->UnlockConnector[gun_index].guid, (char *)ShmOCPP16Data->UnlockConnector[gun_index].ResponseStatus);
- ShmOCPP16Data->CsMsg.bits[gun_index].UnlockConnectorConf = 0;
- }
- //==========================================
- // csu trigger ReserveNowConf
- //==========================================
- if((server_sign == TRUE) &&(ShmOCPP16Data->CsMsg.bits[gun_index].ReserveNowConf == 1))
- {
- sendReserveNowTransactionConfirmation((char *)ShmOCPP16Data->ReserveNow[gun_index].guid, (char *)ShmOCPP16Data->ReserveNow[gun_index].ResponseStatus);
- ShmOCPP16Data->CsMsg.bits[gun_index].ReserveNowConf = 0;
- }
- //==========================================
- // csu trigger DataTransferReq
- //==========================================
- if((server_sign == TRUE) &&(ShmOCPP16Data->CsMsg.bits[gun_index].DataTransferReq == 1))
- {
- sendDataTransferRequest(gun_index);
- ShmOCPP16Data->CsMsg.bits[gun_index].DataTransferReq = 0;
- }
- }
- }
- //==========================================
- // send request routine
- //==========================================
- int sendAuthorizeRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[100]={0};
- char guid[37];
- char tempdata[65]={0};
- DEBUG_INFO("sendAuthorizeRequest \n");
- //Local Authorize
- if((strcmp((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemData, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData, "TRUE") == 0)&&(ShmOCPP16Data->OcppConnStatus == 0))
- {
- OCPP_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId);
- if((strcmp(idTagQuery.idTagstr,"") == 0) || (strcmp(idTagQuery.idTagstatus,"Accepted") != 0) )
- {
- DEBUG_INFO("offline Local Authorization Fail !!!!\n");
- strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ExpiryDate, "");
- strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
- strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Invalid");
- ShmOCPP16Data->SpMsg.bits.AuthorizeReq = 0;
- ShmOCPP16Data->SpMsg.bits.AuthorizeConf = 1; // inform csu
- authorizeRetryTimes = 0;
- return result;
- }
- else
- {
- DEBUG_INFO("offline Local Authorization Pass !!!!\n");
- strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ExpiryDate, idTagQuery.expiryDate);
- strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
- strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, idTagQuery.idTagstatus);
- result = PASS;
- ShmOCPP16Data->SpMsg.bits.AuthorizeReq = 0;
- ShmOCPP16Data->SpMsg.bits.AuthorizeConf = 1; // inform csu
- authorizeRetryTimes = 0;
- return result;
- }
- }
- //initailize struct Authorize
- memset(&(ShmOCPP16Data->Authorize), 0 , sizeof(struct StructAuthorize));
- //get data from shared memory
- strcpy((char *)ShmOCPP16Data->Authorize.IdTag, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
- random_uuid(guid);
- sprintf(message,"[ %d, \"%s\", \"Authorize\", { \"idTag\": \"%s\" } ]",MESSAGE_TYPE_CALL, guid, ShmOCPP16Data->Authorize.IdTag);
- LWS_Send(message);
- sprintf(tempdata, "Authorize,%d", gun_index);
- if(hashmap_operation(0, guid, tempdata) == 1)
- {
- result = PASS;
- DEBUG_ERROR("Authorize mapItem pass\n");
- }
- ShmOCPP16Data->SpMsg.bits.AuthorizeReq = 0;
- return result;
- }
- int sendBootNotificationRequest(void)
- {
- mtrace();
- int result = FAIL;
- char message[500]={0}, payload[700]={0};
- char guid[37]={0};
- char tempdata[65]={0};
- int IsGunCharging = FALSE;
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- IsGunCharging = TRUE;
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- IsGunCharging = TRUE;
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- IsGunCharging = TRUE;
- }
- }
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
- {
- IsGunCharging = TRUE;
- }
- }
- }
- if(IsGunCharging == TRUE)
- {
- server_sign = TRUE;
- return result;
- }
- // Fill BootNotification fields
- strcpy((char *)ShmOCPP16Data->BootNotification.CbSN,(const char *)ShmOCPP16Data->ChargeBoxId);
- strcpy((char *)ShmOCPP16Data->BootNotification.CpModel,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName);
- strcpy((char *)ShmOCPP16Data->BootNotification.CpSN,(const char *)ShmSysConfigAndInfo->SysConfig.SerialNumber);
- strcpy((char *)ShmOCPP16Data->BootNotification.CpVendor,(const char *)ShmSysConfigAndInfo->SysConfig.chargePointVendor);
- strcpy((char *)ShmOCPP16Data->BootNotification.CpFwVersion,(const char *)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
- strcpy((char *)ShmOCPP16Data->BootNotification.CpIccid,(const char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
- strcpy((char *)ShmOCPP16Data->BootNotification.CpImsi,(const char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
- sprintf(payload, "{ \"chargeBoxSerialNumber\": \"%s\", \"chargePointModel\": \"%s\", \"chargePointSerialNumber\": \"%s\", \"chargePointVendor\": \"%s\", \"firmwareVersion\": \"%s\", \"iccid\": \"%s\", \"imsi\": \"%s\", \"meterSerialNumber\": \"%s\", \"meterType\": \"%s\"} ",
- ShmOCPP16Data->ChargeBoxId
- ,ShmSysConfigAndInfo->SysConfig.ModelName
- ,ShmSysConfigAndInfo->SysConfig.SerialNumber
- ,ShmSysConfigAndInfo->SysConfig.chargePointVendor
- ,ShmOCPP16Data->BootNotification.CpFwVersion
- ,ShmOCPP16Data->BootNotification.CpIccid
- ,ShmOCPP16Data->BootNotification.CpImsi
- ,ShmOCPP16Data->BootNotification.CpMeterSerialNumber
- ,ShmOCPP16Data->BootNotification.CpMeterType);
- random_uuid(guid);
- sprintf(message,"[ %d, \"%s\", \"%s\", %s ]",MESSAGE_TYPE_CALL, guid, "BootNotification", payload);
- LWS_Send(message);
- sprintf(tempdata, "BootNotification,0");
- if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, guid,mapItem, tempdata/*(void**)(&mapItem)*//*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
- {
- result = PASS;
- }
- memset(queuedata, 0, sizeof(queuedata));
- strcpy(queuedata,message);
- HeartBeatCount = 0;
- return result;
- }
- int sendDataTransferRequest(int gun_index)
- {
- mtrace();
- char message[1000]={0};
- char guid[37]={0};
- char tempdata[65]={0};
- int result = FAIL;
- //[2,"696e8a35-f394-45e3-a0c7-7098b86f38a6","DataTransfer",{"vendorId":"Phihong","messageId":"FeePerKWH","data":"1"}]
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
- MESSAGE_TYPE_CALL,
- guid,
- ShmOCPP16Data->DataTransfer[gun_index].VendorId,
- ShmOCPP16Data->DataTransfer[gun_index].MessageId,
- ShmOCPP16Data->DataTransfer[gun_index].Data);
- LWS_Send(message);
- sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
- if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
- {
- result = PASS;
- DEBUG_ERROR("DataTransfer mapItem pass\n");
- }
- return result;
- }
- int sendDiagnosticsStatusNotificationRequest(char *status)
- {
- mtrace();
- int result = FAIL;
- char message[110]={0};
- char guid[37]={0};
- char tempdata[65]={0};
- //[ 2, "9f7bced1-b8b1-40ec-b3bb-2e15630e3cdc", "DiagnosticsStatusNotification", { "status": "Idle" } ]
- DEBUG_INFO("sendDiagnosticsStatusNotificationRequest \n");
- sprintf((char *)ShmOCPP16Data->DiagnosticsStatusNotification.Status,"%s",(const char *)status);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"DiagnosticsStatusNotification\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALL, guid,status);
- LWS_Send(message);
- sprintf(tempdata, "DiagnosticsStatusNotification,%d", 0);
- if(hashmap_operation(0, guid, tempdata) == 1)
- {
- result = PASS;
- //DEBUG_INFO("DiagnosticsStatusNotification mapItem pass\n");
- }
- //#ifdef SystemLogMessage
- //DEBUG_INFO(">>>>>DiagnosticsStatusNotification request\n");
- //DEBUG_INFO("Message: %s\n", SendBuffer);
- //DEBUG_INFO("After push hash length: %d\n", hashmapForMessageLength()/*hashmap_length(hashMap)*/);
- //#endif
- ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 0;
- ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationConf = 0;
- //record status
- if(strcmp(status,"Idle")==0)
- {
- DiagnosticsStatusNotificationStatus = 0;
- }
- else if(strcmp(status,"Uploaded")==0)
- {
- DiagnosticsStatusNotificationStatus = 1;
- }
- else if(strcmp(status,"UploadFailed")==0)
- {
- DiagnosticsStatusNotificationStatus = 2;
- }
- else if(strcmp(status,"Uploading")==0)
- {
- DiagnosticsStatusNotificationStatus = 3;
- }
- return result;
- }
- int sendFirmwareStatusNotificationRequest(char *status)
- {
- mtrace();
- int result = FAIL;
- char message[110]={0};
- char guid[37]={0};
- char tempdata[65]={0};
- // [ 2, "eb841424-ae56-42b0-8c84-d5296018c33c", "FirmwareStatusNotification", { "status": "Downloaded" } ]
- DEBUG_INFO("sendFirmwareStatusNotificationRequest \n");
- sprintf((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "%s", (const char *)status);
- random_uuid(guid);
- sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALL, guid, status);
- LWS_Send(message);
- sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
- if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
- {
- result = PASS;
- DEBUG_INFO("FirmwareStatusNotification mapItem pass\n");
- }
- //#ifdef SystemLogMessage
- //DEBUG_INFO(">>>>>FirmwareStatusNotification request\n");
- //DEBUG_INFO("Message: %s\n", SendBuffer);
- //#endif
- ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 0;
- ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationConf = 0;
- //record status
- if(strcmp(status,"Downloaded")==0)
- {
- FirmwareStatusNotificationStatus = 0;
- }
- else if(strcmp(status,"DownloadFailed")==0)
- {
- FirmwareStatusNotificationStatus = 1;
- }
- else if(strcmp(status,"Downloading")==0)
- {
- FirmwareStatusNotificationStatus = 2;
- }
- else if(strcmp(status,"Idle")==0)
- {
- FirmwareStatusNotificationStatus = 3;
- }
- else if(strcmp(status,"InstallationFailed")==0)
- {
- FirmwareStatusNotificationStatus = 4;
- }
- else if(strcmp(status,"Installing")==0)
- {
- FirmwareStatusNotificationStatus = 5;
- }
- else if(strcmp(status,"Installed")==0)
- {
- FirmwareStatusNotificationStatus = 6;
- }
- return result;
- }
- int sendHeartbeatRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[80]={0};
- char guid[37]={0};
- char tempdata[65]={0};
- random_uuid(guid);
- sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
- , MESSAGE_TYPE_CALL
- , guid );
- LWS_Send(message);
- sprintf(tempdata, "Heartbeat,%d", 0);
- if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, guid, mapItem, tempdata/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
- {
- result = PASS;
- //DEBUG_ERROR("Heartbeat mapItem pass\n");
- }
- return result;
- }
- int sendStartTransactionRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- char message[250]={0};
- char guid[37]={0};
- struct timeval tmnow;
- struct tm *tm;
- char buf[28];//, usec_buf[6];
- char tempdata[65]={0};
- DEBUG_INFO("sendStartTransactionRequest...");
- 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
- ShmOCPP16Data->StartTransaction[gun_index].ConnectorId = gun_index +1 ; // gun start from 1~
- strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].Timestamp, buf);
- //strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].IdTag, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- ShmOCPP16Data->StartTransaction[gun_index].MeterStart = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
- ShmOCPP16Data->StartTransaction[gun_index].ReservationId = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId;
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- ShmOCPP16Data->StartTransaction[gun_index].MeterStart = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
- ShmOCPP16Data->StartTransaction[gun_index].ReservationId = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId;
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- ShmOCPP16Data->StartTransaction[gun_index].MeterStart = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
- ShmOCPP16Data->StartTransaction[gun_index].ReservationId = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId;
- }
- }
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- ShmOCPP16Data->StartTransaction[gun_index].MeterStart = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
- ShmOCPP16Data->StartTransaction[gun_index].ReservationId = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId;
- }
- }
- }//END OF ELSE
- random_uuid(guid);
- sprintf(message, "[%d,\"%s\",\"StartTransaction\",{\"connectorId\":%d,\"idTag\":\"%s\",\"meterStart\":%d,\"reservationId\":%d,\"timestamp\":\"%s\"}]"
- , MESSAGE_TYPE_CALL
- , guid
- , ShmOCPP16Data->StartTransaction[gun_index].ConnectorId
- , ShmOCPP16Data->StartTransaction[gun_index].IdTag
- , ShmOCPP16Data->StartTransaction[gun_index].MeterStart
- , ShmOCPP16Data->StartTransaction[gun_index].ReservationId
- , ShmOCPP16Data->StartTransaction[gun_index].Timestamp );
- sprintf(tempdata, "StartTransaction,%d", (gun_index));
- if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
- {
- result = PASS;
- }
- strcpy(queuedata, message);
- queue_operation(4, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
- LWS_Send(message);
- #if 0
- sprintf(tempdata, "StartTransaction,%d", (gun_index));
- if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
- {
- result = PASS;
- }
- strcpy(queuedata, message);
- queue_operation(4, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
- #endif
- //#ifdef SystemLogMessage
- //DEBUG_INFO(">>>>>StartTransaction request\n");
- //DEBUG_INFO("Message: %s\n", SendBuffer);
- //#endif
- 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};
- 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);
- ShmOCPP16Data->StatusNotification[gun_index].ConnectorId = (gun_index + 1);
- //strcpy(ShmOCPP16Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
- // it's option
- strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].Info, "");
- /*
- 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
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)) //S_IDLE
- {
- currentStatus = 0; //OCPP Status: Available
- }
- else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //S_PRECHARGE
- {
- currentStatus = 1; //OCPP Status: Preparing
- }
- else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)) //S_CHARGING
- {
- currentStatus = 2; //OCPP Status: Charging
- }
- else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) //S_COMPLETE
- {
- currentStatus = 5; //OCPP Status: Finishing
- }
- else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING))) //S_ALARM, S_TERMINATING ---> SuspendedEV
- {
- currentStatus = 4; //OCPP Status: SuspendedEV
- }
- else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&((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 = 7; //OCPP Status: Unavailable
- }
- else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT ---> Faulted
- {
- currentStatus = 8; //OCPP Status: Faulted
- }
- else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // ---> Reserved
- {
- currentStatus = 6; //OCPP Status: Reserved
- }
- }//end of for CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE)) //S_IDLE
- {
- currentStatus = 0; //OCPP Status: Available
- }
- else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //S_PRECHARGE
- {
- currentStatus = 1; //OCPP Status: Preparing
- }
- else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)) //S_CHARGING
- {
- currentStatus = 2; //OCPP Status: Charging
- }
- else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) //S_COMPLETE
- {
- currentStatus = 5; //OCPP Status: Finishing
- }
- else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING))) //S_ALARM ,S_TERMINATING ---> SuspendedEV
- {
- currentStatus = 4; //OCPP Status: SuspendedEV
- }
- else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&((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 = 7; //OCPP Status : Unavailable
- }
- else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT ---> Faulted
- {
- currentStatus = 8; //OCPP Status: Faulted
- }
- else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // ---> Reserved
- {
- currentStatus = 6; //OCPP Status: Reserved
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index) &&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)) //S_IDLE
- {
- currentStatus = 0; //OCPP Status: Available
- }
- else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index) &&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //S_PRECHARGE
- {
- currentStatus = 1; //OCPP Status: Preparing
- }
- else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)) //S_CHARGING
- {
- currentStatus = 2; //OCPP Status: Charging
- }
- else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) //S_COMPLETE
- {
- currentStatus = 5; //OCPP Status: Finishing
- }
- else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING))) //S_ALARM , S_TERMINATING ---> SuspendedEV
- {
- currentStatus = 4; //OCPP Status: SuspendedEV
- }
- else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&((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 = 7; //OCPP Status: Unavailable
- }
- else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT ---> Faulted
- {
- currentStatus = 8; //OCPP Status: Faulted
- }
- else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // ---> Reserved
- {
- currentStatus = 6; //OCPP Status: Reserved
- }
- }
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE)) //S_IDLE
- {
- currentStatus = 0; //OCPP Status: Available
- }
- else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //S_PRECHARGE
- {
- currentStatus = 1; //OCPP Status: Preparing
- }
- else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)) //S_CHARGING
- {
- currentStatus = 2; //OCPP Status: Charging
- }
- else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) //S_COMPLETE
- {
- currentStatus = 5; //OCPP Status: Finishing
- }
- else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING))) //S_ALARM, S_TERMINATING ---> SuspendedEV
- {
- currentStatus = 4; //OCPP Status: SuspendedEV
- }
- else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&((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 = 7; //OCPP Status: Unavailable
- }
- else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT ---> Faulted
- {
- currentStatus = 8; //OCPP Status: Faulted
- }
- else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // ---> Reserved
- {
- currentStatus = 6; //OCPP Status: Reserved
- }
- }//end of for AC_QUANTITY
- }//END OF ELSE
- //it's option
- strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].Timestamp, buf);
- strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].VendorId, "PhihongTechnology");
- strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].Status, ChargePointStatusStr[currentStatus]);
- random_uuid(guid);
- sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"errorCode\":\"%s\",\"info\":\"%s\",\"status\":\"%s\",\"timestamp\":\"%s\",\"vendorId\":\"%s\",\"vendorErrorCode\":\"%s\"}]"
- , MESSAGE_TYPE_CALL
- , guid
- , ShmOCPP16Data->StatusNotification[gun_index].ConnectorId
- , ShmOCPP16Data->StatusNotification[gun_index].ErrorCode
- , ShmOCPP16Data->StatusNotification[gun_index].Info
- , ShmOCPP16Data->StatusNotification[gun_index].Status
- , ShmOCPP16Data->StatusNotification[gun_index].Timestamp
- , ShmOCPP16Data->StatusNotification[gun_index].VendorId
- , ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode);
- LWS_Send(message);
- sprintf(tempdata, "StatusNotification,%d", (gun_index));
- if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, guid, mapItem, tempdata/*(void**)(&mapItem)*//*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
- {
- //DEBUG_ERROR("statusNotification mapitem pass");
- result = PASS;
- }
- return result;
- }
- int sendStopTransactionRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- //char message[1500]={0};
- char guid[37]={0};
- char tempdata[65]={0};
- //int idx_sample=0;
- DEBUG_ERROR("sendStopTransactionRequest \n");
- memset(queuedata, 0, sizeof(queuedata));
- //ENERGY_ACTIVE_IMPORT_REGISTER
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
- }
- }// END OF CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
- }
- }// END OF CCS_QUANTITY
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
- }
- }// END OF GB_QUANTITY
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- ShmOCPP16Data->StopTransaction[gun_index].MeterStop = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
- }
- }// END OF AC_QUANTITY
- }//END OF ELSE
- //Stop Transaction 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);
- strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].Timestamp,buf);
- ShmOCPP16Data->StopTransaction[gun_index].TransactionId = ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId;
- random_uuid(guid);
- /***********************************transactionData******************************************************/
- memset(ShmOCPP16Data->StopTransaction[gun_index].TransactionData, 0, sizeof(sizeof(struct StructMeterValue)));
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].TimeStamp, buf);
- //=================================
- // Transaction_Begin
- //=================================
- // Energy.Active.Export.Interval
- //idx_sample=0;
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Value, "%.1f",(float)(ShmOCPP16Data->StartTransaction[gun_index].MeterStart)*1000); // MeterStart is 0~6553.5 kWh
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Context,ReadingContextStr[ReadingContext_Transaction_Begin]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Format,ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Measurand,MeasurandStr[Energy_Active_Export_Interval]);//MeasurandStr[Energy_Active_Export_Interval/*Energy_Reactive_Export_Register*/]);
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Phase,PhaseStr[L3_N]);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Phase,PhaseStr[L1_N]);
- }
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Location,LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Unit,UnitOfMeasureStr[UnitOfMeasure_Wh/*UnitOfMeasure_kWh*/]);
- //=================================
- // Transaction_End
- //=================================
- //Current.Export
- //idx_sample=1;
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent );// PresentChargingCurrent is 0~6553.5 amp
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent );// PresentChargingCurrent is 0~6553.5 amp
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent );// PresentChargingCurrent is 0~6553.5 amp
- }
- }
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Phase,PhaseStr[L3_N]);
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent );// 0~6553.5 amp for EVSE
- }
- }
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Phase,PhaseStr[L1_N]);
- }// END FOR AC ELSE
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Context,ReadingContextStr[ReadingContext_Transaction_End]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Format,ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Measurand,MeasurandStr[Current_Export]);
- //strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Phase,PhaseStr[L1_N]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Location,LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Unit,UnitOfMeasureStr[UnitOfMeasure_A]);
- //Energy.Active.Export.Interval
- //idx_sample=2;
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy*1000 );// PresentChargedEnergy is 0~6553.5 kWh
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy*1000 );// PresentChargedEnergy is 0~6553.5 kWh
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy*1000 );// PresentChargedEnergy is 0~6553.5 kWh
- }
- }
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Phase,PhaseStr[L3_N]);
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy*1000 );// PresentChargedEnergy is 0~6553.5 kWh
- }
- }
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Phase,PhaseStr[L1_N]);
- }// END FOR AC ELSE
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Context,ReadingContextStr[ReadingContext_Transaction_End]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Format,ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Measurand,MeasurandStr[Energy_Active_Export_Interval]);
- //strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Phase,PhaseStr[L1_N]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Location,LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Unit,UnitOfMeasureStr[UnitOfMeasure_Wh/*UnitOfMeasure_kWh*/]);
- //Power.Active.Export
- //idx_sample=3;
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower );// PresentChargingPower is 0~6553.5 kW
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower );// PresentChargingPower is 0~6553.5 kW
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower );// PresentChargingPower is 0~6553.5 kW
- }
- }
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Phase,PhaseStr[L3_N]);
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower );// PresentChargingPower is 0~6553.5 kW
- }
- }
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Phase,PhaseStr[L1_N]);
- }// END FOR AC ELSE
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Context,ReadingContextStr[ReadingContext_Transaction_End]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Format,ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Measurand,MeasurandStr[Power_Active_Export]);
- //strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Phase,PhaseStr[L1_N]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Location,LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Unit,UnitOfMeasureStr[UnitOfMeasure_kW/*UnitOfMeasure_kWh*/]);
- //Voltage
- //idx_sample=4;
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage );// PresentChargingVoltage is 0~6553.5 volt
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage );// PresentChargingVoltage is 0~6553.5 volt
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage );// PresentChargingVoltage is 0~6553.5 volt
- }
- }
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Phase,PhaseStr[L3_N]);
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage );//AcChargingVoltage is 0~6553.5 volt for AC EVSE
- }
- }
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Phase,PhaseStr[L1_N]);
- }// END FOR AC ELSE
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Context,ReadingContextStr[ReadingContext_Transaction_End]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Format,ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Measurand,MeasurandStr[Voltage]);
- //strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Phase,PhaseStr[L1_N]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Location,LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Unit,UnitOfMeasureStr[UnitOfMeasure_V]);
- //SoC
- //idx_sample=5;
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc );// 0~100%
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc );// 0~100%
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc );// 0~100%
- }
- }
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Context,ReadingContextStr[ReadingContext_Transaction_End]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Format,ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Measurand,MeasurandStr[SoC/*Energy_Reactive_Export_Register*/]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Phase,PhaseStr[L3_N]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Location,LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Unit,UnitOfMeasureStr[UnitOfMeasure_Percent/*UnitOfMeasure_kWh*/]);
- } // END FOR DC CASE
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- sprintf(queuedata,"[%d,\"%s\",\"StopTransaction\",{\"idTag\":\"%s\",\"meterStop\":%d,\"timestamp\":\"%s\",\"transactionId\":%d,\"reason\":\"%s\",\"transactionData\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" },{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" },{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" },{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" },{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" },{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" } ] } ] } ]"
- ,MESSAGE_TYPE_CALL
- ,guid
- ,ShmOCPP16Data->StopTransaction[gun_index].IdTag
- ,ShmOCPP16Data->StopTransaction[gun_index].MeterStop
- ,ShmOCPP16Data->StopTransaction[gun_index].Timestamp
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionId
- ,ShmOCPP16Data->StopTransaction[gun_index].StopReason
- ,(const char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].TimeStamp
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Unit
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Unit
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Unit
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Unit
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Unit
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[5].Unit
- );
- }
- else
- {
- sprintf(queuedata,"[%d,\"%s\",\"StopTransaction\",{\"idTag\":\"%s\",\"meterStop\":%d,\"timestamp\":\"%s\",\"transactionId\":%d,\"reason\":\"%s\",\"transactionData\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" },{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" },{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" },{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" },{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\" } ] } ] } ]"
- ,MESSAGE_TYPE_CALL
- ,guid
- ,ShmOCPP16Data->StopTransaction[gun_index].IdTag
- ,ShmOCPP16Data->StopTransaction[gun_index].MeterStop
- ,ShmOCPP16Data->StopTransaction[gun_index].Timestamp
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionId
- ,ShmOCPP16Data->StopTransaction[gun_index].StopReason
- ,(const char *)ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].TimeStamp
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[0].Unit
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[1].Unit
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[2].Unit
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[3].Unit
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Value
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Context
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Format
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Measurand
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Phase
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Location
- ,ShmOCPP16Data->StopTransaction[gun_index].TransactionData[0].SampledValue[4].Unit
- );
- }
- sprintf(tempdata, "StopTransaction,%d", (gun_index));
- if(hashmap_operation(0, guid, tempdata) == 1)
- {
- result = PASS;
- DEBUG_INFO("StopTransaction mapitem pass\n");
- }
- queue_operation(4, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
- LWS_Send(queuedata);
- #if 0
- sprintf(tempdata, "StopTransaction,%d", (gun_index));
- if(hashmap_operation(0, guid, tempdata) == 1)
- {
- result = PASS;
- DEBUG_INFO("StopTransaction mapitem pass\n");
- }
- queue_operation(4, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
- #endif
- //for test
- ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq = 0;
- return result;
- }
- int sendMeterValuesRequest(int gun_index)
- {
- mtrace();
- int result = FAIL;
- // char message[1500]={0};
- char guid[37]={0};
- //int idx_sample=0;
- //int length = 0;
- char tempdata[65]={0};
- DEBUG_ERROR("sendMeterValuesRequest ...\n");
- //DEBUG_ERROR("gun_index =%d\n",gun_index);
- if((ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId == 0)&&(ShmOCPP16Data->CsMsg.bits[gun_index].TriggerMessageReq == 0)) // no TransactionId
- {
- DEBUG_INFO("NOT SENT METER Vlaue\n");
- //DEBUG_ERROR("ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId =%d\n",ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId);
- //DEBUG_ERROR("ShmOCPP16Data->CsMsg.bits[gun_index].TriggerMessageReq =%d\n",ShmOCPP16Data->CsMsg.bits[gun_index].TriggerMessageReq);
- return result;
- }
- if(ShmOCPP16Data->CsMsg.bits[gun_index].TriggerMessageReq == 1)
- {
- ShmOCPP16Data->CsMsg.bits[gun_index].TriggerMessageReq = 0;
- }
- memset(queuedata, 0, sizeof(queuedata));
- //set value
- ShmOCPP16Data->MeterValues[gun_index].ConnectorId = gun_index + 1; // gun start from 1~
- ShmOCPP16Data->MeterValues[gun_index].TransactionId = ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId;
- random_uuid(guid);
- //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);
- strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].TimeStamp, buf);
- DEBUG_INFO( "ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
- //idx_sample=0;
- //********************************(1)Current.Export************************************************/
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent );
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent );
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent );
- }
- }
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Phase, PhaseStr[L3_N]);
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent );
- }
- }
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Phase, PhaseStr[L1_N]);
- }// END FOR AC ELSE
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Format, ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Measurand, MeasurandStr[Current_Export]);
- //strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Phase, PhaseStr[L1_N]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Location, LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Unit,UnitOfMeasureStr[UnitOfMeasure_A]);
- //idx_sample=1;
- //****************************************************(3)Energy.Active.Export.Interval*********************************************/
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy );
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- // printf("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].Index=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index );
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- //ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy = 100.0;
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy );
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy);
- }
- }
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L3_N]);
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy );
- }
- }
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L1_N]);
- }//END FOR AC ELSE
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Format, ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Measurand, MeasurandStr[Energy_Active_Export_Interval]);
- //strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase, PhaseStr[L1_N]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Location, LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Unit,UnitOfMeasureStr[UnitOfMeasure_kWh]);
- //idx_sample=2;
- //********************************(4)Power.Active.Export************************************************/
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower);
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower);
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower);
- }
- }
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L3_N]);
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value, "%.1f" , ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower);
- }
- }
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L1_N]);
- }// END FOR AC ELSE
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Format, ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Measurand, MeasurandStr[Power_Active_Export]);
- //strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase, PhaseStr[L1_N]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Location, LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Unit,UnitOfMeasureStr[UnitOfMeasure_kW]);
- //idx_sample=3;
- //***********************************************(5)VOLTAGE******************************************************/
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage );
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage );
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage );
- }
- }
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L3_N]);
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value, "%.1f" ,ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage );
- }
- }
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L1_N]);
- }//END FOR AC ELSE
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Format, ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Measurand, MeasurandStr[Voltage]);
- // strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase, PhaseStr[L1_N]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Location, LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Unit,UnitOfMeasureStr[UnitOfMeasure_V]);
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- //idx_sample=4;
- //sampledValue = NULL;
- //***********************************************(6)SOC******************************************************/
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc );
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc );
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc );
- }
- }
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Format, ValueFormatStr[Raw]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Measurand, MeasurandStr[SoC]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase, PhaseStr[L3_N]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Location, LocationStr[Location_Outlet]);
- strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Unit,UnitOfMeasureStr[UnitOfMeasure_Percent]);
- }
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",{\"connectorId\":%d,\"transactionId\":%d,\"meterValue\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
- ,MESSAGE_TYPE_CALL
- ,guid
- ,ShmOCPP16Data->MeterValues[gun_index].ConnectorId
- ,ShmOCPP16Data->MeterValues[gun_index].TransactionId
- ,(const char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].TimeStamp
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Value
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Context
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Format
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Measurand
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Phase
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Location
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Unit
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Context
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Format
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Measurand
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Location
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Unit
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Context
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Format
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Measurand
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Location
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Unit
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Context
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Format
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Measurand
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Location
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Unit
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Value
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Context
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Format
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Measurand
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Phase
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Location
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[4].Unit
- );
- }
- else
- {
- sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",{\"connectorId\":%d,\"transactionId\":%d,\"meterValue\":[{\"timestamp\":\"%s\",\"sampledValue\":[{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"},{\"value\":\"%s\",\"context\":\"%s\",\"format\":\"%s\",\"measurand\":\"%s\",\"phase\":\"%s\",\"location\":\"%s\",\"unit\":\"%s\"}]}]}]"
- ,MESSAGE_TYPE_CALL
- ,guid
- ,ShmOCPP16Data->MeterValues[gun_index].ConnectorId
- ,ShmOCPP16Data->MeterValues[gun_index].TransactionId
- ,(const char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].TimeStamp
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Value
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Context
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Format
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Measurand
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Phase
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Location
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[0].Unit
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Value
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Context
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Format
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Measurand
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Phase
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Location
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[1].Unit
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Value
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Context
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Format
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Measurand
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Phase
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Location
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[2].Unit
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Value
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Context
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Format
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Measurand
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Phase
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Location
- ,ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[3].Unit
- );
- }
- // Put request guid to hash map
- sprintf(tempdata, "MeterValues,%d", (gun_index));
- if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
- {
- result = PASS;
- DEBUG_INFO("MeterValues mapitem pass\n");
- }
- queue_operation(4, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
- LWS_Send(queuedata);
- #if 0
- // Put request guid to hash map
- sprintf(tempdata, "MeterValues,%d", (gun_index));
- if(hashmap_operation(0, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, mapItem[0].key_string, mapItem[0].key_value/*mapItem*/, (void**)(&mapItem)/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
- {
- result = PASS;
- DEBUG_INFO("MeterValues mapitem pass\n");
- }
- queue_operation(4, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
- #endif
- return result;
- }
- //==========================================
- // send confirm routine
- //==========================================
- int sendCancelReservationConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[100]={0};
- DEBUG_ERROR("handle sendCancelReservationConfirmation\n");
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT,uuid, payload);
- LWS_Send(message);
- result = TRUE;
- ShmOCPP16Data->CsMsg.bits[0].CancelReservationConf = 0;
- return result;
- }
- int sendChangeAvailabilityConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[100]={0};
- DEBUG_ERROR("handle sendChangeAvailabilityConfirmation\n");
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT,uuid, payload);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendChangeConfigurationConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[100]={0};
- DEBUG_ERROR("handle sendChangeConfigurationConfirmation\n");
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT,uuid, payload);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendClearCacheConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[500]={0};
- // int count = 0;
- // int gun_index = 0;
- // char guid[37];
- // [ 3, "1570592744204", { "status": "Accepted" } ]
- DEBUG_ERROR("sendClearCacheConfirmation\n");
- sprintf(message,"[ %d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
- LWS_Send(message);
- return result;
- }
- int sendClearChargingProfileConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[500]={0};
- // [ 3, "1571284268200", { "status": "Unknown" } ]
- DEBUG_ERROR("sendClearChargingProfileConfirmation\n");
- sprintf(message,"[ %d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
- LWS_Send(message);
- return result;
- }
- int sendDataTransferConfirmation(char *uuid,char *payload)
- {
- mtrace();
- char statusStr[20]={0};
- char dataStr[10]={0};
- char sstr[20]={0};
- int c = 0;
- char *loc;
- int result = FAIL;
- // [3,"792bc950-b279-49e3-ab8f-429e02a2f9a7",{"status":"Accepted","data":"True"}]
- DEBUG_ERROR("sendDataTransferConfirmation ...\n");
- /**********************status**************************/
- loc = strstr(payload, "status");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("status")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("status")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(statusStr, sstr);
- /**********************data**************************/
- loc = strstr(payload, "data");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("data")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("data")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(dataStr, sstr);
- return result;
- }
- int sendGetCompositeScheduleConfirmation(char *uuid,char *payload, int connectorIdInt,int nPeriod)
- {
- mtrace();
- int result = FAIL;
- char message[1000]={0};
- double diff_f = 0.0;
- int diff_i = 0;
- int diffSeconds = 0;
- struct tm tp;
- int TimeZero = FALSE;
- int CompositeScheduleIndex = 0;
- DEBUG_INFO("handle sendGetCompositeScheduleConfirmation ...\n");
- if((CurrentChargingProfileScheduleStr == NULL)||(strcmp((const char *)CurrentChargingProfileScheduleStr,"")==0))
- {
- TimeZero = TRUE;
- }
- else
- {
- strptime((const char *)CurrentChargingProfileScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
- }
- if(TimeZero == FALSE)
- {
- tp.tm_isdst = -1;
- time_t utc = mktime(&tp);
- time_t t = time(NULL);
- diff_f = difftime(t, utc);
- diff_i = (int)diff_f;
- diffSeconds = diff_i % 86400;//86400 seconds/day
- }
- //DEBUG_INFO("\n diff_f=%f \n",diff_f);
- CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
- #if 0 //remove temporally
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\",\"connectorId\":%d,\"scheduleStart\":\"%s\",\"chargingSchedule\":{\"duration\":%d,\"startSchedule\":\"%s\",\"chargingRateUnit\":\"%s\",\"chargingSchedulePeriod\":[{\"startPeriod\":0,\"limit\":6.0,\"numberPhases\":3},{\"startPeriod\":40,\"limit\":10.0,\"numberPhases\":3},{\"startPeriod\":100,\"limit\":8.0,\"numberPhases\":3}"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,payload
- ,connectorIdInt
- ,ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.StartSchedule
- ,ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.Duration
- ,ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.StartSchedule
- ,ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.ChargingRateUnit);
- #endif
- if(nPeriod == 0)
- {
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\",\"connectorId\":%d,\"scheduleStart\":\"%s\"}]"
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,payload
- ,connectorIdInt
- ,ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.StartSchedule);
- }
- else
- {
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\",\"connectorId\":%d,\"scheduleStart\":\"%s\",\"chargingSchedule\":{\"duration\":%d,\"startSchedule\":\"%s\",\"chargingRateUnit\":\"%s\",\"chargingSchedulePeriod\":["
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid
- ,payload
- ,connectorIdInt
- ,ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.StartSchedule
- ,ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.Duration
- ,ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.StartSchedule
- ,ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingRateUnit);
- int len = nPeriod;
- //Last Period StartPriod is less than diffSeconds
- if(ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[len -1].StartPeriod < diffSeconds)
- {
- sprintf(message + strlen(message), "{\"startPeriod\":%d,\"limit\":%.1f,\"numberPhases\":%d}"
- , 0
- , ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[len -1].Limit
- , ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[len -1].NumberPhases );
- }
- else
- {
- for(int idx_sample=0;idx_sample< len;idx_sample++)
- {
- if((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod < diffSeconds) && (ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample + 1].StartPeriod > diffSeconds))//if (idx_sample == 0)
- {
- sprintf(message + strlen(message), "{\"startPeriod\":%d,\"limit\":%.1f,\"numberPhases\":%d}"
- , 0 /*ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod*/
- , ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].Limit
- , ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].NumberPhases );
- }
- else if(ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod > diffSeconds)
- {
- sprintf(message + strlen(message), ",{\"startPeriod\":%d,\"limit\":%.1f,\"numberPhases\":%d}"
- , (ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/)//(((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds ) <= 0)?(ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod):(ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/)) //(((ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/) <= 0)?(ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod):(ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].StartPeriod - diffSeconds /*-1*/))
- , ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].Limit
- , ShmOCPP16Data->GetCompositeSchedule[CompositeScheduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[idx_sample].NumberPhases );
- }
- }
- }
- sprintf(message + strlen(message), "]}}]");
- }
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetConfigurationConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- int MaxKeySupported = 0;
- int sentConfigurationNumber= 0;
- int sentunConfigurationNumber= 0;
- char message[4000]={0};
- DEBUG_ERROR("handle sendGetConfigurationConfirmation ...\n");
- MaxKeySupported = atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemData);
- //DEBUG_INFO("MaxKeySupported=%d\n",MaxKeySupported);
- sprintf(message,"[%d,\"%s\",{\"configurationKey\":[ "
- ,MESSAGE_TYPE_CALLRESULT
- ,uuid );
- //configuration key
- for(int idx_sample=0;idx_sample< MaxKeySupported/*43*/;idx_sample++)
- {
- if(strcmp((const char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[idx_sample].Key, "")!= 0)
- {
- if (sentConfigurationNumber == 0)
- {
- sprintf(message + strlen(message), "{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}"
- , ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[idx_sample].Key
- , atoi((const char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[idx_sample].ReadOnly) == 1 ? "true":"false"
- , ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[idx_sample].Value );
- }
- else
- {
- sprintf(message + strlen(message), ", {\"key\":\"%s\",\"readonly\":%s,\"value\":\"%s\"}"
- , ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[idx_sample].Key
- , atoi((const char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[idx_sample].ReadOnly) == 1 ? "true":"false"
- , ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[idx_sample].Value );
- }
- sentConfigurationNumber = sentConfigurationNumber + 1;
- }
- }
- sprintf(message + strlen(message), "]");
- if(UnknownKeynum != 0)
- {
- sprintf(message + strlen(message), ",\"unknownKey\":[");
- //unkown key
- for(int idx_sample=0;idx_sample< UnknownKeynum ;idx_sample++)
- {
- // json_object *jstring1 = json_object_new_string((const char *)((ShmOCPP16Data->GetConfiguration.ResponseUnknownKey + idx_sample)->Item));
- DEBUG_INFO("unkown key:%s\n", ShmOCPP16Data->GetConfiguration.ResponseUnknownKey[idx_sample].Item);
- if(sentunConfigurationNumber == 0)
- {
- sprintf(message + strlen(message), "\"%s\""
- , ShmOCPP16Data->GetConfiguration.ResponseUnknownKey[idx_sample].Item );
- }
- else
- {
- sprintf(message + strlen(message), ",\"%s\""
- , ShmOCPP16Data->GetConfiguration.ResponseUnknownKey[idx_sample].Item );
- }
- sentunConfigurationNumber = sentunConfigurationNumber + 1;
- }
- sprintf(message + strlen(message), "]");
- }
- sprintf(message + strlen(message), "} ]");
- LWS_Send(message);
- return result;
- }
- int sendGetDiagnosticsConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[400]={0};
- DEBUG_ERROR("handle sendGetDiagnosticsConfirmation ...\n");
- if(strcmp(payload,"")==0)
- {
- sprintf(message,"[%d,\"%s\",{}]",MESSAGE_TYPE_CALLRESULT, uuid);
- }
- else
- {
- sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "fileName", payload);
- }
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendGetLocalListVersionConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[80]={0};
- //[ 3, "4f0141fb-f3a0-4634-9179-b1379b514d3c", { "listVersion": 1 } ]
- DEBUG_ERROR("handle GetLocalListVersionRequest ...\n");
- sprintf(message,"[%d,\"%s\",{\"listVersion\":%d}]",MESSAGE_TYPE_CALLRESULT, uuid, ShmOCPP16Data->GetLocalListVersion.ResponseListVersion);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendRemoteStartConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[80]={0};
- //[3,"26f6b7bc-a6e8-48a8-bdc5-a541bf8f9e27",{"status":"Accepted"}]
- DEBUG_ERROR("handleRemoteStartRequest ...\n");
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, payload);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendRemoteStopTransactionConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[80]={0};
- // [3,"287d837d-809e-41ea-8385-fdab7f72a01c",{"status":"Accepted"}]
- DEBUG_ERROR("sendRemoteStopTransactionConfirmation ...\n");
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, payload);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendReserveNowTransactionConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[80]={0};
- // [3,"287d837d-809e-41ea-8385-fdab7f72a01c",{"status":"Accepted"}]
- DEBUG_ERROR("sendReserveNowTransactionConfirmation\n");
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, payload);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendResetConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- //[ 3, "6f88d461-4d17-462c-a69b-1f7a8c5b12df", { "status": 0 } ]
- char message[80]={0};
- ShmOCPP16Data->MsMsg.bits.ResetConf = 0;
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, payload);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendSendLocalListConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[500]={0};
- // [ 3, "1571284266109", { "status": "Accepted" } ]
- sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendSetChargingProfileConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- //[3,"5748585f-8524-4fa6-9b4f-4a7eca750b90",{"status":"NotSupported"}]
- char message[80]={0};
- DEBUG_INFO("sendSetChargingProfileConfirmation\n");
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, payload);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendTriggerMessageConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[80]={0};
- DEBUG_INFO("sendTriggerMessageConfirmation\n");
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, payload);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendUnlockConnectorConfirmation(char *uuid,char *payload)
- {
- mtrace();
- int result = FAIL;
- char message[80]={0};
- //[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
- DEBUG_INFO("sendUnlockConnectorConfirmation\n");
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, payload);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- int sendUpdateFirmwareConfirmation(char *uuid)
- {
- mtrace();
- int result = FAIL;
- char message[60]={0};
- //[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
- DEBUG_INFO("sendUpdateFirmwareConfirmation\n");
- sprintf(message,"[%d,\"%s\",{}]",MESSAGE_TYPE_CALLRESULT, uuid);
- LWS_Send(message);
- result = TRUE;
- return result;
- }
- //==========================================
- // send CallError routine
- //==========================================
- void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
- {
- mtrace();
- //int result = FAIL;
- char message[220]={0};
- // [4,"f1c52ff5-e65d-4070-b7d4-6c70bc1e8970","PropertyConstraintViolation","Payload is syntactically correct but at least one field contains an invalid value",{}]
- #ifdef SystemLogMessage
- DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n",
- uniqueId, action, errorCode, errorDescription);
- #endif
- sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
- LWS_Send(message);
- //result = TRUE;
- }
- //==========================================
- // Handle server request routine Start
- //==========================================
- #define GUN_NUM 1
- int handleCancelReservationRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int gunNO = 0;
- int reservationIdInt =0;
- char comfirmstr[20];
- int c = 0;
- char *loc;
- char sstr[100]={0};
- DEBUG_INFO("handle CancelReservationRequest\n");
- //ShmOCPP16Data->CsMsg.bits[gunNO].CancelReservationReq = 1;
- c = 0;
- loc = strstr(payload, "reservationId");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("reservationId")+2+c] != '}')
- {
- sstr[c] = loc[strlen("reservationId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- reservationIdInt = atoi(sstr);
- memset(comfirmstr, 0, sizeof comfirmstr);
- sprintf(comfirmstr, "%s", CancelReservationStatusStr[CancelReservationStatus_Rejected]);
- //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
- {
- sprintf(comfirmstr, "%s", CancelReservationStatusStr[CancelReservationStatus_Accepted] );
- sprintf((char *)ShmOCPP16Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].ResponseStatus, "%s", comfirmstr );
- gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
- ShmOCPP16Data->CsMsg.bits[gunNO].CancelReservationReq = 1;
- goto end;
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
- {
- sprintf(comfirmstr, "%s", CancelReservationStatusStr[CancelReservationStatus_Accepted] );
- sprintf((char *)ShmOCPP16Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].ResponseStatus, "%s", comfirmstr );
- gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
- ShmOCPP16Data->CsMsg.bits[gunNO].CancelReservationReq = 1;
- goto end;
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
- {
- sprintf(comfirmstr, "%s", CancelReservationStatusStr[CancelReservationStatus_Accepted] );
- sprintf((char *)ShmOCPP16Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].ResponseStatus, "%s", comfirmstr );
- gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
- ShmOCPP16Data->CsMsg.bits[gunNO].CancelReservationReq = 1;
- goto end;
- }
- }
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
- {
- sprintf(comfirmstr, "%s", CancelReservationStatusStr[CancelReservationStatus_Accepted] );
- sprintf((char *)ShmOCPP16Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].ResponseStatus, "%s", comfirmstr );
- gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
- ShmOCPP16Data->CsMsg.bits[gunNO].CancelReservationReq = 1;
- goto end;
- }
- }
- }// END FOR AC ELSE
- //The reservationId does NOT match the reservationId
- sendCancelReservationConfirmation(uuid, comfirmstr);
- end:
- // Fill in ocpp packet uuid
- strcpy((char *)ShmOCPP16Data->CancelReservation[gunNO].guid, uuid);
- return result;
- }
- int handleChangeAvailabilityRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int gunIndex = 0;
- char sstr[90]={0};
- char typeStr[16]={0};
- char comfirmstr[20];
- int specificId = FALSE;
- DEBUG_ERROR("handle ChangeAvailabilityRequest\n");
- char *loc;
- //int intervalInt = 0;
- int c = 0;
- /*** connectorId ****/
- c = 0;
- loc = strstr(payload, "connectorId");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc != NULL) &&(loc[strlen("connectorId")+2+c] != ',') &&(loc[strlen("connectorId")+2+c] != '}') )
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- c++;
- }
- sstr[c] = '\0';
- gunIndex = atoi(sstr);
- /***type ****/
- loc = strstr(payload, "type");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while ((loc != NULL) &&(loc[3+strlen("type")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("type")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(typeStr, sstr);
- if(gunIndex != 0)
- {
- ShmOCPP16Data->ChangeAvailability[gunIndex - 1].ConnectorId= gunIndex;
- sprintf((char *)ShmOCPP16Data->ChangeAvailability[gunIndex - 1].Type, "%s", typeStr);
- }
- else
- {
- ShmOCPP16Data->ChangeAvailability[0].ConnectorId= gunIndex;
- sprintf((char *)ShmOCPP16Data->ChangeAvailability[0].Type, "%s", typeStr);
- }
- memset(comfirmstr, 0, sizeof comfirmstr);
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
- if((gunIndex == 0) || ((gunIndex - 1) < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/))
- {
- specificId = TRUE;
- }
- if(specificId == FALSE)
- goto end;
- if(gunIndex != 0)
- {
- ShmOCPP16Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = 1;
- }
- else
- {
- for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
- ShmOCPP16Data->CsMsg.bits[i].ChangeAvailabilityReq = 1;
- }
- /*
- enum SYSTEM_STATUS
- {
- SYS_MODE_BOOTING = 0,
- SYS_MODE_IDLE = 1,
- SYS_MODE_AUTHORIZING = 2,
- SYS_MODE_MODE_REASSIGN_CHECK = 3,
- SYS_MODE_REASSIGN = 4,
- SYS_MODE_PREPARING = 5,
- SYS_MODE_PREPARE_FOR_EV = 6,
- SYS_MODE_PREPARE_FOR_EVSE = 7,
- SYS_MODE_CHARGING = 8,
- SYS_MODE_TERMINATING = 9,
- SYS_MODE_COMPLETE = 10,
- SYS_MODE_ALARM = 11,
- SYS_MODE_FAULT = 12,
- SYS_MODE_RESERVATION = 13,
- SYS_MODE_BOOKING = 14,
- SYS_MODE_MAINTAIN = 15,
- SYS_MODE_DEBUG = 16,
- SYS_MODE_CCS_PRECHARGE_STEP0 = 17,
- SYS_MODE_CCS_PRECHARGE_STEP1 = 18,
- SYS_MODE_UPDATE = 19
- };
- */
- if(strcmp((const char *)typeStr, AvailabilityTypeStr[Inoperative]) == 0)
- {
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((gunIndex == 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == (gunIndex - 1)))
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
- }
- else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
- }
- else
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
- }
- goto end;
- }
- }//END FOR CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if ((gunIndex == 0)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == (gunIndex - 1)))
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING)// S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
- }
- else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
- }
- else
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
- }
- goto end;
- }
- }//END FOR CCS_QUANTITY
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if ((gunIndex == 0)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == (gunIndex - 1)))
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
- }
- else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
- }
- else
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
- }
- goto end;
- }
- }// END FOR GB_QUANTITY
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if ((gunIndex == 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == (gunIndex - 1)))
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) // S_PRECHARGE
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
- }
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
- }
- else
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
- }
- goto end;
- }
- }//END FOR AC_QUANTITY
- }// END FOR AC ELSE
- }//END FOR AvailabilityTypeStr[Inoperative]
- if(strcmp((const char *)typeStr, AvailabilityTypeStr[Operative]) == 0)
- {
- //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (((gunIndex == 0)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == (gunIndex - 1))) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
- goto end;
- }
- }//END FOR CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (((gunIndex == 0)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == (gunIndex - 1)))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
- goto end;
- }
- }//END FOR CCS_QUANTITY
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (((gunIndex == 0)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == (gunIndex - 1)))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
- {
- ShmOCPP16Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = 1;
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
- goto end;
- }
- }// END FOR GB_QUANTITY
- //sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (((gunIndex == 0)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == (gunIndex - 1))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
- {
- sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
- goto end;
- }
- }//END FOR CHAdeMO_QUANTITY
- }//END FOR AC ELSE
- }//END FOR AvailabilityTypeStr[Operative]
- end:
- if(gunIndex != 0)
- {
- sprintf((char *)ShmOCPP16Data->ChangeAvailability[gunIndex - 1].ResponseStatus, "%s", comfirmstr );
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ChangeAvailability[0].ResponseStatus, "%s", comfirmstr );
- }
- sendChangeAvailabilityConfirmation(uuid, comfirmstr);
- //ShmOCPP16Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityConf = 1;
- return result;
- }
- int handleChangeConfigurationRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- char sstr[100]={0};
- char keystr[40]={0};
- char valuestr[100]={0};
- char *loc;
- int c = 0;
- char comfirmstr[20]={0};
- DEBUG_ERROR("handle ChangeConfigurationRequest\n");
- /***key ****/
- loc = strstr(payload, "key");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while ((loc != NULL) &&(loc[3+strlen("key")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("key")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(keystr, sstr);
- //DEBUG_INFO( "keystr=%s\n",keystr);
- /***value ****/
- loc = strstr(payload, "value");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while ((loc != NULL) &&(loc[3+strlen("value")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("value")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(valuestr, sstr);
- //DEBUG_INFO( "valuestr=%s\n",valuestr);
- if((uuid==NULL) || (payload ==NULL) )
- {
- #ifdef Debug
- DEBUG_INFO("payload is null\n");
- #endif
- sprintf(comfirmstr, "%s", ConfigurationStatusStr[ConfigurationStatus_Rejected] );
- }
- else
- {
- int status = setKeyValue(keystr, valuestr);
- switch(status)
- {
- case ConfigurationStatus_Accepted:
- sprintf(comfirmstr, "%s", ConfigurationStatusStr[ConfigurationStatus_Accepted]);
- ShmOCPP16Data->MsMsg.bits.ChangeConfigurationReq = 1;
- StoreConfigurationTable();
- break;
- case ConfigurationStatus_Rejected:
- sprintf(comfirmstr, "%s", ConfigurationStatusStr[ConfigurationStatus_Rejected] );
- break;
- case RebootRequired:
- sprintf(comfirmstr, "%s", ConfigurationStatusStr[RebootRequired]);
- StoreConfigurationTable();
- break;
- case NotSupported:
- sprintf(comfirmstr, "%s", ConfigurationStatusStr[NotSupported] );
- break;
- default:
- break;
- }
- }
- //confirmation.setStatus(ConfigurationStatus.Rejected);
- sendChangeConfigurationConfirmation(uuid, comfirmstr);
- ShmOCPP16Data->MsMsg.bits.ChangeConfigurationConf = 1;
- return result;
- }
- int handleClearCacheRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- char comfirmstr[20];
- int fd;
- char rmFileCmd[100]={0};
- struct stat stats;
- DEBUG_INFO("handle ClearCacheRequest\n");
- stat("../Storage/OCPP", &stats);
- // Check for directory existence
- if (S_ISDIR(stats.st_mode) == 1)
- {
- //DEBUG_ERROR("\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, sizeof rmFileCmd);
- if((access(AuthorizationCache_JSON,F_OK))!=-1)
- {
- DEBUG_INFO("AuthorizationCache file exist.\n");
- }
- else
- {
- DEBUG_INFO("AuthorizationCache file not exist\n");
- FILE *log = fopen(AuthorizationCache_JSON, "w+");
- if(log == NULL)
- {
- DEBUG_INFO("AuthorizationCache file is NULL\n");
- sprintf(comfirmstr, "%s", ClearCacheStatusStr[ClearCacheStatus_Rejected] );
- goto end;
- }
- else
- {
- fclose(log);
- }
- }
- fd = open(AuthorizationCache_JSON,O_RDWR);
- if(fd < 0)
- {
- DEBUG_INFO("open AuthorizationCache file failed\n");
- sprintf(comfirmstr, "%s", ClearCacheStatusStr[ClearCacheStatus_Rejected] );
- }
- else
- {
- DEBUG_INFO("open AuthorizationCache file successful\n");
- //* 清空? 件 */
- ftruncate(fd,0);
- //* ? 新设置? 件? 移??*/
- lseek(fd,0,SEEK_SET);
- close(fd);
- sprintf(comfirmstr, "%s", ClearCacheStatusStr[ClearCacheStatus_Accepted] );
- //ShmOCPP16Data->MsMsg.bits.ClearCacheReq = 1; //OCPP handle byself
- }
- end:
- sendClearCacheConfirmation(uuid, comfirmstr);
- //ShmOCPP16Data->MsMsg.bits.ClearCacheConf = 1; //OCPP handle byself
- return result;
- }
- int handleClearChargingProfileRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int resultRename;
- int connectorIdInt, chargingProfileIdInt, stackLevelInt;
- char chargingProfilePurposeStr[26]={0};
- int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
- char tempchargingProfilePurposeStr[26]={0};
- char sstr[160]={0};//sstr[200]={ 0 };
- char str[100]={0};
- int c = 0;
- //int i = 0;
- //char * pch;
- char *loc;
- char fname[200];
- char comfirmstr[20]={0};
- char word[1000]={0};
- int clearflag = FALSE;
- int chargingProfileIdIsNULL = FALSE;
- int connectorIsNULL = FALSE;
- int chargingProfilePurposeIsNULL = FALSE;
- int stackLevelIsNULL = FALSE;
- int GotoEnd = FALSE;
- FILE *fptr1, *fptr2;
- char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json";
- int n_chargingProfile=0;
- char sLineWord[1060]={0};
- DEBUG_INFO("handle ClearChargingProfileRequest\n");
- connectorIdInt= chargingProfileIdInt= stackLevelInt =0;
- //***id ****/
- c = 0;
- loc = strstr(payload, "id");
- memset(sstr ,0, sizeof(sstr) );
- if(loc == NULL)
- {
- chargingProfileIdIsNULL = TRUE;
- }
- else
- {
- while ((loc != NULL) &&((loc[strlen("id")+2+c] != ',')&& (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';
- chargingProfileIdInt = atoi(sstr);
- }
- //***connectorId ****/
- c=0;
- loc = strstr(payload, "connectorId");
- memset(sstr ,0, sizeof(sstr) );
- if(loc == NULL)
- {
- connectorIsNULL = TRUE;
- }
- else
- {
- while ((loc != NULL) &&((loc[strlen("connectorId")+2+c] != ',')&&(loc[strlen("connectorId")+2+c] != '}')))
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- connectorIdInt = atoi(sstr);
- }
- //***chargingProfilePurpose ****/
- loc = strstr(payload, "chargingProfilePurpose");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- if(loc == NULL)
- {
- chargingProfilePurposeIsNULL = TRUE;
- }
- else
- {
- while ((loc != NULL) &&(loc[3+strlen("chargingProfilePurpose")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(chargingProfilePurposeStr, sstr);
- }
- //***stackLevel ****/
- c=0;
- loc = strstr(payload, "stackLevel");
- memset(sstr ,0, sizeof(sstr) );
- if(loc == NULL)
- {
- stackLevelIsNULL = TRUE;
- }
- else
- {
- while ((loc != NULL) &&((loc[strlen("stackLevel")+2+c] != '}') && (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';
- stackLevelInt = atoi(sstr);
- }
- if(connectorIsNULL == FALSE)
- {
- switch(connectorIdInt)
- {
- case 0:
- if((chargingProfilePurposeIsNULL == TRUE)||((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0)))
- {
- strcpy(fname, ChargePointMaxProfile_JSON);
- }
- else
- {
- strcpy(fname, TxDefaultProfile_0_JSON);
- }
- break;
- case 1:
- if((chargingProfilePurposeIsNULL == TRUE)||((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0)))
- {
- strcpy(fname, TxDefaultProfile_1_JSON);
- }
- // else
- // {
- // strcpy(fname, TxProfile_1_JSON);
- // }
- break;
- case 2:
- if((chargingProfilePurposeIsNULL == TRUE)||((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0)))
- {
- strcpy(fname, TxDefaultProfile_2_JSON);
- }
- // else
- // {
- // strcpy(fname, TxProfile_2_JSON);
- // }
- break;
- default:
- strcpy(fname, ChargePointMaxProfile_JSON );
- break;
- }
- }
- else
- {
- strcpy(fname, ChargePointMaxProfile_JSON );
- }
- fptr1 = fopen(fname, "r");
- if (!fptr1)
- {
- //file not exist
- DEBUG_INFO("Unable to open the input file!!\n");
- fptr1 = fopen(fname, "w+");
- }
- fclose(fptr1);
- if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
- {
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Unknown] );
- goto end;
- }
- if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
- {
- //clear file in C
- sprintf(str,"rm -f %s",fname);
- system(str);
- // clear temp file
- sprintf(str,"rm -f %s",temp);
- system(str);
- #if 0
- fclose(fopen(ChargePointMaxProfile_JSON, "w"));
- fclose(fopen(TxDefaultProfile_0_JSON, "w"));
- fclose(fopen(TxDefaultProfile_1_JSON, "w"));
- fclose(fopen(TxDefaultProfile_2_JSON, "w"));
- fclose(fopen(TxProfile_1_JSON, "w"));
- fclose(fopen(TxProfile_2_JSON, "w"));
- #endif
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Accepted] );
- goto end;
- }
- else
- {
- fptr1 = fopen(fname, "r");
- fptr2 = fopen(temp, "w+");
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- //DEBUG_INFO("word=%s\n",word);
- if(strcmp(word, "chargingProfileId") == 0)
- {
- n_chargingProfile = n_chargingProfile + 1;
- DEBUG_INFO("chargingProfileId Found\n");
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- //int i= 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
- {
- //*************************tempconnectorIdInt*********************************/
- loc = strstr(sLineWord, "connectorId");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- c++;
- }
- sstr[c] = '\0';
- tempconnectorIdInt = atoi(sstr);
- //chargingProfileId
- c = 0;
- loc = strstr(sLineWord, "chargingProfileId");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("chargingProfileId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("chargingProfileId")+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, sizeof(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, sizeof(sstr) );
- while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingProfilePurposeStr, sstr);
- if(chargingProfileIdIsNULL == FALSE)
- {
- if(tempchargingProfileIdInt == chargingProfileIdInt)
- {
- //DEBUG_INFO("\n OCPP clear 0-1 !!!\n");
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Accepted] );
- clearflag = TRUE;
- continue;
- }
- else
- {
- //DEBUG_INFO("\n OCPP clear 0-2 !!!\n");
- //json_object_array_add(newHeatMap, jsonitem);
- fprintf(fptr2, sLineWord);//writing data into file
- }
- }
- else
- {
- if((connectorIsNULL == FALSE) && (connectorIdInt != 0) && ( connectorIdInt == tempconnectorIdInt))
- {
- if(stackLevelIsNULL == TRUE)//((stackLevelIsNULL == TRUE)||((stackLevelIsNULL == FALSE)&& (tempstackLevelInt == stackLevelInt)))
- {
- fclose(fptr1);
- fclose(fptr2);
- sprintf(str,"rm -f %s",fname);
- system(str);
- // clear temp file
- sprintf(str,"rm -f %s",temp);
- system(str);
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Accepted] );
- clearflag = TRUE;
- GotoEnd = TRUE;
- break;
- }
- else if((stackLevelIsNULL == FALSE)&& (tempstackLevelInt == stackLevelInt))
- {
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Accepted] );
- clearflag = TRUE;
- continue;
- }
- }
- else if((connectorIsNULL == TRUE) && ((tempstackLevelInt == stackLevelInt) || (strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0)))
- {
- if((stackLevelIsNULL == FALSE)|| (chargingProfilePurposeIsNULL == FALSE))
- {
- if( ((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt)) ||
- ((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0)) )
- {
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Accepted] );
- clearflag = TRUE;
- continue;
- }
- }
- }
- else
- {
- //json_object_array_add(newHeatMap, jsonitem);
- fprintf(fptr2, sLineWord);//writing data into file
- }
- }
- memset(sLineWord, 0, sizeof sLineWord);
- }
- if((clearflag == FALSE) && (GotoEnd == TRUE))
- {
- sprintf(comfirmstr, "%s", ClearChargingProfileStatusStr[ClearChargingProfileStatus_Unknown] );
- sprintf(str,"rm -f %s",temp);
- system(str);
- goto end;
- }
- else
- {
- goto end;
- }
- fclose(fptr1);
- fclose(fptr2);
- sprintf(str,"rm -f %s",fname);
- system(str);
- resultRename = rename(temp, fname);
- if(resultRename == 0)
- {
- DEBUG_INFO("File ChargingProfile renamed successfully");
- }
- else
- {
- DEBUG_INFO("Error: unable to rename the ChargingProfile file");
- }
- }
- end:
- sendClearChargingProfileConfirmation(uuid, comfirmstr);
- return result;
- }
- int handleDataTransferRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- //Payload={"vendorId":"Phihong","messageId":"MSGID","data":"Data1"}
- char tempvendorId[255]={0};
- char tempmessageId[50]={0};
- char tempdata[50]={0};
- char sstr[160]={0};//sstr[200]={ 0 };
- char message[80]={0};
- int c = 0;
- char *loc;
- DEBUG_INFO("handle DataTransferRequest\n");
- if((uuid != NULL) && (payload != NULL))
- {
- //===============================
- // vendorId
- //===============================
- c = 0;
- loc = strstr(payload, "vendorId");
- while (loc[strlen("vendorId")+3+c] != '\"')
- {
- sstr[c] = loc[strlen("vendorId")+3+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvendorId,sstr);
- //===============================
- // messageId
- //===============================
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- loc = strstr(payload, "messageId");
- while (loc[strlen("messageId")+3+c] != '\"')
- {
- sstr[c] = loc[strlen("messageId")+3+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempmessageId,sstr);
- //===============================
- // data
- //===============================
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- loc = strstr(payload, "data");
- printf("loc=%s\n",loc);
- while (loc[strlen("data")+3+c] != '\"')
- {
- sstr[c] = loc[strlen("data")+3+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempdata,sstr);
- sprintf(message,"[%d,\"%s\",{\"status\":\"%s\",\"data\":\"vendorId-%s messageId-%s data-%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "Rejected", tempvendorId, tempmessageId, tempdata );
- }
- else
- {
- char guid[37]={0};
- random_uuid(guid);
- //[2,"1577349264923","DataTransfer",{"vendorId":"Phihong","messageId":"MSGID","data":"Data1"}]
- sprintf(message,"[%d,\"%s\",\"%s\",{\"vendorId\":\"Phihong\",\"messageId\":\"MSGID\",\"data\":\"Data1\"}]",MESSAGE_TYPE_CALL, guid, "DataTransfer");
- }
- LWS_Send(message);
- return result;
- }
- int handleGetCompositeScheduleRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int connectorIdInt, durationInt;
- char chargingRateUnitStr[4]={0};
- //int tempconnectorIdInt,
- int tempdurationInt;
- float tempminChargingRateFloat = 0.0;
- char tempvalidFromStr[30]={0},tempchargingRateUnitStr[4]={0}, tempstartScheduleStr[30]={0};
- int tempStartPeriodInt=0;
- float tempLimitInt=0.0;//0.1;
- int tempNumberPhasesInt=0;
- char fname[200];
- char comfirmstr[20];
- //float totallimit =0.0;
- float MinChargingRate =0.0;
- //double diff_t;
- //struct tm tp;
- FILE *fptr1;
- int c = 0;
- //int i = 0;
- char * pch;
- char *loc;
- char sstr[200]={ 0 };
- int n_chargingProfile = 0;
- int n_SchedulePeriods = 0;
- char SchedulePeriodList[10][200]={0};
- char sLineWord[800]={0};
- //int n_periods = 0;
- char word[1000]={0};
- int confirmPeriods = 0;
- struct StructProfile ChargePointMaxProfile;
- struct StructProfile TxDefaultProfile;
- struct StructProfile TxProfile;
- struct StructProfile TxDefaultProfiletemp[2]={0};
- int TxDefaultProfileFileIsNull=FALSE;
- int ChargePointMaxProfileIsNull=FALSE;
- int TxProfileIsNull=FALSE;
- int CompositeSceduleIndex = 0;
- char ChargePointMaxProfileScheduleStr[30]={0};
- char TxDefaultProfileScheduleStr[30]={0};
- char TxProfileScheduleStr[30]={0};
- memset(&ChargePointMaxProfile,0,sizeof(struct StructProfile));
- memset(&TxDefaultProfile,0,sizeof(struct StructProfile));
- memset(&TxProfile,0,sizeof(struct StructProfile));
- DEBUG_INFO("handleGetCompositeScheduleRequest\n");
- c=0;
- loc = strstr(payload, "connectorId");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("connectorId")+2+c] != '}') && (loc[strlen("connectorId")+2+c] != ','))
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- connectorIdInt = atoi(sstr);
- c=0;
- loc = strstr(payload, "duration");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("duration")+2+c] != '}') && (loc[strlen("duration")+2+c] != ','))
- {
- sstr[c] = loc[strlen("duration")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- durationInt = atoi(sstr);
- c = 0;
- loc = strstr(payload, "chargingRateUnit");
- memset(sstr ,0, sizeof(sstr) );
- if(loc == NULL)
- {
- }
- else
- {
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(chargingRateUnitStr, sstr);
- }
- CompositeSceduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) :0;
- memset(ShmOCPP16Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/ );
- if(connectorIdInt==0) // connectorId is 0
- {
- //******************************ChargePointMaxProfile*****************************************************/
- strcpy(fname, ChargePointMaxProfile_JSON );
- char word[30]={0};
- char sLineWord[1060]={0};
- int n_chargingProfile=0;
- ChargePointMaxProfileIsNull=TRUE;
- if((access(fname,F_OK))!=-1)
- {
- fptr1 = fopen(fname, "r");
- int c;
- c = fgetc(fptr1);
- //DEBUG_INFO("c:%d\n",c);
- rewind(fptr1);
- if(c == EOF)
- {
- DEBUG_INFO("\n End of file ChargingProfile reached.");
- ChargePointMaxProfileIsNull=TRUE;
- fclose(fptr1);
- }
- else
- {
- ChargePointMaxProfileIsNull=FALSE;
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- if(strcmp(word, "chargingProfileId") == 0)
- {
- n_chargingProfile = n_chargingProfile + 1;
- printf("Found\n");
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- int i= 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL ) {
- #if 0
- /***********connectorId****************/
- c = 0;
- loc = strstr(sLineWord, "connectorId");
- // printf("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempconnectorIdInt = atoi(sstr);
- #endif
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "validFrom");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- DEBUG_INFO("validFrom=%s\n",sstr);
- strcpy(tempvalidFromStr,sstr);
- }
- else
- {
- strcpy(tempvalidFromStr,"");
- }
- //**********startSchedule**********/
- c = 0;
- loc = strstr(sLineWord, "startSchedule");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("startSchedule")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startSchedule")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempstartScheduleStr, sstr);
- strcpy(ChargePointMaxProfileScheduleStr, sstr);
- //**********chargingRateUnit**********/
- c = 0;
- loc = strstr(sLineWord, "chargingRateUnit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingRateUnitStr, sstr);
- //**********minChargingRate*******/
- c = 0;
- loc = strstr(sLineWord, "minChargingRate");
- //printf("loc=%s\n",loc);
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[2+strlen("minChargingRate")+c] != ',')&&(loc[2+strlen("minChargingRate")+c] != '}'))
- {
- sstr[c] = loc[2+strlen("minChargingRate")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempminChargingRateFloat = atof(sstr);
- }
- else
- {
- tempminChargingRateFloat = 0.0;
- }
- //
- #if 0
- strptime(tempstartScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- time_t utc = mktime(&tp);
- // current time
- time_t t = time(NULL);
- #endif
- //diff_t = difftime(t, utc);
- //parsing strings to words
- i = 0;
- loc = strstr(sLineWord, "chargingSchedulePeriod");
- loc = loc+3+strlen("chargingSchedulePeriod");
- pch = strtok(loc ,"{");
- while (pch != NULL)
- {
- strcpy(SchedulePeriodList[i], pch);
- //printf ("SchedulePeriodList[%d]:%s\n",i,SchedulePeriodList[i]);
- //printf ("%s\n",pch);
- pch = strtok (NULL, "{");
- i = i + 1;
- }
- n_SchedulePeriods = i;
- for(int i=0;i<n_SchedulePeriods;i++)
- {
- //*************startPeriod****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "startPeriod");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("startPeriod")+2+c] != ',')
- {
- sstr[c] = loc[strlen("startPeriod")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempStartPeriodInt = atoi(sstr);
- //*************limit****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "limit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("limit")+2+c] != ',')
- {
- sstr[c] = loc[strlen("limit")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempLimitInt = atof(sstr);
- //*************numberPhases****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "numberPhases");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
- {
- sstr[c] = loc[strlen("numberPhases")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempNumberPhasesInt = atoi(sstr);
- ChargePointMaxProfile.Duration = durationInt;
- ChargePointMaxProfile.TotalPeriod = n_SchedulePeriods;
- ChargePointMaxProfile.Period[i].Limit = tempLimitInt;
- ChargePointMaxProfile.Period[i].NumberPhases = tempNumberPhasesInt;
- ChargePointMaxProfile.Period[i].StartPeriod = tempStartPeriodInt;
- }
- if(MinChargingRate < tempminChargingRateFloat)
- MinChargingRate = tempminChargingRateFloat;
- }
- }// End of file ChargingProfile
- } //THE END OF ACCESS ChargePointMaxProfile
- //******************************TxDefaultProfile***********************************************/
- strcpy(fname, TxDefaultProfile_0_JSON);
- memset(word, 0, 30);
- memset(sLineWord, 0, 1060);
- //char word[30]={0};
- //char sLineWord[1060]={0};
- n_chargingProfile=0;
- TxDefaultProfileFileIsNull=TRUE;
- if((access(fname,F_OK))!=-1)
- {
- fptr1 = fopen(fname, "r");
- c = 0;
- c = fgetc(fptr1);
- //DEBUG_INFO("c:%d\n",c);
- rewind(fptr1);
- if(c == EOF)
- {
- DEBUG_INFO("\n End of file ChargingProfile reached.");
- TxDefaultProfileFileIsNull=TRUE;
- fclose(fptr1);
- }
- else
- {
- TxDefaultProfileFileIsNull=FALSE;
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- if(strcmp(word, "chargingProfileId") == 0)
- {
- n_chargingProfile = n_chargingProfile + 1;
- printf("Found\n");
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- int i= 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL ) {
- #if 0
- /***********connectorId****************/
- c = 0;
- loc = strstr(sLineWord, "connectorId");
- // printf("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- DEBUG_INFO("connectorId=%d\n",atoi(sstr));
- tempconnectorIdInt = atoi(sstr);
- #endif
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "validFrom");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- DEBUG_INFO("validFrom=%s\n",sstr);
- strcpy(tempvalidFromStr,sstr);
- }
- else
- {
- strcpy(tempvalidFromStr,"");
- }
- //**********startSchedule**********/
- c = 0;
- loc = strstr(sLineWord, "startSchedule");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("startSchedule")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startSchedule")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempstartScheduleStr, sstr);
- strcpy(TxDefaultProfileScheduleStr, sstr);
- DEBUG_INFO(" debug 3-1\n");
- //**********chargingRateUnit**********/
- c = 0;
- loc = strstr(sLineWord, "chargingRateUnit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingRateUnitStr, sstr);
- //**********minChargingRate*******/
- c = 0;
- loc = strstr(sLineWord, "minChargingRate");
- //printf("loc=%s\n",loc);
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[2+strlen("minChargingRate")+c] != ',')&&(loc[2+strlen("minChargingRate")+c] != '}'))
- {
- sstr[c] = loc[2+strlen("minChargingRate")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempminChargingRateFloat = atof(sstr);
- }
- else
- {
- tempminChargingRateFloat = 0.0;
- }
- #if 0
- //
- strptime(tempstartScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- time_t utc = mktime(&tp);
- // current time
- time_t t = time(NULL);
- //diff_t = difftime(t, utc);
- #endif
- //parsing strings to words
- i = 0;
- loc = strstr(sLineWord, "chargingSchedulePeriod");
- loc = loc+3+strlen("chargingSchedulePeriod");
- pch = strtok(loc ,"{");
- while (pch != NULL)
- {
- strcpy(SchedulePeriodList[i], pch);
- //printf ("SchedulePeriodList[%d]:%s\n",i,SchedulePeriodList[i]);
- //printf ("%s\n",pch);
- pch = strtok (NULL, "{");
- i = i + 1;
- }
- n_SchedulePeriods = i;
- for(int i=0;i<n_SchedulePeriods;i++)
- {
- //*************startPeriod****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "startPeriod");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("startPeriod")+2+c] != ',')
- {
- sstr[c] = loc[strlen("startPeriod")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempStartPeriodInt = atoi(sstr);
- //*************limit****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "limit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("limit")+2+c] != ',')
- {
- sstr[c] = loc[strlen("limit")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempLimitInt = atof(sstr);
- //*************numberPhases****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "numberPhases");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("numberPhases")+2+c] != ',')&&(loc[strlen("numberPhases")+2+c] != '}'))
- {
- sstr[c] = loc[strlen("numberPhases")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempNumberPhasesInt = atoi(sstr);
- TxDefaultProfile.Duration = durationInt;
- TxDefaultProfile.TotalPeriod = n_SchedulePeriods;
- TxDefaultProfile.Period[i].Limit = tempLimitInt;
- TxDefaultProfile.Period[i].NumberPhases = tempNumberPhasesInt;
- TxDefaultProfile.Period[i].StartPeriod = tempStartPeriodInt;
- }
- if(MinChargingRate < tempminChargingRateFloat)
- MinChargingRate = tempminChargingRateFloat;
- }
- }
- }// the end of ACCESS TxDefaultProfile
- // Composite Schedule
- if((ChargePointMaxProfileIsNull==FALSE)&&(TxDefaultProfileFileIsNull==FALSE))
- {
- strcpy(CurrentChargingProfileScheduleStr, TxDefaultProfileScheduleStr);
- for(int index=0; index < TxDefaultProfile.TotalPeriod ; index++)
- {
- if(ChargePointMaxProfile.Period[0].Limit > TxDefaultProfile.Period[index].Limit)
- {
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].Limit = TxDefaultProfile.Period[index].Limit;
- }
- else
- {
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].Limit = ChargePointMaxProfile.Period[0].Limit;
- }
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].NumberPhases = TxDefaultProfile.Period[index].NumberPhases; //for discussion
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[index].StartPeriod = TxDefaultProfile.Period[index].StartPeriod;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.Duration = TxDefaultProfile.Duration;
- }
- }
- //* Define temporary variables */
- struct tm *gtime;
- time_t now;
- char buf[28];
- /* Read the current system time */
- time(&now);
- /* Convert the system time to GMT (now UTC) */
- gtime = gmtime(&now);
- strftime(buf, 28, "%Y-%m-%dT%H:%M:%SZ", gtime);
- // make .conf
- strcpy((char *)ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.StartSchedule,buf);
- //MaxChargingProfilesInstalled is 10
- // ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.ChargingSchedulePeriod = (struct StructChargingSchedulePeriod *) malloc(sizeof(struct StructChargingSchedulePeriod)* 9);
- memset(ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod, 0, sizeof(struct StructChargingSchedulePeriod)* 9);
- //nPeriod = 1;
- if(chargingRateUnitStr[0] != 0)
- {
- strcpy((char *)ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingRateUnit, chargingRateUnitStr );
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingRateUnit, "" );
- }
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.MinChargingRate = MinChargingRate;
- sprintf(comfirmstr, "%s", GetCompositeScheduleStatusStr[GetCompositeScheduleStatus_Accepted] );
- confirmPeriods = 1;
- }
- else if ((connectorIdInt > 0)&&((connectorIdInt -1) < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/) )
- {
- //*****************************ChargePointMaxProfile******************************************/
- strcpy(fname, ChargePointMaxProfile_JSON);
- ChargePointMaxProfileIsNull=TRUE;
- if((access(ChargePointMaxProfile_JSON,F_OK))!=-1)
- {
- fptr1 = fopen(fname, "r");
- int c;
- c = fgetc(fptr1);
- //DEBUG_INFO("c:%d\n",c);
- rewind(fptr1);
- if(c == EOF)
- {
- DEBUG_INFO("\n End of file reached.");
- ChargePointMaxProfileIsNull=TRUE;
- fclose(fptr1);
- }
- else
- {
- ChargePointMaxProfileIsNull=FALSE;
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- if(strcmp(word, "chargingProfileId") == 0)
- {
- n_chargingProfile = n_chargingProfile + 1;
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- int i = 0;
- int j = 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL ) {
- #if 0
- /***********connectorId****************/
- c = 0;
- loc = strstr(sLineWord, "connectorId");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempconnectorIdInt = atoi(sstr);
- #endif
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "validFrom");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidFromStr,sstr);
- }
- else
- {
- strcpy(tempvalidFromStr,"");
- }
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "duration");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[2+strlen("duration")+c] != ',')
- {
- sstr[c] = loc[2+strlen("duration")+c];
- c++;
- }
- sstr[c] = '\0';
- tempdurationInt = atoi(sstr);
- }
- else
- {
- tempdurationInt = 0;
- }
- //**********startSchedule**********/
- c = 0;
- loc = strstr(sLineWord, "startSchedule");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("startSchedule")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startSchedule")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempstartScheduleStr, sstr);
- strcpy(ChargePointMaxProfileScheduleStr, sstr);
- //**********chargingRateUnit**********/
- c = 0;
- loc = strstr(sLineWord, "chargingRateUnit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingRateUnitStr, sstr);
- //**********minChargingRate*******/
- c = 0;
- loc = strstr(sLineWord, "minChargingRate");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[2+strlen("minChargingRate")+c] != ',')&&(loc[2+strlen("minChargingRate")+c] != '}'))
- {
- sstr[c] = loc[2+strlen("minChargingRate")+c];
- c++;
- }
- sstr[c] = '\0';
- tempminChargingRateFloat = atof(sstr);
- }
- else
- {
- tempminChargingRateFloat = 0.0;
- }
- #if 0
- //
- strptime(tempstartScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- time_t utc = mktime(&tp);
- time_t t = time(NULL);
- //diff_t = difftime(t, utc);
- #endif
- //DEBUG_INFO("diff_t=%f\n",diff_t);
- //DEBUG_INFO(" debug 5 -1\n");
- //parsing strings to words
- i = 0;
- loc = strstr(sLineWord, "chargingSchedulePeriod");
- loc = loc+3+strlen("chargingSchedulePeriod");
- pch = strtok(loc ,"{");
- while (pch != NULL)
- {
- strcpy(SchedulePeriodList[i], pch);
- pch = strtok (NULL, "{");
- i = i + 1;
- }
- n_SchedulePeriods = i;
- for(int i=0;i<n_SchedulePeriods;i++)
- {
- //*************startPeriod****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "startPeriod");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("startPeriod")+2+c] != ',')
- {
- sstr[c] = loc[strlen("startPeriod")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempStartPeriodInt = atoi(sstr);
- //*************limit****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "limit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("limit")+2+c] != ',')
- {
- sstr[c] = loc[strlen("limit")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempLimitInt = atof(sstr);
- //*************numberPhases****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "numberPhases");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("numberPhases")+2+c] != '}')
- {
- sstr[c] = loc[strlen("numberPhases")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempNumberPhasesInt = atoi(sstr);
- if(j == 0)
- {
- ChargePointMaxProfile.Duration = tempdurationInt;
- ChargePointMaxProfile.TotalPeriod = n_SchedulePeriods;
- ChargePointMaxProfile.Period[i].Limit = tempLimitInt;
- ChargePointMaxProfile.Period[i].NumberPhases = tempNumberPhasesInt;
- ChargePointMaxProfile.Period[i].StartPeriod = tempStartPeriodInt;
- }
- }
- if(MinChargingRate < tempminChargingRateFloat)
- {
- MinChargingRate = tempminChargingRateFloat;
- }
- if(confirmPeriods < n_SchedulePeriods)
- {
- confirmPeriods = n_SchedulePeriods;
- }
- j = j + 1;
- }
- fclose(fptr1);
- }
- }// the end of access file ChargePointMaxProfile
- //****************************TxDefaultProfile************************************************/
- switch(connectorIdInt)
- {
- case 0:
- break;
- case 1:
- strcpy(fname, TxDefaultProfile_1_JSON );
- break;
- case 2:
- strcpy(fname, TxDefaultProfile_2_JSON );
- break;
- default:
- strcpy(fname, TxDefaultProfile_1_JSON );
- break;
- }
- TxDefaultProfileFileIsNull=TRUE;
- if((access(fname,F_OK))!=-1)
- {
- fptr1 = fopen(fname, "r");
- c = 0;
- c = fgetc(fptr1);
- //DEBUG_INFO("c:%d\n",c);
- rewind(fptr1);
- if(c == EOF)
- {
- DEBUG_INFO("\n End of file reached.");
- TxDefaultProfileFileIsNull=TRUE;
- fclose(fptr1);
- }
- else
- {
- TxDefaultProfileFileIsNull=FALSE;
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- if(strcmp(word, "chargingProfileId") == 0)
- {
- n_chargingProfile = n_chargingProfile + 1;
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- int i = 0;
- int j = 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL ) {
- //DEBUG_INFO(" 1-1\n");
- #if 0
- /***********connectorId****************/
- c = 0;
- loc = strstr(sLineWord, "connectorId");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempconnectorIdInt = atoi(sstr);
- #endif
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "validFrom");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidFromStr,sstr);
- }
- else
- {
- strcpy(tempvalidFromStr,"");
- }
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "duration");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[2+strlen("duration")+c] != ',')
- {
- sstr[c] = loc[2+strlen("duration")+c];
- c++;
- }
- sstr[c] = '\0';
- tempdurationInt = atoi(sstr);
- }
- else
- {
- tempdurationInt = 0;
- }
- //**********startSchedule**********/
- c = 0;
- loc = strstr(sLineWord, "startSchedule");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("startSchedule")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startSchedule")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempstartScheduleStr, sstr);
- strcpy(TxDefaultProfileScheduleStr, sstr);
- //**********chargingRateUnit**********/
- c = 0;
- loc = strstr(sLineWord, "chargingRateUnit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingRateUnitStr, sstr);
- //**********minChargingRate*******/
- c = 0;
- loc = strstr(sLineWord, "minChargingRate");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[2+strlen("minChargingRate")+c] != ',')&&(loc[2+strlen("minChargingRate")+c] != '}'))
- {
- sstr[c] = loc[2+strlen("minChargingRate")+c];
- c++;
- }
- sstr[c] = '\0';
- tempminChargingRateFloat = atof(sstr);
- }
- else
- {
- tempminChargingRateFloat = 0.0;
- }
- #if 0
- //
- strptime(tempstartScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- time_t utc = mktime(&tp);
- time_t t = time(NULL);
- //diff_t = difftime(t, utc);
- #endif
- //DEBUG_INFO("diff_t=%f\n",diff_t);
- //parsing strings to words
- i = 0;
- loc = strstr(sLineWord, "chargingSchedulePeriod");
- loc = loc+3+strlen("chargingSchedulePeriod");
- pch = strtok(loc ,"{");
- while (pch != NULL)
- {
- strcpy(SchedulePeriodList[i], pch);
- pch = strtok (NULL, "{");
- i = i + 1;
- }
- n_SchedulePeriods = i;
- for(int i=0;i<n_SchedulePeriods;i++)
- {
- //*************startPeriod****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "startPeriod");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("startPeriod")+2+c] != ',')
- {
- sstr[c] = loc[strlen("startPeriod")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempStartPeriodInt = atoi(sstr);
- //*************limit****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "limit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("limit")+2+c] != ',')
- {
- sstr[c] = loc[strlen("limit")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempLimitInt = atof(sstr);
- //*************numberPhases****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "numberPhases");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("numberPhases")+2+c] != '}')
- {
- sstr[c] = loc[strlen("numberPhases")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempNumberPhasesInt = atoi(sstr);
- if(j == 0)
- {
- TxDefaultProfile.Duration = tempdurationInt;
- TxDefaultProfile.TotalPeriod = n_SchedulePeriods;
- TxDefaultProfile.Period[i].Limit = tempLimitInt;
- TxDefaultProfile.Period[i].NumberPhases = tempNumberPhasesInt;
- TxDefaultProfile.Period[i].StartPeriod = tempStartPeriodInt;
- }
- else
- {
- //other stack level charging Profile
- TxDefaultProfiletemp[j-1].Period[i].Limit = tempLimitInt;
- TxDefaultProfiletemp[j-1].Period[i].NumberPhases = tempNumberPhasesInt;
- TxDefaultProfiletemp[j-1].Period[i].StartPeriod = tempStartPeriodInt;
- TxDefaultProfiletemp[j-1].Duration = tempdurationInt;
- TxDefaultProfiletemp[j-1].TotalPeriod = n_SchedulePeriods;
- }
- }
- if(MinChargingRate < tempminChargingRateFloat)
- MinChargingRate = tempminChargingRateFloat;
- if(confirmPeriods < n_SchedulePeriods)
- confirmPeriods = n_SchedulePeriods;
- j = j + 1;
- //DEBUG_INFO(" 1-2\n");
- }
- fclose(fptr1);
- //Stacking Charging Profiles
- for(int l=0; l <(j-1) ;l++)
- {
- for(int k=0; k < TxDefaultProfiletemp[l].TotalPeriod; k++)
- {
- if(TxDefaultProfiletemp[l].Period[k].StartPeriod > TxDefaultProfile.Duration)
- {
- if((k >0) && ((TxDefaultProfiletemp[l].Period[k-1].StartPeriod < TxDefaultProfile.Duration) &&(TxDefaultProfiletemp[l].Period[k-1].StartPeriod >= TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod-1].StartPeriod )))
- {
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].Limit = TxDefaultProfiletemp[l].Period[k-1].Limit;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].NumberPhases = TxDefaultProfiletemp[l].Period[k-1].NumberPhases;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].StartPeriod = TxDefaultProfile.Duration;
- TxDefaultProfile.TotalPeriod = TxDefaultProfile.TotalPeriod + 1;
- TxDefaultProfile.Duration = TxDefaultProfiletemp[l].Duration;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].Limit = TxDefaultProfiletemp[l].Period[k].Limit;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].NumberPhases = TxDefaultProfiletemp[l].Period[k].NumberPhases;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].StartPeriod = TxDefaultProfiletemp[l].Period[k].StartPeriod;
- TxDefaultProfile.TotalPeriod = TxDefaultProfile.TotalPeriod + 1;
- TxDefaultProfile.Duration = TxDefaultProfiletemp[l].Duration;
- }
- else
- {
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].Limit = TxDefaultProfiletemp[l].Period[k].Limit;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].NumberPhases = TxDefaultProfiletemp[l].Period[k].NumberPhases;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].StartPeriod = TxDefaultProfiletemp[l].Period[k].StartPeriod;
- TxDefaultProfile.TotalPeriod = TxDefaultProfile.TotalPeriod + 1;
- TxDefaultProfile.Duration = TxDefaultProfiletemp[l].Duration;
- }
- }
- }
- }
- //end of Stacking Charging Profiles
- }
- }// the end of ACCESS TxDefaultProfile
- //****************************TxProfile************************************************/
- switch(connectorIdInt)
- {
- case 0:
- break;
- case 1:
- strcpy(fname, TxProfile_1_JSON );
- break;
- case 2:
- strcpy(fname, TxProfile_2_JSON );
- break;
- default:
- strcpy(fname, TxProfile_1_JSON );
- break;
- }
- TxProfileIsNull=TRUE;
- if((access(fname,F_OK))!=-1)
- {
- fptr1 = fopen(fname, "r");
- c = 0;
- c = fgetc(fptr1);
- //DEBUG_INFO("c:%d\n",c);
- rewind(fptr1);
- if(c == EOF)
- {
- DEBUG_INFO("\n End of file reached.");
- TxProfileIsNull=TRUE;
- fclose(fptr1);
- }
- else
- {
- TxProfileIsNull=FALSE;
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- if(strcmp(word, "chargingProfileId") == 0)
- {
- n_chargingProfile = n_chargingProfile + 1;
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- int i= 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL ) {
- #if 0
- /***********connectorId****************/
- c = 0;
- loc = strstr(sLineWord, "connectorId");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempconnectorIdInt = atoi(sstr);
- #endif
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "validFrom");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidFromStr,sstr);
- }
- else
- {
- strcpy(tempvalidFromStr,"");
- }
- //**********startSchedule**********/
- c = 0;
- loc = strstr(sLineWord, "startSchedule");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("startSchedule")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startSchedule")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempstartScheduleStr, sstr);
- strcpy(TxProfileScheduleStr, sstr);
- //**********chargingRateUnit**********/
- c = 0;
- loc = strstr(sLineWord, "chargingRateUnit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingRateUnitStr, sstr);
- //**********minChargingRate*******/
- c = 0;
- loc = strstr(sLineWord, "minChargingRate");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[2+strlen("minChargingRate")+c] != ',')&&(loc[2+strlen("minChargingRate")+c] != '}'))
- {
- sstr[c] = loc[2+strlen("minChargingRate")+c];
- c++;
- }
- sstr[c] = '\0';
- tempminChargingRateFloat = atof(sstr);
- }
- else
- {
- tempminChargingRateFloat = 0.0;
- }
- #if 0
- //
- strptime(tempstartScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- time_t utc = mktime(&tp);
- time_t t = time(NULL);
- //diff_t = difftime(t, utc);
- #endif
- //DEBUG_INFO("diff_t=%f\n",diff_t);
- //parsing strings to words
- i = 0;
- loc = strstr(sLineWord, "chargingSchedulePeriod");
- loc = loc+3+strlen("chargingSchedulePeriod");
- pch = strtok(loc ,"{");
- while (pch != NULL)
- {
- strcpy(SchedulePeriodList[i], pch);
- pch = strtok (NULL, "{");
- i = i + 1;
- }
- n_SchedulePeriods = i;
- for(int i=0;i<n_SchedulePeriods;i++)
- {
- //*************startPeriod****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "startPeriod");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("startPeriod")+2+c] != ',')
- {
- sstr[c] = loc[strlen("startPeriod")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempStartPeriodInt = atoi(sstr);
- //*************limit****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "limit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("limit")+2+c] != ',')
- {
- sstr[c] = loc[strlen("limit")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempLimitInt = atof(sstr);
- //*************numberPhases****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "numberPhases");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("numberPhases")+2+c] != '}')
- {
- sstr[c] = loc[strlen("numberPhases")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempNumberPhasesInt = atoi(sstr);
- TxProfile.Duration = durationInt;
- TxProfile.TotalPeriod = n_SchedulePeriods;
- TxProfile.Period[i].Limit = tempLimitInt;
- TxProfile.Period[i].NumberPhases = tempNumberPhasesInt;
- TxProfile.Period[i].StartPeriod = tempStartPeriodInt;
- }
- if(MinChargingRate < tempminChargingRateFloat)
- MinChargingRate = tempminChargingRateFloat;
- if(confirmPeriods < n_SchedulePeriods)
- confirmPeriods = n_SchedulePeriods;
- }
- fclose(fptr1);
- }
- }// the end of ACCESS TxProfile
- //CompositeSchedule
- int period=0;
- if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==FALSE) && (TxProfileIsNull==FALSE) )
- {
- strcpy(CurrentChargingProfileScheduleStr,TxProfileScheduleStr);
- for(int k=0; k < TxProfile.TotalPeriod;k++)
- {
- if(TxProfile.Period[k].Limit < ChargePointMaxProfile.Period[0].Limit)
- {
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = TxProfile.Period[k].Limit;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxProfile.Period[k].NumberPhases;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxProfile.Period[k].StartPeriod;
- period = period + 1;
- }
- else
- {
- if( (TxProfile.Period[k-1].Limit >= ChargePointMaxProfile.Period[0].Limit) && (TxProfile.Period[k].Limit >= ChargePointMaxProfile.Period[0].Limit))
- {
- }
- else
- {
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxProfile.Period[k].NumberPhases;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxProfile.Period[k].StartPeriod;
- period = period + 1;
- }
- }
- }
- for(int l=0; l < TxDefaultProfile.TotalPeriod;l++)
- {
- if((TxDefaultProfile.Period[l].StartPeriod < durationInt)&&(TxDefaultProfile.Period[l].StartPeriod > ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period-1].StartPeriod))
- {
- if(TxDefaultProfile.Period[l].Limit < ChargePointMaxProfile.Period[0].Limit)
- {
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = TxDefaultProfile.Period[l].Limit;
- }
- else
- {
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
- }
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- period = period + 1;
- }
- }
- if((TxDefaultProfile.Duration < durationInt) && (ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period-1].Limit) < ChargePointMaxProfile.Period[0].Limit)
- {
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = ShmOCPP16Data->GetCompositeSchedule[0].ResponseChargingSchedule.ChargingSchedulePeriod[period-1].NumberPhases;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Duration;
- period = period + 1;
- }
- }
- else if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==FALSE) && (TxProfileIsNull==TRUE) )
- {
- strcpy(CurrentChargingProfileScheduleStr,TxDefaultProfileScheduleStr);
- for(int l=0; l < TxDefaultProfile.TotalPeriod;l++)
- {
- if(TxProfile.Period[l].Limit < ChargePointMaxProfile.Period[0].Limit)
- {
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].Limit = TxDefaultProfile.Period[l].Limit;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- period = period + 1;
- }
- else
- {
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].Limit = ChargePointMaxProfile.Period[0].Limit;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- period = period + 1;
- }
- }
- }
- else if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==TRUE) && (TxProfileIsNull==TRUE) )
- {
- strcpy(CurrentChargingProfileScheduleStr,TxDefaultProfileScheduleStr);
- for(int l=0; l < TxDefaultProfile.TotalPeriod;l++)
- {
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].Limit = TxDefaultProfile.Period[l].Limit;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- period = period + 1;
- }
- }
- confirmPeriods = period;
- //DEBUG_INFO("confirmPeriods=%d\n",confirmPeriods);
- //* Define temporary variables */
- struct tm *gtime;
- time_t now;
- char buf[28];
- //* Read the current system time */
- time(&now);
- //* Convert the system time to GMT (now UTC) */
- gtime = gmtime(&now);
- strftime(buf, 28, "%Y-%m-%dT%H:%M:%SZ", gtime);
- // make .conf
- strcpy((char *)ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.StartSchedule,buf);
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.Duration = durationInt;
- //DEBUG_INFO(" debug 11\n");
- strcpy((char *)ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingRateUnit, tempchargingRateUnitStr );
- ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.MinChargingRate = MinChargingRate;
- sprintf(comfirmstr, "%s", GetCompositeScheduleStatusStr[GetCompositeScheduleStatus_Accepted] );
- }
- else
- {
- sprintf(comfirmstr, "%s", GetCompositeScheduleStatusStr[GetCompositeScheduleStatus_Accepted] );
- }
- sendGetCompositeScheduleConfirmation(uuid,comfirmstr, connectorIdInt, confirmPeriods);
- return result;
- }
- int handleGetConfigurationRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- // struct json_object *obj=NULL, *key=NULL;// *jsonitem;
- //struct json_object *jsonitem;
- int MaxKeySupported = 0;
- int n_keys = 0;
- char requestKey[43][50]={0};
- char search[]="[";
- char sstr[500]={ 0 };
- //int pos;
- int l, c = 0;
- int i = 0;
- char *delim = "\",\"";
- char * pch;
- char *loc = strstr(payload, search);
- //********************* Parsing String ***********************************/
- if(loc == NULL) {
- DEBUG_INFO("no key match in Configuration \n");
- }
- else {
- //pos = loc - payload;
- l = strlen(loc)-4;
- while (c < l)
- {
- sstr[c] = loc[c+2];
- c++;
- }
- sstr[c] = '\0';
- //parsing strings to words
- pch = strtok(sstr,delim);
- if(pch == NULL)
- {
- strcpy(requestKey[0], sstr);
- }
- else
- {
- while (pch != NULL)
- {
- strcpy(requestKey[i], pch);
- pch = strtok (NULL, delim);
- i = i + 1;
- }
- n_keys = i;
- }
- }
- UnknownKeynum = 0;
- memset( (void *)unknownkey, 0, sizeof(unknownkey)/*sizeof(char)*10*20*/ );
- MaxKeySupported = GetConfigurationMaxKeysNUM;//atoi(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData);
- memset(ShmOCPP16Data->GetConfiguration.Key, 0 ,sizeof(struct StructConfigurationKeyItems)*MaxKeySupported);
- memset(ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey, 0, sizeof(struct StructConfigurationKey)*MaxKeySupported);
- if(n_keys != 0)
- {
- for(int i=0;i<n_keys;i++)
- {
- getKeyValue(requestKey[i]);
- //json_object_put(jsonitem);
- }
- }
- else
- {
- DEBUG_INFO("There is no key in Message, get all configuration\n");
- getKeyValue("");
- }
- processUnkownKey();
- sendGetConfigurationConfirmation(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, sizeof(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< sizeof(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, sizeof(fnamePWithNoPath));
- strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
- fnamePWithNoPath[i+1] = '\0';
- for(int j=0; j< sizeof(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);
- }
- }
- static char GetDiagnosticspayloadData[300]={0};
- int handleGetDiagnosticsRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- pthread_t t; // pthread 變數
- system("exec /root/logPackTools 'log' 6");
- #if 0
- //char buffer [128];
- time (&rawtime);
- //printf("%ld\n", rawtime);
- timeinfo = localtime (&rawtime);
- strftime (fnamePlusPath,sizeof(fnamePlusPath),"../mnt/%4Y-%2m.zip",timeinfo);
- DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
- if((access(fnamePlusPath,F_OK))!=-1)
- {
- DEBUG_INFO("fnamePlusPath exist.\n");
- strftime (fname,sizeof(fname),"%4Y-%2m-%d-%H-%M-%S.zip",timeinfo);
- }
- else
- {
- DEBUG_INFO("fnamePlusPath not exist!\n");
- }
- #endif
- checkUploadLog();
- memset(GetDiagnosticspayloadData, 0, 300);
- strcpy(GetDiagnosticspayloadData, payload);
- sendGetDiagnosticsConfirmation(uuid,fnamePWithNoPath/*(char*) ret*/);
- pthread_create(&t, NULL, GetDiagnosticsProcess, payload);
- return result;
- }
- void* GetDiagnosticsProcess(void* data)
- {
- pthread_detach(pthread_self());
- mtrace();
- int retriesInt=0, retryIntervalInt=0;
- char locationstr[100]={0}, startTimestr[30]={0}, stopTimestr[30]={0} ;
- int retriesIsNULL,retryIntervalIsNULL, startTimeIsNULL, stopTimeIsNULL;
- char protocol[10]={0}, user[50]={0},password[50]={0},host[50]={0}, path[50]={0}, ftppath[60]={0},host1[50]={0},path1[50]={0};
- int port=0;
- char sstr[260]={ 0 };//sstr[200]={ 0 };
- int c = 0;
- char *loc;
- int isSuccess = FALSE;
- char ftpbuf[200]={0};
- //char temp[100]={0};
- char * pch;
- // [2,"137d88c7-a403-4ead-bb2d-fc6ec90531c1","GetDiagnostics",{"location":"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/","retries":0,"retryInterval":0,"startTime":"0001-01-01T00:00:00.000Z","stopTime":"0001-01-01T00:00:00.000Z"}]
- char str[300]={ 0 };
- strcpy(str,(const char*)GetDiagnosticspayloadData);
- retriesIsNULL = retryIntervalIsNULL = startTimeIsNULL = stopTimeIsNULL = FALSE;
- DEBUG_INFO("GetDiagnosticsProcess\n");
- sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_Uploading]);
- //****************location*******************/
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(str, "location");
- while (loc[3+strlen("location")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("location")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(locationstr,sstr);
- //strcpy(locationstr,"http://test.evsocket.phihong.com.cn:9001/UploadFiles/Diagnostics/");
- if(strcmp(locationstr,"")==0)
- {
- DEBUG_INFO("location is <Empty>!\n");
- sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
- goto end;
- }
- //****************retries*******************/
- c = 0;
- loc = strstr(str, "retries");
- if(loc == NULL)
- {
- retriesIsNULL = TRUE;
- }
- else
- {
- while ((loc[strlen("retries")+2+c] != ',')&&(loc[strlen("retries")+2+c] != '}'))
- {
- sstr[c] = loc[strlen("retries")+2+c];
- c++;
- }
- sstr[c] = '\0';
- retriesInt = atoi(sstr);
- }
- if(retriesIsNULL == TRUE)
- {
- retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
- }
- //****************retryInterval*******************/
- c = 0;
- loc = strstr(str, "retryInterval");
- if(loc == NULL)
- {
- retryIntervalIsNULL = TRUE;
- retryIntervalInt = 30; // if this field is not present, it is left to Charge Point to decide how long to wait between attempts.
- }
- else
- {
- while ((loc[strlen("retryInterval")+2+c] != ',')&&(loc[strlen("retries")+2+c] != '}'))
- {
- sstr[c] = loc[strlen("retryInterval")+2+c];
- c++;
- }
- sstr[c] = '\0';
- retryIntervalInt = atoi(sstr);
- }
- //****************startTime*******************/
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(str, "startTime");
- if(loc == NULL)
- {
- startTimeIsNULL = TRUE;
- }
- else
- {
- while (loc[3+strlen("startTime")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startTime")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(startTimestr,sstr);
- }
- //****************stopTime*******************/
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(str, "stopTime");
- if(loc == NULL)
- {
- stopTimeIsNULL = TRUE;
- }
- else
- {
- while (loc[3+strlen("stopTime")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("stopTime")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(stopTimestr,sstr);
- }
- memset(protocol, 0, sizeof(protocol));
- memset(user, 0, sizeof(user) );
- memset(password, 0, sizeof(password));
- memset(host, 0, sizeof(host));
- memset(path, 0, sizeof(path));
- memset(ftppath, 0, sizeof(ftppath));
- memset(host1, 0, sizeof(host1));
- memset(path1, 0, sizeof(path1));
- /*location: ftp://user:password@host:port/path*/
- #if 0
- time_t rawtime;
- struct tm * timeinfo;
- //char buffer [128];
- time (&rawtime);
- //printf("%ld\n", rawtime);
- timeinfo = localtime (&rawtime);
- strftime (fnamePlusPath,sizeof(fnamePlusPath),"../mnt/%4Y-%2m.zip",timeinfo);
- strftime (fname,sizeof(fname),"%4Y-%2m-%d-%H-%M-%S.zip",timeinfo);
- #endif
- //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
- if((access(fnamePlusPath,F_OK))!=-1)
- {
- DEBUG_INFO("fnamePlusPath exist.\n");
- }
- else
- {
- DEBUG_INFO("fnamePlusPath not exist!\n");
- sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
- goto end;
- }
- pch=strchr(locationstr,'@');
- if(pch==NULL)
- {
- sscanf(locationstr,
- "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
- protocol, host, &port, path);
- strcpy(user,"anonymous");
- strcpy(password,"");
- }
- else
- {
- //DEBUG_INFO("pch=%s\n", pch);
- sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
- protocol, user, password, host, &port, path);
- }
- if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
- {
- DEBUG_INFO("protocol is not ftp/http ! \n");
- sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
- goto end;
- }
- if(strncmp(locationstr,"http", 4) == 0)
- {
- sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
- sprintf(ftppath,"/%s", path);
- do{
- isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, locationstr);
- sleep(retryIntervalInt);
- }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
- if(!isSuccess)
- {
- DEBUG_INFO("Diagnostics fail.\n");
- sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
- }
- else
- {
- DEBUG_INFO("sendDiagnosticsStatusNotificationRequest Uploaded\n");
- sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_Uploaded]);
- }
- }
- else
- {
- sscanf(host,"%[^/]%s",host1, path1);
- 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, sizeof(filenametemp));
- strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
- filenametemp[i+1] = 0;
- memset(ftpbuf, 0, sizeof(ftpbuf));
- if(port == 0)
- port = 21;
- do{
- isSuccess = ftpFile(/*"test.evsocket.phihong.com.cn","phihong","y42j/4cj84",21,"/",fname*/host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
- sleep(retryIntervalInt);
- }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
- if(!isSuccess)
- {
- DEBUG_INFO("Diagnostics fail.\n");
- sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_UploadFailed]);
- }
- else
- {
- DEBUG_INFO("sendDiagnosticsStatusNotificationRequest Uploaded\n");
- sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatus_Uploaded]);
- }
- }
- end:
- DiagnosticsStatusNotificationStatus = 0; //Idle
- pthread_exit(NULL/*(void *) fname*/); // ? ?子執行 ?
- }
- int handleGetLocalListVersionRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- DEBUG_INFO("handle GetLocalListVersionRequest\n");
- if(strcmp((const char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData, "FALSE") == 0)
- {
- DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
- localversion = -1;
- }
- else
- {
- DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
- OCPP_getListVerion();
- }
- //from db.OCPP_getListVerion
- ShmOCPP16Data->GetLocalListVersion.ResponseListVersion = localversion;
- //ShmOCPP16Data->MsMsg.bits.GetLocalListVersionReq = 1;
- sendGetLocalListVersionConfirmation(uuid,"");
- //ShmOCPP16Data->MsMsg.bits.GetLocalListVersionConf = 1;
- return result;
- }
- int handleRemoteStartRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int connectorIdInt=0, chargingProfileIdInt=0, transactionIdInt=0, stackLevelInt=0,
- durationInt=0, startPeriodInt[10]={0}, numberPhasesInt[10]={0};
- char idTagstr[20]={0}, chargingProfilePurposestr[30]={0}, chargingProfileKindstr[14]={0}, recurrencyKindstr[10]={0},
- validFromstr[30]={0}, validTostr[30]={0}, startSchedulestr[30]={0}, chargingRateUnitstr[4]={0};
- int connectorIdIsNULL,chargingProfileIsNULL,transactionIdIsNULL,recurrencyKindIsNULL,validFromIsNULL,validToIsNULL,durationIsNULL,startScheduleIsNULL,minChargingRateIsNULL,numberPhasesIsNULL;
- float minChargingRateflaot=0.0, limitflaot[10]={0.0};
- int chargingSchedulePeriodCount = 0;
- char sstr[30]={ 0 };//sstr[200]={ 0 };
- int c = 0;
- char *loc;
- char comfirmstr[20]={0};
- DEBUG_INFO("handleRemoteStartRequest ...\n");
- if(server_pending == TRUE)
- {
- return 0;
- }
- connectorIdIsNULL = chargingProfileIsNULL = transactionIdIsNULL = recurrencyKindIsNULL = validFromIsNULL = validToIsNULL = durationIsNULL = startScheduleIsNULL = minChargingRateIsNULL = numberPhasesIsNULL= FALSE;
- //**********connectorId****************/
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(payload, "connectorId");
- if(loc == NULL)
- {
- connectorIdIsNULL = TRUE;
- }
- else
- {
- while ((loc[strlen("connectorId")+2+c] != '}') && (loc[strlen("connectorId")+2+c] != ','))
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- connectorIdInt = atoi(sstr);
- }
- if(connectorIdIsNULL == TRUE) // Number of the connector on which to start the transaction. connectorId SHALL be > 0
- {
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- goto end;
- }
- //****************idTag*******************/
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(payload, "idTag");
- while (loc[3+strlen("idTag")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("idTag")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(idTagstr,sstr);
- //****************chargingProfile*******************/
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(payload, "chargingProfile");
- if(loc == NULL)
- {
- chargingProfileIsNULL = TRUE;
- }
- else
- {
- //****************chargingProfileId*******************/
- c=0;
- loc = strstr(payload, "chargingProfileId");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("chargingProfileId")+2+c] != '}') && (loc[strlen("chargingProfileId")+2+c] != ','))
- {
- sstr[c] = loc[strlen("chargingProfileId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- chargingProfileIdInt = atoi(sstr);
- //****************transactionId*******************/
- loc = strstr(payload, "transactionId");
- if(loc == NULL)
- {
- transactionIdIsNULL = TRUE;
- }
- else
- {
- c=0;
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("transactionId")+2+c] != '}') && (loc[strlen("transactionId")+2+c] != ','))
- {
- sstr[c] = loc[strlen("transactionId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- transactionIdInt = atoi(sstr);
- }
- //****************stackLevel*******************/
- c=0;
- loc = strstr(payload, "stackLevel");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("stackLevel")+2+c] != '}') && (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';
- stackLevelInt = atoi(sstr);
- //****************chargingProfilePurpose*******************/
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(payload, "chargingProfilePurpose");
- while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(chargingProfilePurposestr,sstr);
- //****************chargingProfileKind*******************/
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(payload, "chargingProfileKind");
- while (loc[3+strlen("chargingProfileKind")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfileKind")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(chargingProfileKindstr,sstr);
- //****************recurrencyKind*******************/
- loc = strstr(payload, "recurrencyKind");
- if(loc == NULL)
- {
- recurrencyKindIsNULL = TRUE;
- }
- else
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("recurrencyKind")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("recurrencyKind")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(recurrencyKindstr,sstr);
- }
- //****************validFrom*******************/
- loc = strstr(payload, "validFrom");
- if(loc == NULL)
- {
- validFromIsNULL = TRUE;
- }
- else
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(validFromstr,sstr);
- }
- //****************validTo*******************/
- loc = strstr(payload, "validTo");
- if(loc == NULL)
- {
- validToIsNULL = TRUE;
- }
- else
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validTo")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validTo")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(validTostr,sstr);
- }
- //****************chargingSchedule*******************/
- loc = strstr(payload, "chargingSchedule");
- if(loc != NULL)
- {
- //****************duration*******************/
- loc = strstr(payload, "duration");
- if(loc == NULL)
- {
- durationIsNULL = TRUE;
- }
- else
- {
- c=0;
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("duration")+2+c] != '}') && (loc[strlen("duration")+2+c] != ','))
- {
- sstr[c] = loc[strlen("duration")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- durationInt = atoi(sstr);
- }
- //****************startSchedule******************/
- loc = strstr(payload, "startSchedule");
- if(loc == NULL)
- {
- startScheduleIsNULL = TRUE;
- }
- else
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("startSchedule")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startSchedule")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(startSchedulestr,sstr);
- }
- //****************chargingRateUnit*******************/
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(payload, "chargingRateUnit");
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(chargingRateUnitstr,sstr);
- //****************minChargingRate*******************/
- loc = strstr(payload, "minChargingRate");
- if(loc == NULL)
- {
- minChargingRateIsNULL = TRUE;
- }
- else
- {
- c=0;
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("minChargingRate")+2+c] != '}') && (loc[strlen("minChargingRate")+2+c] != ','))
- {
- sstr[c] = loc[strlen("minChargingRate")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- minChargingRateflaot = atof(sstr);
- }
- //****************chargingSchedulePeriod count*******************/
- int what_len = strlen("startPeriod");
- char *where = payload;
- while ((where = strstr(where, "startPeriod"))) {
- where += what_len;
- chargingSchedulePeriodCount++;
- }
- where = payload;
- for(int periodNums=0; periodNums < chargingSchedulePeriodCount; periodNums++)
- {
- //****************startPeriod*******************/
- c=0;
- loc = strstr(where, "startPeriod");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("startPeriod")+2+c] != '}') && (loc[strlen("startPeriod")+2+c] != ','))
- {
- sstr[c] = loc[strlen("startPeriod")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- startPeriodInt[periodNums] = atoi(sstr);
- //****************limit*******************/
- c=0;
- loc = strstr(where, "limit");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("limit")+2+c] != '}') && (loc[strlen("limit")+2+c] != ','))
- {
- sstr[c] = loc[strlen("limit")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- limitflaot[periodNums] = atof(sstr);
- //****************numberPhases*******************/
- loc = strstr(where, "numberPhases");
- if(loc == NULL)
- {
- numberPhasesIsNULL = TRUE;
- }
- else
- {
- c=0;
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("numberPhases")+2+c] != '}') && (loc[strlen("numberPhases")+2+c] != ','))
- {
- sstr[c] = loc[strlen("numberPhases")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- numberPhasesInt[periodNums] = atoi(sstr);
- }
- where = loc;
- }
- }
- }
- /*
- 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
- }
- */
- if((connectorIdIsNULL == FALSE)&&(connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber/*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/))
- {
- sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag, "%s" , idTagstr);
- ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.TransactionId = transactionIdInt;
- //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault 8: Reserved
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == (connectorIdInt -1))
- {
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != 0)&&(strcmp((const char *)ShmSysConfigAndInfo->SysConfig.UserId, idTagstr) == 0))
- {
- //Reserved
- DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != 0)&&(strcmp((const char *)ShmSysConfigAndInfo->SysConfig.UserId, idTagstr) != 0))
- {
- //Reserved
- DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- goto end;
- }
- 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
- {
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- goto end;
- }
- }//END FOR ELSE
- }
- }// END FOR CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == (connectorIdInt -1))
- {
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != 0)&&(strcmp((const char *)ShmSysConfigAndInfo->SysConfig.UserId, idTagstr) == 0))
- {
- //Reserved
- DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != 0)&&(strcmp((const char *)ShmSysConfigAndInfo->SysConfig.UserId, idTagstr) != 0))
- {
- //Reserved
- DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- goto end;
- }
- 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
- {
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- goto end;
- }
- }// END FOR ELSE
- }
- }// END FOR CCS_QUANTITY
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == (connectorIdInt -1))
- {
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != 0)&&(strcmp((const char *)ShmSysConfigAndInfo->SysConfig.UserId, idTagstr) == 0))
- {
- //Reserved
- DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != 0)&&(strcmp((const char *)ShmSysConfigAndInfo->SysConfig.UserId, idTagstr) != 0))
- {
- //Reserved
- DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- goto end;
- }
- 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
- {
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- goto end;
- }
- }// END FOR ELSE
- }
- } // END FOR GB_QUANTITY
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == (connectorIdInt -1))
- {
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != 0)&&(strcmp((const char *)ShmSysConfigAndInfo->SysConfig.UserId, idTagstr) == 0))
- {
- //Reserved
- DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
- }
- else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != 0)&&(strcmp((const char *)ShmSysConfigAndInfo->SysConfig.UserId, idTagstr) != 0))
- {
- //Reserved
- DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- goto end;
- }
- 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
- {
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- goto end;
- }
- }//END FOR ELSE
- }
- }// END FOR AC_QUANTITY
- }
- if(chargingProfileIsNULL == FALSE)
- {
- //ChargingProfile
- ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfileId = chargingProfileIdInt;
- sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfileKind, "%s" ,chargingProfileKindstr);
- sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfilePurpose, "%s" ,chargingProfilePurposestr);
- if(recurrencyKindIsNULL == FALSE) //OPTION
- sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.RecurrencyKind, "%s" ,recurrencyKindstr);
- ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.StackLevel = stackLevelInt;
- if(transactionIdIsNULL == FALSE) // OPTION
- ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.TransactionId = transactionIdInt;
- if(validFromIsNULL == FALSE) // OPTION
- sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ValidFrom, "%s" ,validFromstr);
- if(validToIsNULL == FALSE) //OPTION
- sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ValidTo, "%s" ,validTostr);
- //ChargingSchedule
- sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingRateUnit, "%s" ,chargingRateUnitstr);
- if(durationIsNULL == FALSE) //OPTION
- ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.Duration = durationInt;
- if(minChargingRateIsNULL == FALSE) //OPTION
- ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.MinChargingRate = minChargingRateflaot;
- if(startScheduleIsNULL == FALSE) //OPTION
- sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.StartSchedule, "%s" ,startSchedulestr);
- for(int periodNums=0; periodNums < chargingSchedulePeriodCount; periodNums++)
- {
- //ChargingSchedulePeriod
- ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[periodNums].Limit = limitflaot[periodNums] ;
- if(numberPhasesIsNULL == FALSE)
- {
- ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[periodNums].NumberPhases = numberPhasesInt[periodNums];
- }
- ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[periodNums].StartPeriod = startPeriodInt[periodNums];
- }
- if(strcmp(chargingProfilePurposestr, ChargingProfilePurposeTypeStr[TxProfile]) == 0)
- {
- ShmOCPP16Data->CsMsg.bits[connectorIdInt -1].RemoteStartTransactionReq = 1;
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
- //memset idTag
- memset((char *)ShmOCPP16Data->StartTransaction[connectorIdInt -1].IdTag,0, 20);
- strcpy((char *)ShmOCPP16Data->StartTransaction[connectorIdInt -1].IdTag, idTagstr);
- memset((char *)ShmOCPP16Data->StopTransaction[connectorIdInt -1].IdTag,0, 20);
- strcpy((char *)ShmOCPP16Data->StopTransaction[connectorIdInt -1].IdTag, idTagstr);
- }
- else
- {
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- }
- }
- else
- {
- ShmOCPP16Data->CsMsg.bits[connectorIdInt -1].RemoteStartTransactionReq = 1;
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
- //memset idTag
- memset((char *)ShmOCPP16Data->StartTransaction[connectorIdInt -1].IdTag,0, 20);
- strcpy((char *)ShmOCPP16Data->StartTransaction[connectorIdInt -1].IdTag, idTagstr);
- memset((char *)ShmOCPP16Data->StopTransaction[connectorIdInt -1].IdTag,0, 20);
- strcpy((char *)ShmOCPP16Data->StopTransaction[connectorIdInt -1].IdTag, idTagstr);
- }
- }
- else
- {
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- //sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ResponseStatus, "%s" ,comfirmstr);
- }
- end:
- if(connectorIdIsNULL == FALSE)
- ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ConnectorId = connectorIdInt;
- strcpy((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].IdTag, idTagstr);
- sprintf((char *)ShmOCPP16Data->RemoteStartTransaction[connectorIdInt -1].ResponseStatus, "%s" ,comfirmstr);
- //OCPP send RemoteStartConfirmation by first.
- sendRemoteStartConfirmation(uuid, comfirmstr);
- return result;
- }
- int handleRemoteStopTransactionRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int match = FALSE;
- int GunNO = 0;
- int transactionIdInt=0;
- int transactionIdIsNULL= FALSE;
- char sstr[16]={ 0 };//sstr[200]={ 0 };
- int c = 0;
- char *loc;
- char comfirmstr[20];
- //[2,"ff522854-0dea-436e-87ba-23a229269994","RemoteStopTransaction",{"transactionId":1373618380}]
- DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
- if(server_pending == TRUE)
- {
- return 0;
- }
- c=0;
- loc = strstr(payload, "transactionId");
- if(loc == NULL)
- {
- transactionIdIsNULL= TRUE;
- }
- else
- {
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("transactionId")+2+c] != '}') && (loc[strlen("transactionId")+2+c] != ','))
- {
- sstr[c] = loc[strlen("transactionId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- transactionIdInt = atoi(sstr);
- }
- if(transactionIdIsNULL == FALSE)
- {
- for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
- {
- if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId == transactionIdInt)
- {
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
- {
- 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
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
- {
- 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
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
- {
- 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
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
- {
- 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)
- {
- ShmOCPP16Data->CsMsg.bits[GunNO].RemoteStopTransactionReq = 1; // inform csu of StopTransaction
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
- sprintf((char *)ShmOCPP16Data->RemoteStopTransaction[GunNO].ResponseStatus, "%s" ,comfirmstr);
- }
- else
- {
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
- }
- }
- sendRemoteStopTransactionConfirmation(uuid, comfirmstr);
- return result;
- }
- int handleReserveNowTransactionRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int connectorIdInt=0, reservationIdInt=0;
- char expiryDatestr[30]={0}, idTagstr[20]={0},parentIdTagstr[20]={0};
- char comfirmstr[20]={0};
- char sstr[180]={ 0 };
- int c = 0;
- char *loc;
- //char *ptr;
- //[2,"1571898416054","ReserveNow",{"connectorId":1,"expiryDate":"2020-06-19T09:10:00.000Z","idTag":"B014EA9C","reservationId":1}]
- //***(1)connectorId ****/
- c=0;
- loc = strstr(payload, "connectorId");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc != NULL) &&(loc[strlen("connectorId")+2+c] != ',') && (loc[strlen("connectorId")+2+c] != '}'))
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- connectorIdInt = atoi(sstr);
- //***(2)expiryDate ****/
- loc = strstr(payload, "expiryDate");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while ((loc != NULL) &&(loc[3+strlen("expiryDate")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("expiryDate")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(expiryDatestr, sstr);
- //***(3)idTag ****/
- loc = strstr(payload, "idTag");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while ((loc != NULL) &&(loc[3+strlen("idTag")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("idTag")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(idTagstr, sstr);
- //***(4)parentIdTag ****/
- loc = strstr(payload, "parentIdTag");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- if(loc == NULL)
- {
- strcpy(parentIdTagstr, "");
- }
- else
- {
- while ((loc != NULL) &&(loc[3+strlen("parentIdTag")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("parentIdTag")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(parentIdTagstr, sstr);
- }
- //***(5)reservationId ****/
- c=0;
- loc = strstr(payload, "reservationId");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc != NULL) &&((loc[strlen("reservationId")+2+c] != '}') && (loc[strlen("reservationId")+2+c] != ',')))
- {
- sstr[c] = loc[strlen("reservationId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- reservationIdInt = atoi(sstr);
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Rejected]);
- /*
- enum SYSTEM_STATUS
- {
- SYS_MODE_BOOTING = 0,
- SYS_MODE_IDLE = 1,
- SYS_MODE_AUTHORIZING = 2,
- SYS_MODE_MODE_REASSIGN_CHECK = 3,
- SYS_MODE_REASSIGN = 4,
- SYS_MODE_PREPARING = 5,
- SYS_MODE_PREPARE_FOR_EV = 6,
- SYS_MODE_PREPARE_FOR_EVSE = 7,
- SYS_MODE_CHARGING = 8,
- SYS_MODE_TERMINATING = 9,
- SYS_MODE_COMPLETE = 10,
- SYS_MODE_ALARM = 11,
- SYS_MODE_FAULT = 12,
- SYS_MODE_RESERVATION = 13,
- SYS_MODE_BOOKING = 14,
- SYS_MODE_MAINTAIN = 15,
- SYS_MODE_DEBUG = 16,
- SYS_MODE_CCS_PRECHARGE_STEP0 = 17,
- SYS_MODE_CCS_PRECHARGE_STEP1 = 18,
- SYS_MODE_UPDATE = 19
- };
- */
- if((connectorIdInt == 0) &&(strcmp((const char *)ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemData, "FALSE") == 0)) //For OCTT Test case
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Rejected]);
- goto end;
- }
- if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
- {
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == (connectorIdInt -1))
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT) //S_FAULT
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_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(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
- }
- else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Occupied]);
- }
- else
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Rejected]);
- }
- }
- else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Faulted]);
- }
- }
- else
- {
- //replace reservation
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Accepted]);
- }
- }
- } // END FOR CHAdeMO_QUANTITY
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == (connectorIdInt -1))
- {
- 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) //S_FAULT
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_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(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
- }
- else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Occupied]);
- }
- else
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Rejected]);
- }
- }
- else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus ==SYS_MODE_FAULT) //S_FAULT
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Faulted]);
- }
- }
- else
- {
- //replace reservation
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Accepted]);
- }
- }
- } // END FOR CCS_QUANTITY
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == (connectorIdInt - 1))
- {
- 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) //S_FAULT
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_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(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
- }
- else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Occupied]);
- }
- else
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Rejected]);
- }
- }
- else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_FAULT) //S_FAULT
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Faulted]);
- }
- }
- else
- {
- //replace reservation
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Accepted]);
- }
- }
- }// END FOR GB_QUANTITY
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == (connectorIdInt -1))
- {
- if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[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.AcChargingData[index].SystemStatus != SYS_MODE_FAULT) //S_FAULT
- {
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
- {
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_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(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
- }
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Occupied]);
- }
- else
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Rejected]);
- }
- }
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Faulted]);
- }
- }
- else
- {
- //replace reservation
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Accepted]);
- }
- }
- } // END FOR AC_QUANTITY
- }//END FOR AC ELSE
- sprintf((char *)ShmOCPP16Data->ReserveNow[connectorIdInt-1].ResponseStatus, "%s" ,comfirmstr);
- }
- else if(connectorIdInt == 0)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- //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(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Occupied]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Faulted]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_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(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
- }
- else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Occupied]);
- }
- else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus ==SYS_MODE_FAULT) //S_FAULT
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Faulted]);
- }
- else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Rejected]);
- }
- }
- } // 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(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
- }
- else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Occupied]);
- }
- else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_FAULT) //S_FAULT
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Faulted]);
- }
- else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Rejected]);
- }
- }
- } // END FOR GB_QUANTITY
- }
- else
- {
- 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(comfirmstr, ReservationStatusStr[ReservationStatus_Unavailable]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Occupied]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Faulted]);
- goto end;
- }
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Rejected]);
- goto end;
- }
- }
- }// END FOR AC_QUANTITY
- }
- //The connectorId is 0
- ShmOCPP16Data->CsMsg.bits[0].ReserveNowReq = 1;
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Accepted]);
- sprintf((char *)ShmOCPP16Data->ReserveNow[0].ResponseStatus, "%s" ,comfirmstr);
- ShmOCPP16Data->ReserveNow[0].ConnectorId = connectorIdInt;
- sprintf((char *)ShmOCPP16Data->ReserveNow[0].ExpiryDate, "%s" , expiryDatestr);
- sprintf((char *)ShmOCPP16Data->ReserveNow[0].IdTag, "%s" , idTagstr);
- sprintf((char *)ShmOCPP16Data->ReserveNow[0].ParentIdTag, "%s" , parentIdTagstr);
- ShmOCPP16Data->ReserveNow[0].ReservationId = reservationIdInt;
- strcpy((char *)ShmOCPP16Data->ReserveNow[0].guid, uuid);
- result = TRUE;
- return result;
- }
- else
- {
- strcpy(comfirmstr, ReservationStatusStr[ReservationStatus_Rejected]);
- sprintf((char *)ShmOCPP16Data->ReserveNow[connectorIdInt-1].ResponseStatus, "%s" ,comfirmstr);
- }
- if(strcmp(comfirmstr,"Accepted") == 0)
- {
- ShmOCPP16Data->ReserveNow[connectorIdInt-1].ConnectorId = connectorIdInt;
- sprintf((char *)ShmOCPP16Data->ReserveNow[connectorIdInt-1].ExpiryDate, "%s" , expiryDatestr);
- sprintf((char *)ShmOCPP16Data->ReserveNow[connectorIdInt-1].IdTag, "%s" , idTagstr);
- sprintf((char *)ShmOCPP16Data->ReserveNow[connectorIdInt-1].ParentIdTag, "%s" , parentIdTagstr);
- ShmOCPP16Data->ReserveNow[connectorIdInt-1].ReservationId = reservationIdInt;
- strcpy((char *)ShmOCPP16Data->ReserveNow[connectorIdInt-1].guid, uuid);
- result = TRUE;
- return result;
- }
- end:
- sendReserveNowTransactionConfirmation(uuid,comfirmstr);
- //ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].ReserveNowConf = 1;
- return result;
- }
- int handleResetRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- char sstr[10]={0};
- char typestr[10]={0};
- char comfirmstr[20]={0};
- int c = 0;
- char *loc;
- //[2,"6f88d461-4d17-462c-a69b-1f7a8c5b12df","Reset",{"type":"Hard"}]
- DEBUG_INFO("handleResetRequest ...\n");
- loc = strstr(payload, "type");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("type")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("type")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(typestr,sstr);
- sprintf((char *)ShmOCPP16Data->Reset.Type, "%s" ,typestr);
- //strcpy(ShmOCPP16Data->Reset.Type, typestr);
- if(strcmp(typestr, ResetTypeStr[Hard])==0)
- {
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- {
- //0: unplug, 1: Plug-in
- //ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn = 0;
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- {
- //0: unplug, 1: Plug-in
- //ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn = 0;
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- {
- //0: unplug, 1: Plug-in
- //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn = 0;
- }
- }
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- {
- //0: unplug, 1: Plug-in
- //ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn = 0;
- }
- }
- }// END FOR AC ELSE
- ShmOCPP16Data->MsMsg.bits.ResetReq = 1;
- strcpy((char *)ShmOCPP16Data->Reset.guid, uuid);
- result = TRUE;
- return result;
- }
- else if(strcmp(typestr, ResetTypeStr[Soft])==0)
- {
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- {
- //0: unplug, 1: Plug-in
- //ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn = 0;
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- {
- //0: unplug, 1: Plug-in
- //ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn = 0;
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- {
- //0: unplug, 1: Plug-in
- //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn = 0;
- }
- }
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
- {
- //0: unplug, 1: Plug-in
- //ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn = 0;
- }
- }
- }// END FOR AC ELSE
- ShmOCPP16Data->MsMsg.bits.ResetReq = 1;
- strcpy((char *)ShmOCPP16Data->Reset.guid, uuid);
- result = TRUE;
- return result;
- }
- else
- {
- strcpy(comfirmstr, ResetStatusStr[ResetStatus_Rejected]);
- sprintf((char *)ShmOCPP16Data->Reset.ResponseStatus, "%s" ,comfirmstr);
- goto errorend;
- }
- errorend:
- sendResetConfirmation(uuid, comfirmstr);
- return result;
- }
- int handleSendLocalListRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int listVersionInt;
- //char *updateTypestr, *idTagstr, *expiryDatestr, *parentIdTagstr, *statusstr;
- char listsearch[]="listVersion";
- char updateTypesearch[]="updateType";
- char localAuthorizationListsearch[]="localAuthorizationList";
- char sstr[60500]={ 0 };//sstr[200]={ 0 };
- char CardList[500][160]={0};
- char updateTypestr[15]={0};
- char idTagstr[20]={0};
- char parentIdTag[20]={0};
- char expiryDate[30]={0};
- char idTagstatus[16]={0};
- int c = 0;
- int i = 0;
- char *delim1 = "}";
- char * pch;
- char *loc;
- //char *ptr;
- char comfirmstr[20];
- //int n_localAuthorizations = 0;
- int checkState_Faulted = FALSE;
- DEBUG_INFO("handleSendLocalListRequest\n");
- if(strcmp((const char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData, "FALSE") == 0) //For OCTT Test case
- {
- strcpy(comfirmstr, UpdateStatusStr[UpdateStatus_NotSupported]);
- goto end;
- }
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- //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
- }
- }
- }
- else
- {
- //check Charge Point state
- 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
- }
- }
- }// END FOR AC ELSE
- if(checkState_Faulted == TRUE)
- {
- strcpy(comfirmstr, UpdateStatusStr[UpdateStatus_Failed]);
- goto end;
- }
- //listVersion
- c = 0;
- loc = strstr(payload, listsearch);
- while ((loc[strlen("listVersion")+2+c] != ',')&&(loc[strlen("listVersion")+2+c] != '}'))
- {
- sstr[c] = loc[strlen("listVersion")+2+c];
- c++;
- }
- sstr[c] = '\0';
- listVersionInt = atoi(sstr);
- ShmOCPP16Data->SendLocalList.ListVersion = listVersionInt;
- //updateType
- loc = strstr(payload, updateTypesearch);
- c = 0;
- while (loc[3+strlen(updateTypesearch)+c] != '\"')
- {
- sstr[c] = loc[3+strlen(updateTypesearch)+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(updateTypestr, sstr);
- sprintf((char *)ShmOCPP16Data->SendLocalList.UpdateType, "%s", updateTypestr);
- //localAuthorizationList
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(payload, localAuthorizationListsearch);
- if(loc != NULL) // localAuthorizationList is not NULL
- {
- //Check UpdateType
- if(strcmp(updateTypestr, UpdateTypeStr[Full]) == 0)
- {
- //Local list full update
- printf("Local list full update.\n");
- OCPP_cleanLocalList();
- }
- else if(strcmp(updateTypestr, UpdateTypeStr[Differential]) == 0)
- {
- //Local list different update
- printf("Local list different update.\n");
- OCPP_getListVerion();
- if(listVersionInt < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
- {
- strcpy(comfirmstr, UpdateStatusStr[UpdateStatus_VersionMismatch]);
- goto end;
- }
- }
- else
- {
- strcpy(comfirmstr, UpdateStatusStr[UpdateStatus_NotSupported]);
- goto end;
- }
- c = 0;
- while (loc[3+strlen(localAuthorizationListsearch)+c] != ']')
- {
- sstr[c] = loc[3+strlen(localAuthorizationListsearch)+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- //DEBUG_INFO("sstr=%s\n", sstr);
- //parsing strings to words
- i = 0;
- pch = strtok(sstr,delim1);
- while (pch != NULL)
- {
- strcpy(CardList[i], pch);
- DEBUG_INFO("CardList[i]=%s\n", CardList[i]);
- pch = strtok (NULL, delim1);
- i = i + 1;
- }
- //DEBUG_INFO("listVersionInt=%s\n", sstr);
- //local Authorizations List Numbers
- //n_localAuthorizations = i;
- ShmOCPP16Data->SendLocalList.ListVersion = listVersionInt;
- memset(ShmOCPP16Data->SendLocalList.LocalAuthorizationList, 0 , sizeof(struct StructLocalAuthorizationList)* 500);
- c= 0;
- while(c < i)
- {
- //Search "IdToken"
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(CardList[c], "idTag");
- int j = 0;
- while (loc[3+strlen("idTag")+j] != '\"')
- {
- sstr[j] = loc[3+strlen("idTag")+j];
- //printf("i=%d sstr=%c\n",c, sstr[j]);
- j++;
- }
- sstr[j] = '\0';
- strcpy(idTagstr, sstr);
- //DEBUG_INFO("idTagstr=%s\n", idTagstr);
- //Search "expiryDate"
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(CardList[c], "expiryDate");
- j = 0;
- if(loc != NULL)
- {
- while (loc[3+strlen("expiryDate")+j] != '\"')
- {
- sstr[j] = loc[3+strlen("expiryDate")+j];
- //printf("i=%d sstr=%c\n",c, sstr[j]);
- j++;
- }
- sstr[j] = '\0';
- strcpy(expiryDate, sstr);
- }
- else
- {
- strcpy(expiryDate, "");
- }
- //DEBUG_INFO("expiryDate=%s\n", expiryDate);
- //Search "parentIdTag"
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(CardList[c], "parentIdTag");
- j = 0;
- if(loc != NULL)
- {
- while (loc[3+strlen("parentIdTag")+j] != '\"')
- {
- sstr[j] = loc[3+strlen("parentIdTag")+j];
- //printf("i=%d sstr=%c\n",c, sstr[j]);
- j++;
- }
- sstr[j] = '\0';
- strcpy(parentIdTag, sstr);
- }
- else
- {
- strcpy(parentIdTag, "");
- }
- //DEBUG_INFO("parentIdTag=%s\n", parentIdTag);
- //Search "status"
- memset(sstr ,0, sizeof(sstr) );
- loc = strstr(CardList[c], "status");
- j = 0;
- while (loc[3+strlen("status")+j] != '\"')
- {
- sstr[j] = loc[3+strlen("status")+j];
- //printf("i=%d sstr=%c\n",c, sstr[j]);
- j++;
- }
- sstr[j] = '\0';
- strcpy(idTagstatus, sstr);
- //DEBUG_INFO("idTagstatus=%s\n", idTagstatus);
- OCPP_getIdTag(idTagstr);
- //OCPP_getIdTag("test"); For Test
- //DEBUG_INFO("idTagAuthorization=%s\n",idTagAuthorization);
- if(strcmp(updateTypestr, UpdateTypeStr[Full]) == 0)
- {
- //Local list full update
- DEBUG_INFO("Local list full update.\n");
- // update list
- OCPP_addLocalList_1(listVersionInt, idTagstr, parentIdTag, expiryDate, idTagstatus);
- OCPP_get_TableAuthlocalAllData();
- }
- else if(strcmp(updateTypestr, UpdateTypeStr[Differential]) == 0)
- {
- if((strcmp(idTagstr, idTagAuthorization) == 0) && (parentIdTag[0] != '\0'))
- {
- OCPP_addLocalList_1(listVersionInt, idTagstr, parentIdTag, expiryDate, idTagstatus);
- }
- else if((strcmp(idTagstr, idTagAuthorization) == 0) && (parentIdTag[0] == '\0'))
- {
- OCPP_deleteIdTag(idTagstr);
- }
- else if((strcmp(idTagstr, idTagAuthorization) != 0) && (parentIdTag[0] != '\0'))
- {
- OCPP_addLocalList_1(listVersionInt, idTagstr, parentIdTag, expiryDate, idTagstatus);
- }
- }
- strcpy((char *)ShmOCPP16Data->SendLocalList.LocalAuthorizationList[c].IdTag, idTagstr);
- strcpy((char *)ShmOCPP16Data->SendLocalList.LocalAuthorizationList[c].IdTagInfo.ExpiryDate, expiryDate);
- strcpy((char *)ShmOCPP16Data->SendLocalList.LocalAuthorizationList[c].IdTagInfo.ParentIdTag, parentIdTag);
- strcpy((char *)ShmOCPP16Data->SendLocalList.LocalAuthorizationList[c].IdTagInfo.Status, idTagstatus);
- c++;
- }
- }
- else
- {
- //Check UpdateType
- if(strcmp(updateTypestr, UpdateTypeStr[Full]) == 0)
- {
- //Local list full update
- DEBUG_INFO("If no (empty) localAuthorizationList is given and the updateType is Full, all identifications are removed from the list. \n");
- OCPP_cleanLocalList();
- strcpy(comfirmstr, UpdateStatusStr[UpdateStatus_Accepted]);
- goto end;
- }
- if(strcmp(updateTypestr, UpdateTypeStr[Differential]) == 0)
- {
- //Local list different update
- DEBUG_INFO("Requesting a Differential update without (empty) localAuthorizationList will have no effect on the list\n");
- strcpy(comfirmstr, UpdateStatusStr[UpdateStatus_Accepted]);
- goto end;
- }
- }
- strcpy(comfirmstr, UpdateStatusStr[UpdateStatus_Accepted]);
- end:
- sendSendLocalListConfirmation(uuid, comfirmstr);
- //ShmOCPP16Data->MsMsg.bits.SendLocalListConf = 1;
- return result;
- }
- #define MAX 200
- int handleSetChargingProfileRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int connectorIdInt=0, chargingProfileIdInt=0, transactionIdInt=0,stackLevelInt=0, durationInt=0, startPeriodInt[10]={0}, numberPhasesInt[10]={0};
- int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
- char chargingProfilePurposeStr[30]={0};
- char chargingProfileKindStr[16]={0};
- char recurrencyKindStr[10]={0};
- char validFromStr[30]={0}, validToStr[30]={0}, startScheduleStr[30]={0}, chargingRateUnitStr[6]={0};
- float minChargingRateFloat = 0.0, limitflaot[10] = {0.0};
- int chargingSchedulePeriodCount = 0;
- //int updateflag = FALSE;
- char comfirmstr[20]={0};
- int meet= FALSE;
- char sstr[10]={0};
- int c = 0;
- char *loc;
- FILE *fptr1;//, *fptr2;
- //int lno=0;//, linectr = 0;
- //int modifyflag = FALSE;
- char filename[MAX]={0};
- char tempfile[] = "/Storage/OCPP/temp.json";
- //int resultRename=0;
- char rmFileCmd[50]={0};
- char tempchargingProfilePurposeStr[30]={0};
- //[2,"d65bcbca-0b07-49c1-b679-e6c6ff9f5627","SetChargingProfile",{"connectorId":0,"csChargingProfiles":{"chargingProfileId":1,"transactionId":0,"stackLevel":0,"chargingProfilePurpose":"TxDefaultProfile","chargingProfileKind":"Absolute","recurrencyKind":"Daily","validFrom":"2019-07-01T02:39:55.000Z","validTo":"2019-07-04T02:39:55.000Z","chargingSchedule":{"duration":86400,"startSchedule":"2019-07-01T02:39:55.000Z","chargingRateUnit":"A","chargingSchedulePeriod":[{"startPeriod":0,"limit":20.0,"numberPhases":3},{"startPeriod":300,"limit":10.0,"numberPhases":3},{"startPeriod":600,"limit":20.0,"numberPhases":3},{"startPeriod":1200,"limit":10.0,"numberPhases":3},{"startPeriod":1800,"limit":20.0,"numberPhases":3},{"startPeriod":2400,"limit":10.0,"numberPhases":3},{"startPeriod":3000,"limit":20.0,"numberPhases":3}],"minChargingRate":20.1}}}]
- DEBUG_INFO("handleSetChargingProfileRequest\n");
- connectorIdInt = chargingProfileIdInt = transactionIdInt = stackLevelInt = 0;
- //*********************connectorId***************************/
- loc = strstr(payload, "connectorId");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- c++;
- }
- sstr[c] = '\0';
- connectorIdInt = atoi(sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ConnectorId = connectorIdInt;
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ConnectorId = connectorIdInt;
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -1\n");
- //*********************chargingProfileId***************************/
- loc = strstr(payload, "chargingProfileId");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("chargingProfileId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("chargingProfileId")+2+c];
- c++;
- }
- sstr[c] = '\0';
- chargingProfileIdInt = atoi(sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingProfileId = chargingProfileIdInt;
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingProfileId = chargingProfileIdInt;
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -2\n");
- //*********************transactionId***************************/
- loc = strstr(payload, "transactionId");
- if(loc != NULL)
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("transactionId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("transactionId")+2+c];
- c++;
- }
- sstr[c] = '\0';
- transactionIdInt = atoi(sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.TransactionId = transactionIdInt;
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.TransactionId = transactionIdInt;
- }
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -3\n");
- //*********************stackLevel***************************/
- loc = strstr(payload, "stackLevel");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("stackLevel")+2+c] != ',')
- {
- sstr[c] = loc[strlen("stackLevel")+2+c];
- c++;
- }
- sstr[c] = '\0';
- stackLevelInt = atoi(sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.StackLevel = stackLevelInt;
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.StackLevel = stackLevelInt;
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -4\n");
- //*********************chargingProfilePurpose***************************/
- loc = strstr(payload, "chargingProfilePurpose");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(chargingProfilePurposeStr,sstr);
- //DEBUG_INFO("chargingProfilePurposeStr=%s\n",chargingProfilePurposeStr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingProfilePurpose, chargingProfilePurposeStr);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingProfilePurpose, chargingProfilePurposeStr);
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -6\n");
- //*********************chargingProfileKind***************************/
- loc = strstr(payload, "chargingProfileKind");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingProfileKind")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfileKind")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(chargingProfileKindStr,sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingProfileKind, chargingProfileKindStr);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingProfileKind, chargingProfileKindStr);
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -7\n");
- //*********************recurrencyKind***************************/
- loc = strstr(payload, "recurrencyKind");
- if(loc != NULL)
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("recurrencyKind")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("recurrencyKind")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(recurrencyKindStr,sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.RecurrencyKind, recurrencyKindStr);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.RecurrencyKind, recurrencyKindStr);
- }
- }
- else
- {
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.RecurrencyKind, "");
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.RecurrencyKind, "");
- }
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -8\n");
- //*********************validFrom***************************/
- loc = strstr(payload, "validFrom");
- if(loc != NULL)
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(validFromStr,sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ValidFrom, validFromStr);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ValidFrom, validFromStr);
- }
- }
- else
- {
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ValidFrom, "");
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ValidFrom, "");
- }
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -9\n");
- //*********************validTo***************************/
- loc = strstr(payload, "validTo");
- if(loc != NULL)
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validTo")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validTo")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(validToStr,sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ValidTo, validToStr);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ValidTo, validToStr);
- }
- }
- else
- {
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ValidTo, "");
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ValidTo, "");
- }
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -10\n");
- //*********************duration***************************/
- loc = strstr(payload, "duration");
- if(loc != NULL)
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("duration")+2+c] != ',')
- {
- sstr[c] = loc[strlen("duration")+2+c];
- c++;
- }
- sstr[c] = '\0';
- durationInt = atoi(sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.Duration = durationInt;
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingSchedule.Duration = durationInt;
- }
- }
- else
- {
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.Duration = 0;
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingSchedule.Duration = 0;
- }
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -11\n");
- //*********************startSchedule***************************/
- loc = strstr(payload, "startSchedule");
- if(loc != NULL)
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("startSchedule")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startSchedule")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(startScheduleStr,sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.StartSchedule,startScheduleStr);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingSchedule.StartSchedule,startScheduleStr);
- }
- }
- else
- {
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.StartSchedule,"");
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingSchedule.StartSchedule,"");
- }
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -12\n");
- //*********************chargingRateUnit***************************/
- loc = strstr(payload, "chargingRateUnit");
- if(loc != NULL)
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(chargingRateUnitStr,sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.ChargingRateUnit,chargingRateUnitStr);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingRateUnit,chargingRateUnitStr);
- }
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -13\n");
- //****************chargingSchedulePeriod count start*******************/
- int what_len = strlen("startPeriod");
- char tempChargingProfile[1000]={0};
- strcpy(tempChargingProfile,(const char*)payload);
- char *where = tempChargingProfile;
- if (what_len)
- {
- while ((where = strstr(where, "startPeriod"))) {
- where += what_len;
- chargingSchedulePeriodCount++;
- }
- }
- //DEBUG_INFO("chargingSchedulePeriodCount=%d\n",chargingSchedulePeriodCount);
- //DEBUG_INFO("handleSetChargingProfileRequest -13 -1\n");
- //where = payload;
- int templength = 0;
- //int searchstart = 0;
- for(int periodNums=0; periodNums < chargingSchedulePeriodCount; periodNums++)
- {
- //****************startPeriod*******************/
- c=0;
- loc = strstr(tempChargingProfile + templength, "startPeriod");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("startPeriod")+2+c] != '}') && (loc[strlen("startPeriod")+2+c] != ','))
- {
- sstr[c] = loc[strlen("startPeriod")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- startPeriodInt[periodNums] = atoi(sstr);
- //DEBUG_INFO("sstr=%d\n",atoi(sstr));
- //DEBUG_INFO("handleSetChargingProfileRequest -13 -1 -1\n");
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[periodNums].StartPeriod = startPeriodInt[periodNums];
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[periodNums].StartPeriod = startPeriodInt[periodNums];
- }
- templength = strlen("startPeriod")+2+c;
- //DEBUG_INFO("handleSetChargingProfileRequest -13 -2\n");
- //****************limit*******************/
- c=0;
- loc = strstr(tempChargingProfile + templength, "limit");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("limit")+2+c] != '}') && (loc[strlen("limit")+2+c] != ','))
- {
- sstr[c] = loc[strlen("limit")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- limitflaot[periodNums] = atof(sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[periodNums].Limit = limitflaot[periodNums];
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[periodNums].Limit = limitflaot[periodNums];
- }
- templength = templength + strlen("limit")+2+c;
- //DEBUG_INFO("handleSetChargingProfileRequest -13 -3\n");
- //****************numberPhases*******************/
- loc = strstr(tempChargingProfile + templength, "numberPhases");
- if(loc != NULL)
- {
- c=0;
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("numberPhases")+2+c] != '}') && (loc[strlen("numberPhases")+2+c] != ','))
- {
- sstr[c] = loc[strlen("numberPhases")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- numberPhasesInt[periodNums] = atoi(sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[periodNums].NumberPhases = numberPhasesInt[periodNums];
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[periodNums].NumberPhases = numberPhasesInt[periodNums];
- }
- templength = templength + strlen("numberPhases")+2+c;
- }
- //where = loc;
- }
- //DEBUG_INFO("handleSetChargingProfileRequest -14\n");
- //****************chargingSchedulePeriod count end*******************/
- //*********************minChargingRate***************************/
- loc = strstr(payload, "minChargingRate");
- if(loc != NULL)
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("minChargingRate")+2+c] != ',')&&(loc[strlen("minChargingRate")+2+c] != '}'))
- {
- sstr[c] = loc[strlen("minChargingRate")+2+c];
- c++;
- }
- sstr[c] = '\0';
- minChargingRateFloat = atof(sstr);
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.MinChargingRate = minChargingRateFloat;
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingSchedule.MinChargingRate = minChargingRateFloat;
- }
- }
- else
- {
- if(connectorIdInt == 0) // an overall limit for the Charge Point.
- {
- ShmOCPP16Data->SetChargingProfile[0].ChargingProfile.ChargingSchedule.MinChargingRate = 0.0;
- }
- else
- {
- ShmOCPP16Data->SetChargingProfile[connectorIdInt -1].ChargingProfile.ChargingSchedule.MinChargingRate = 0.0;
- }
- }
- if(strcmp(chargingProfilePurposeStr, ChargingProfilePurposeTypeStr[ChargePointMaxProfile]) == 0)
- {
- //printf("set chargingProfile 1-2\n");
- DEBUG_INFO("chargingProfilePurposeStr is ChargePointMaxProfile !!! \n");
- if(connectorIdInt != 0)
- {
- sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
- goto end;
- }
- strcpy(filename, ChargePointMaxProfile_JSON );
- fptr1 = fopen(filename, "r");
- if (!fptr1)
- {
- //file not exist
- DEBUG_INFO("Unable to open the input file!!\n");
- fptr1 = fopen(filename, "w+");
- }
- fclose(fptr1);
- }
- else if(strcmp(chargingProfilePurposeStr, ChargingProfilePurposeTypeStr[TxDefaultProfile]) == 0)
- {
- //printf("set chargingProfile 1-3\n");
- DEBUG_INFO("chargingProfilePurposeStr is TxDefaultProfile !!! \n");
- if((connectorIdInt != 0) && (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/))
- {
- sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
- goto end;
- }
- switch(connectorIdInt)
- {
- case 0:
- strcpy(filename, TxDefaultProfile_0_JSON );
- break;
- case 1:
- strcpy(filename, TxDefaultProfile_1_JSON );
- break;
- case 2:
- strcpy(filename, TxDefaultProfile_2_JSON );
- break;
- default:
- strcpy(filename, TxDefaultProfile_0_JSON );
- break;
- }
- fptr1 = fopen(filename, "r");
- if (!fptr1)
- {
- //file not exist
- //DEBUG_INFO("Unable to open the input file!!\n");
- fptr1 = fopen(filename, "w+");
- }
- fclose(fptr1);
- }
- else if(strcmp(chargingProfilePurposeStr, ChargingProfilePurposeTypeStr[TxProfile]) == 0)
- {
- //printf("set chargingProfile 1-4\n");
- DEBUG_INFO("chargingProfilePurposeStr is TxProfile !!! \n");
- //check Transaction active
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == (connectorIdInt -1))
- {
- if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
- {
- if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
- {
- meet = TRUE;
- break;
- }
- }
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == (connectorIdInt -1))
- {
- if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
- {
- if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
- {
- meet = TRUE;
- break;
- }
- }
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == (connectorIdInt -1))
- {
- if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
- {
- if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
- {
- meet = TRUE;
- break;
- }
- }
- }
- }
- if(meet == FALSE)
- {
- sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
- goto end;
- }
- if((connectorIdInt != 0) && (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/))
- {
- sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
- goto end;
- }
- switch(connectorIdInt)
- {
- case 0:
- break;
- case 1:
- strcpy(filename, TxProfile_1_JSON);
- break;
- case 2:
- strcpy(filename, TxProfile_2_JSON);
- break;
- default:
- strcpy(filename, TxProfile_1_JSON);
- break;
- }
- fptr1 = fopen(filename, "r");
- if (!fptr1)
- {
- //file not exist
- DEBUG_INFO("Unable to open the input file!!\n");
- fptr1 = fopen(filename, "w+");
- }
- fclose(fptr1);
- }
- //**********************************Write to File********************************************************/
- FILE *infile;
- FILE *outfile;
- // open file for writing
- infile = fopen (filename, "r");
- outfile = fopen (tempfile, "w");
- int d =0;
- d = fgetc(infile);
- //DEBUG_INFO("d:%d\n",d);
- rewind(infile);
- //*检测到文件结束标识返回1,否则返回0。*/
- if(d == EOF)
- {
- //DEBUG_INFO("ChargingProfile content is NULL\n");
- fprintf(outfile,"%s\n",payload);
- sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Accepted] );
- fclose(infile);
- fclose(outfile);
- sprintf(rmFileCmd,"rm -f %s",filename);
- system(rmFileCmd);
- rename(tempfile, filename);
- #if 0
- resultRename = rename(tempfile, filename);
- if(resultRename == 0)
- {
- DEBUG_INFO("File chargingProfile renamed successfully");
- }
- else
- {
- DEBUG_INFO("Error: unable to rename the chargingProfile file");
- }
- #endif
- //sprintf(rmFileCmd,"rm -f %s",tempfile);
- //system(rmFileCmd);
- }
- else
- {
- char buf[1000]={0};
- int ChargingProfileAdded = FALSE;
- while (fgets(buf, sizeof(buf), infile) != NULL)
- {
- buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
- //*************************tempconnectorIdInt*********************************/
- loc = strstr(buf, "connectorId");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- c++;
- }
- sstr[c] = '\0';
- tempconnectorIdInt = atoi(sstr);
- //*************************tempchargingProfileIdInt*********************************/
- loc = strstr(buf, "chargingProfileId");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("chargingProfileId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("chargingProfileId")+2+c];
- c++;
- }
- sstr[c] = '\0';
- tempchargingProfileIdInt = atoi(sstr);
- //*************************tempstackLevelInt*********************************/
- loc = strstr(buf, "stackLevel");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("stackLevel")+2+c] != ',')
- {
- sstr[c] = loc[strlen("stackLevel")+2+c];
- c++;
- }
- sstr[c] = '\0';
- tempstackLevelInt = atoi(sstr);
- //*************************tempchargingProfilePurposeStr*********************************/
- loc = strstr(payload, "chargingProfilePurpose");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingProfilePurposeStr,sstr);
- if((tempconnectorIdInt == connectorIdInt) && (tempchargingProfileIdInt == chargingProfileIdInt))
- {
- if((tempstackLevelInt == stackLevelInt) && (strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
- {
- //DEBUG_INFO("update set chargingProfile to file -0\n");
- if(ChargingProfileAdded == FALSE)
- {
- fprintf(outfile,"%s\n",payload);
- ChargingProfileAdded = TRUE;
- }
- }
- else
- {
- if(tempstackLevelInt < stackLevelInt)
- {
- if(ChargingProfileAdded == FALSE)
- {
- fprintf(outfile,"%s\n",payload);
- ChargingProfileAdded = TRUE;
- fprintf(outfile,"%s\n",buf);
- }
- else
- {
- fprintf(outfile,"%s\n",buf);
- }
- }
- else
- {
- if(ChargingProfileAdded == FALSE)
- {
- fprintf(outfile,"%s\n",buf);
- fprintf(outfile,"%s\n",payload);
- ChargingProfileAdded = TRUE;
- }
- else
- {
- fprintf(outfile,"%s\n",buf);
- }
- }
- }
- }
- else
- {
- if(tempchargingProfileIdInt < chargingProfileIdInt)
- {
- if(ChargingProfileAdded == FALSE)
- {
- fprintf(outfile,"%s\n",payload);
- ChargingProfileAdded = TRUE;
- fprintf(outfile,"%s\n",buf);
- }
- else
- {
- fprintf(outfile,"%s\n",buf);
- }
- }
- else if(tempstackLevelInt < stackLevelInt)
- {
- if(ChargingProfileAdded == FALSE)
- {
- fprintf(outfile,"%s\n",payload);
- ChargingProfileAdded = TRUE;
- fprintf(outfile,"%s\n",buf);
- }
- else
- {
- fprintf(outfile,"%s\n",buf);
- }
- }
- else
- {
- if(ChargingProfileAdded == FALSE)
- {
- fprintf(outfile,"%s\n",buf);
- fprintf(outfile,"%s\n",payload);
- ChargingProfileAdded = TRUE;
- }
- else
- {
- fprintf(outfile,"%s\n",buf);
- }
- }
- }
- } // end of while loop
- fclose(infile);
- fclose(outfile);
- sprintf(rmFileCmd,"rm -f %s",filename);
- system(rmFileCmd);
- rename(tempfile, filename);
- #if 0
- resultRename = rename(tempfile, filename);
- if(resultRename == 0)
- {
- DEBUG_INFO("File chargingProfile renamed successfully");
- }
- else
- {
- DEBUG_INFO("Error: unable to rename the chargingProfile file");
- }
- #endif
- result = TRUE;
- sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Accepted] );
- }
- end:
- sendSetChargingProfileConfirmation(uuid, comfirmstr);
- return result;
- return result;
- }
- int handleTriggerMessageRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- int connectorIdIsNULL = FALSE;
- int connectorIdInt =0;
- char sstr[40]={0};
- char requestedMessagestr[40]={0};
- char comfirmstr[20]={0};
- int c = 0;
- char *loc;
- DEBUG_INFO("handleTriggerMessageRequest\n");
- //[2,"266e23f4-27a4-41cf-84cb-aadf56b9523f","TriggerMessage",{"requestedMessage":"DiagnosticsStatusNotification","connectorId":1}]
- c = 0;
- loc = strstr(payload, "requestedMessage");
- while (loc[3+strlen("requestedMessage")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("requestedMessage")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(requestedMessagestr, sstr);
- c = 0;
- loc = strstr(payload, "connectorId");
- if(loc == NULL)
- {
- connectorIdIsNULL = TRUE;
- }
- else
- {
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("connectorId")+2+c] != ',')&&(loc[strlen("connectorId")+2+c] != '}'))
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- connectorIdInt = atoi(sstr);
- }
- if(connectorIdIsNULL == FALSE && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ )))
- {
- //connectorIdInt = json_object_get_int(connectorId);
- sprintf((char *)ShmOCPP16Data->TriggerMessage[connectorIdInt -1].RequestedMessage, "%s" ,requestedMessagestr);
- ShmOCPP16Data->TriggerMessage[connectorIdInt -1].ConnectorId = connectorIdInt;
- //ShmOCPP16Data->CsMsg.bits[connectorIdInt -1].TriggerMessageReq = 1;
- sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Accepted] );
- sendTriggerMessageConfirmation(uuid,comfirmstr);
- }
- else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
- {
- sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Rejected] );
- sendTriggerMessageConfirmation(uuid,comfirmstr);
- return TRUE;
- }
- if((strcmp(requestedMessagestr, MessageTriggerStr[FirmwareStatusNotification]) != 0) &&
- (strcmp(requestedMessagestr, MessageTriggerStr[DiagnosticsStatusNotification]) != 0) &&
- (strcmp(requestedMessagestr, MessageTriggerStr[BootNotification]) != 0 ) &&
- (strcmp(requestedMessagestr, MessageTriggerStr[Heartbeat]) != 0) &&
- (strcmp(requestedMessagestr, MessageTriggerStr[MeterValues]) != 0) &&
- (strcmp(requestedMessagestr, MessageTriggerStr[StatusNotification]) != 0 ))
- {
- sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_NotImplemented] );
- sendTriggerMessageConfirmation(uuid,comfirmstr);
- return TRUE;
- }
- else
- {
- sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Accepted] );
- sendTriggerMessageConfirmation(uuid,comfirmstr);
- }
- if( strcmp(requestedMessagestr, MessageTriggerStr[FirmwareStatusNotification]) == 0)
- {
- if((FirmwareStatusNotificationStatus != 2) && (FirmwareStatusNotificationStatus != 3) && (FirmwareStatusNotificationStatus != 5) )
- {
- FirmwareStatusNotificationStatus = 3;
- }
- sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatusNotificationStatus]);
- //sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Accepted] );
- }
- else if(strcmp(requestedMessagestr, MessageTriggerStr[DiagnosticsStatusNotification]) == 0 )
- {
- //printf("DiagnosticsStatusStr[DiagnosticsStatus_Idle] =%s\n",DiagnosticsStatusStr[DiagnosticsStatus_Idle]);
- sendDiagnosticsStatusNotificationRequest(DiagnosticsStatusStr[DiagnosticsStatusNotificationStatus]);
- //sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Accepted] );
- }
- else if(strcmp(requestedMessagestr, MessageTriggerStr[BootNotification]) == 0 )
- {
- sendBootNotificationRequest();
- //sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Accepted] );
- }
- else if(strcmp(requestedMessagestr, MessageTriggerStr[Heartbeat]) == 0 )
- {
- sendHeartbeatRequest(connectorIdInt);
- //sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Accepted] );
- }
- else if (strcmp(requestedMessagestr, MessageTriggerStr[MeterValues]) == 0 )
- {
- if(connectorIdIsNULL == FALSE)
- {
- if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
- {
- ShmOCPP16Data->CsMsg.bits[connectorIdInt -1].TriggerMessageReq = 1;
- sendMeterValuesRequest(connectorIdInt -1);
- //sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Accepted] );
- }
- }
- else
- {
- for(int idx=0;idx< gunTotalNumber;idx++)
- {
- ShmOCPP16Data->CsMsg.bits[idx].TriggerMessageReq = 1;
- sendMeterValuesRequest(idx);
- }
- }
- }
- else if(strcmp(requestedMessagestr, MessageTriggerStr[StatusNotification]) == 0 )
- {
- if(connectorIdIsNULL == FALSE)
- {
- if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
- {
- sendStatusNotificationRequest(connectorIdInt -1);
- //sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Accepted] );
- }
- }
- else
- {
- for(int idx=0;idx< gunTotalNumber;idx++)
- sendStatusNotificationRequest(idx);
- //sprintf(comfirmstr, "%s",TriggerMessageStatusStr[TriggerMessageStatus_Accepted] );
- }
- }
- return result;
- }
- int handleUnlockConnectorRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- char sstr[6]={0};
- int connectorIdInt =0;
- char comfirmstr[20]={0};
- int c = 0;
- char *loc;
- //[2,"ba1cbd49-2a76-493a-8f76-fa23e7606532","UnlockConnector",{"connectorId":1}]
- DEBUG_INFO("handleUnlockConnectorRequest ...\n");
- c = 0;
- loc = strstr(payload, "connectorId");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != '}')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- connectorIdInt = atoi(sstr);
- DEBUG_INFO("\n unlock connectorIdInt=%d\n",connectorIdInt);
- if(gunTotalNumber == 0)
- {
- sprintf(comfirmstr, "%s", UnlockStatusStr[UnlockStatus_NotSupported] );
- goto end;
- }
- else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
- {
- //sprintf(comfirmstr, "%s", UnlockStatusStr[UnlockStatus_NotSupported] );
- sprintf(comfirmstr, "%s", UnlockStatusStr[UnlockStatus_NotSupported] );
- goto end;
- }
- else
- {
- //check Transaction active
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == (connectorIdInt-1) ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
- {
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = 1;
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == (connectorIdInt-1) ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
- {
- //stop Transaction
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = 1;
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == (connectorIdInt-1) ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
- {
- //stop Transaction
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = 1;
- }
- }
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == (connectorIdInt-1) ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
- {
- ShmOCPP16Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = 1;
- }
- }
- }// END FOR AC ELSE
- ShmOCPP16Data->UnlockConnector[connectorIdInt-1].ConnectorId = connectorIdInt;
- strcpy((char *)ShmOCPP16Data->UnlockConnector[connectorIdInt-1].guid, uuid);
- result = TRUE;
- return result;
- }
- end:
- //json_object_put(obj); --- remove temporally
- sendUnlockConnectorConfirmation(uuid, comfirmstr);
- return result;
- }
- static char UpdateFirmwarepayloadData[300]={0};
- int handleUpdateFirmwareRequest(char *uuid, char *payload)
- {
- mtrace();
- int result = FAIL;
- pthread_t t;
- sendUpdateFirmwareConfirmation(uuid);
- memset(UpdateFirmwarepayloadData, 0, 300);
- strcpy(UpdateFirmwarepayloadData, payload);
- pthread_create(&t, NULL, UpdateFirmwareProcess, payload);
- ////pthread_join(t, NULL); //
- //pthread_detach(t);
- //sendUpdateFirmwareConfirmation(uuid);
- ShmOCPP16Data->MsMsg.bits.UpdateFirmwareConf =1;
- //ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = 1;
- return result;
- }
- void *UpdateFirmwareProcess(void *data)
- {
- pthread_detach(pthread_self());
- mtrace();
- int retriesInt =0, retryIntervalInt=0;
- char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
- int port=0;
- char locationstr[160]={0}, retrieveDatestr[30]={0};
- //char fname[50]="00000_2018-09-07 160902_CSULog.zip";
- //char comfirmstr[20];
- int isSuccess = 0;
- char ftpbuf[200];
- char temp[100];
- char * pch;
- int retriesISNULL=FALSE;
- int retryInterval=FALSE;
- int c = 0;
- //int i = 0;
- char *loc;
- char sstr[300]={ 0 };
- char str[300]={ 0 };
- //char *str = (char*) data; // ? ?輸入資 ?
- DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
- //DEBUG_INFO("packet=%s\n", (const char*)payloadData);
- strcpy(str,(const char*)UpdateFirmwarepayloadData);
- //***************location **************/
- loc = strstr(str, "location");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("location")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("location")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(locationstr, sstr);
- //***************retries**************/
- c = 0;
- loc = strstr(str, "retries");
- if(loc == NULL)
- {
- retriesISNULL=TRUE;
- }
- else
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("retries")+2+c] != ',')
- {
- sstr[c] = loc[strlen("retries")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- }
- if(retriesISNULL == FALSE)
- {
- retriesInt = atoi(sstr);
- }
- //***************retrieveDate **************/
- loc = strstr(str, "retrieveDate");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("retrieveDate")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("retrieveDate")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(retrieveDatestr, sstr);
- //***************retryInterval **************/
- c = 0;
- loc = strstr(str, "retryInterval");
- memset(sstr ,0, sizeof(sstr) );
- if(loc == NULL)
- {
- retryInterval=TRUE;
- }
- else
- {
- while ((loc[strlen("retryInterval")+2+c] != ',') && (loc[strlen("retryInterval")+2+c] != '}'))
- {
- sstr[c] = loc[strlen("retryInterval")+2+c];
- //DEBUG_INFO("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- }
- if(retryInterval==FALSE)
- {
- retryIntervalInt = atoi(sstr);
- }
- memset(ftppath, 0, sizeof(ftppath));
- memset(path, 0, sizeof(path));
- sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_Downloading]);
- ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = 1;
- if(strncmp(locationstr,"http", 4) == 0)
- {
- sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]",
- protocol, host, path);
- //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
- // protocol, user, password, host, path);
- sprintf(ftppath,"/%s", path);
- //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, sizeof(filenametemp));
- strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
- filenametemp[i+1] = 0;
- //sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_Downloading]);
- do{
- isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
- sleep(retryIntervalInt);
- }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
- // isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
- if(!isSuccess)
- {
- sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
- }
- else
- {
- //ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = 1;
- sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_Downloaded]);
- isUpdateRequest = TRUE;
- }
- }
- else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
- {
- memset(ftpbuf, 0, sizeof(ftpbuf));
- memset(temp, 0, sizeof(temp));
- //DEBUG_INFO("locationstr=%s\n",locationstr);
- strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
- 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, sizeof(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);
- //DEBUG_INFO("protocol =%s\n",protocol);
- //DEBUG_INFO("user =%s\n",user);
- //DEBUG_INFO("password =%s\n",password);
- //DEBUG_INFO("host1 =%s\n",host1);
- //DEBUG_INFO("port =%d\n",port);
- //DEBUG_INFO("path1 =%s\n",path1);
- //DEBUG_INFO("ftppath=%s\n",ftppath);
- //ftpFile(host, user, password, port, ftppath, fname);
- //download firmware pthred
- if(port == 0)
- {
- port = 21;
- }
- //sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_Downloading]);
- do{
- isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
- sleep(retryIntervalInt);
- }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
- if(!isSuccess)
- {
- //BulldogUtil.sleepMs(interval*1000);
- DEBUG_INFO("Update firmware request and download file fail.\n");
- sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
- }
- else
- {
- //ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = 1;
- sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_Downloaded]);
- isUpdateRequest = TRUE;
- }
- ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = 1;
- }
- else
- {
- sendFirmwareStatusNotificationRequest(FirmwareStatusStr[FirmwareStatus_DownloadFailed]);
- //ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = 1;
- }
- pthread_exit(NULL);
- }
- //==========================================
- // Handle server response routine
- //==========================================
- void handleAuthorizeResponse(char *payload, int gun_index)
- {
- mtrace();
- char expiryDatestr[30]={0};
- char parentIdTagstr[20]={0};
- char statusstr[20]={0};
- char expiryDatestrtemp[30]={0};
- char parentIdTagstrtemp[20]={0};
- char IdTagstrtemp[20]={0};
- char statusstrtemp[20]={0};
- int expiryDateISNULL=FALSE;
- int parentIdTagISNULL=FALSE;
- char sstr[160]={ 0 };
- char* filename = AuthorizationCache_JSON;
- char tempfile[] = "/Storage/OCPP/temp.json";
- int c = 0;
- char *loc;
- int resultRename=0;
- int responseIdTagInfoAsZero= 0;
- char rmFileCmd[50]={0};
- DEBUG_INFO("handleAuthorizeResponse ...\n");
- //***********expiryDate*************/
- loc = strstr(payload, "expiryDate");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- if(loc == NULL)
- {
- expiryDateISNULL = TRUE;
- }
- else
- {
- while ((loc != NULL)&&(loc[3+strlen("expiryDate")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("expiryDate")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(expiryDatestr, sstr);
- }
- //***********parentIdTag*************/
- loc = strstr(payload, "parentIdTag");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- if(loc == NULL)
- {
- parentIdTagISNULL = TRUE;
- }
- else
- {
- while ((loc != NULL)&&(loc[3+strlen("parentIdTag")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("parentIdTag")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(parentIdTagstr, sstr);
- }
- //***********status*************/
- loc = strstr(payload, "status");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("status")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("status")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(statusstr, sstr);
- if(expiryDateISNULL == FALSE)
- strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ExpiryDate, expiryDatestr);
- if(parentIdTagISNULL == FALSE)
- strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag, parentIdTagstr);
- strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, statusstr);
- //Update idTag information to authorization cache if supproted
- if((strcmp((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemData, "TRUE") == 0) && (ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag != NULL) && (ShmOCPP16Data->Authorize.ResponseIdTagInfo.ExpiryDate != NULL) )
- {
- if((access(filename,F_OK))!=-1)
- {
- printf("AuthorizationCache exist.\n");
- }
- else
- {
- printf("AuthorizationCache not exist\n");
- FILE *log = fopen(filename, "w+");
- if(log == NULL)
- {
- printf("log is NULL\n");
- goto out;
- }
- else
- {
- fclose(log);
- }
- }
- FILE *infile;
- FILE *outfile;
- // open file for writing
- infile = fopen (filename, "r");
- outfile = fopen (tempfile, "w");
- //*检测到文件结束标识返回1,否则返回0。*/
- //DEBUG_INFO("feof(infile) =%d\n",feof(infile));
- int c;
- c = fgetc(infile);
- //DEBUG_INFO("c:%d\n",c);
- rewind(infile);
- if(c == EOF)
- {
- DEBUG_INFO("Orignal File is NULL\n");
- if(ShmOCPP16Data->Authorize.ResponseIdTagInfo.ExpiryDate != NULL)
- {
- strcpy(expiryDatestrtemp, (const char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ExpiryDate);
- }
- else
- {
- strcpy(expiryDatestrtemp, "");
- }
- if(ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag != NULL)
- {
- strcpy(parentIdTagstrtemp, (const char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag);
- }
- else
- {
- //write Authorize IdTag
- strcpy(parentIdTagstrtemp, (const char *)ShmOCPP16Data->Authorize.IdTag);
- }
- strcpy(statusstrtemp, (const char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status);
- fprintf(outfile,"[{\"idTag\":\"%s\",\"idTagInfo\":{\"expiryDate\":\"%s\",\"parentIdTag\":\"%s\",\"status\":\"%s\"}}]\n",ShmOCPP16Data->Authorize.IdTag, expiryDatestrtemp, parentIdTagstrtemp, statusstrtemp);
- fclose(infile);
- fclose(outfile);
- sprintf(rmFileCmd,"rm -f %s",filename);
- system(rmFileCmd);
- resultRename = rename(tempfile, filename);
- if(resultRename == 0)
- {
- printf("File renamed successfully");
- }
- else
- {
- printf("Error: unable to rename the file");
- }
- }
- else
- {
- char buf[160]={0};
- while (fgets(buf, sizeof(buf), infile) != NULL)
- {
- buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
- memset(expiryDatestr, 0, sizeof(expiryDatestrtemp));
- memset(parentIdTagstr,0, sizeof(parentIdTagstrtemp));
- memset(statusstr, 0, sizeof(statusstrtemp));
- memset(IdTagstrtemp, 0, sizeof(IdTagstrtemp));
- memset(expiryDatestrtemp, 0, sizeof(expiryDatestrtemp));
- memset(parentIdTagstrtemp, 0, sizeof(parentIdTagstrtemp));
- memset(statusstrtemp, 0, sizeof(statusstrtemp));
- //------------------IdTag-----------------------
- loc = strstr(buf, "idTag");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("idTag")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("idTag")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(IdTagstrtemp,sstr);
- //*********************expiryDate***************/
- loc = strstr(buf, "expiryDate");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("expiryDate")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("expiryDate")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(expiryDatestr,sstr);
- //*********************parentIdTag***************/
- loc = strstr(buf, "parentIdTag");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("parentIdTag")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("parentIdTag")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(parentIdTagstr,sstr);
- //*********************status***************/
- loc = strstr(buf, "status");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("status")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("status")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(statusstr,sstr);
- if(((ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag == NULL) || strcmp((const char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag, "") == 0) || (strcmp((const char *)ShmOCPP16Data->Authorize.IdTag, IdTagstrtemp) == 0))
- {
- DEBUG_INFO("ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag is NULL\n");
- responseIdTagInfoAsZero = 1;
- }
- else
- {
- DEBUG_INFO("ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag=%s\n",ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag);
- }
- if((responseIdTagInfoAsZero == 0)&&((strcmp(parentIdTagstr,(const char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag) == 0)|| (strcmp(IdTagstrtemp,(const char *)ShmOCPP16Data->Authorize.IdTag) == 0)))
- {
- //modify item
- if(ShmOCPP16Data->Authorize.ResponseIdTagInfo.ExpiryDate != NULL)
- {
- strcpy(expiryDatestrtemp,(const char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ExpiryDate);
- }
- else
- {
- strcpy(expiryDatestrtemp, "");
- }
- if(ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag != NULL)
- {
- strcpy(parentIdTagstrtemp,(const char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag);
- }
- else
- {
- strcpy(parentIdTagstrtemp, parentIdTagstr);
- }
- strcpy(statusstrtemp,(const char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status);
- }
- else
- {
- //wrie original item
- strcpy(expiryDatestrtemp, expiryDatestr);
- strcpy(parentIdTagstrtemp, parentIdTagstr);
- strcpy(statusstrtemp, statusstr);
- }
- fprintf(outfile,"[{\"idTag\":\"%s\",\"idTagInfo\":{\"expiryDate\":\"%s\",\"parentIdTag\":\"%s\",\"status\":\"%s\"}}]\n",ShmOCPP16Data->Authorize.IdTag, expiryDatestrtemp, parentIdTagstrtemp, statusstrtemp);
- }
- fclose(infile);
- fclose(outfile);
- sprintf(rmFileCmd,"rm -f %s",filename);
- system(rmFileCmd);
- resultRename = rename(tempfile, filename);
- if(resultRename == 0)
- {
- DEBUG_INFO("File renamed successfully");
- }
- else
- {
- DEBUG_INFO("Error: unable to rename the file");
- }
- }
- }
- out:
- ShmOCPP16Data->SpMsg.bits.AuthorizeReq = 0;
- ShmOCPP16Data->SpMsg.bits.AuthorizeConf = 1; // inform csu
- authorizeRetryTimes = 0;
- }
- void handleBootNotificationResponse(char *payload, int gun_index)
- {
- mtrace();
- char sstr[140]={ 0 };//sstr[200]={ 0 };
- char statusStr[12]={0};
- char currentTimeStr[30]={0};
- char *loc;
- int intervalInt = 0;
- int c = 0;
- //double diff_t;
- struct tm tp;
- char buf[28]={0};
- char timebuf[50]={0};
- DEBUG_INFO("handleBootNotificationResponse ...\n");
- //*** interval ****/
- c = 0;
- loc = strstr(payload, "interval");
- //printf("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- while ((loc != NULL) &&(loc[strlen("interval")+2+c] != ',') &&(loc[strlen("interval")+2+c] != '}') )
- {
- sstr[c] = loc[strlen("interval")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- //DEBUG_INFO("id=%d\n",atoi(sstr));
- intervalInt = atoi(sstr);
- //***status ****/
- loc = strstr(payload, "status");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while ((loc != NULL) &&(loc[3+strlen("status")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("status")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(statusStr, sstr);
- //***currentTime ****/
- loc = strstr(payload, "currentTime");
- //printf("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while ((loc != NULL) &&(loc[3+strlen("currentTime")+c] != '\"'))
- {
- sstr[c] = loc[3+strlen("currentTime")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(currentTimeStr, sstr);
- BootNotificationInterval = ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval = intervalInt;
- HeartBeatWaitTime = BootNotificationInterval;
- clientTime.Heartbeat=time((time_t*)NULL);
- //write back to ShmOCPP16Data->BootNotification
- strcpy((char *)ShmOCPP16Data->BootNotification.ResponseCurrentTime, currentTimeStr);
- ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval = intervalInt;
- strcpy((char *)ShmOCPP16Data->BootNotification.ResponseStatus, statusStr);
- if((strcmp(statusStr, RegistrationStatusStr[RegistrationStatus_Accepted]) == 0 )/* ||
- (strcmp(status, RegistrationStatusStr[RegistrationStatus_Pending]) == 0) ||
- (strcmp(status, RegistrationStatusStr[RegistrationStatus_Rejected]) == 0)*/)
- {
- server_sign = TRUE;
- server_pending =FALSE;
- }
- else if(strcmp(statusStr, RegistrationStatusStr[RegistrationStatus_Pending]) == 0)
- {
- server_pending = TRUE;
- }
- strptime((const char *)ShmOCPP16Data->BootNotification.ResponseCurrentTime, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- //time_t utc = mktime(&tp);
- strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
- memset(timebuf, 0, sizeof timebuf);
- sprintf(timebuf,"date -s '%s'",buf);
- //DEBUG_INFO("timebuf=%s\n",timebuf);
- system(timebuf);
- //==============================================
- // RTC sync
- //==============================================
- system("/sbin/hwclock -w --systohc");
- ShmOCPP16Data->OcppConnStatus = 1; ////0: disconnected, 1: connected
- ShmOCPP16Data->SpMsg.bits.BootNotificationConf = 1;
- }
- void handleDataTransferResponse(char *payload, int gun_index)
- {
- char sstr[160]={0};//sstr[200]={ 0 };
- int c = 0;
- char *loc;
- DEBUG_INFO("handleDataTransferResponse ...\n");
- loc = strstr(payload, "status");
- printf("loc=%s\n",loc);
- c = 0;
- while (loc[3+strlen("status")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("status")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- DEBUG_INFO(" DataTransferResponse=%s\n", sstr);
- }
- void handleDiagnosticsStatusNotificationResponse(char *payload, int gun_index)
- {
- DEBUG_INFO("handleDiagnosticsStatusNotificationResponse ...\n");
- //struct json_object *obj;
- // obj = json_tokener_parse(payload);
- ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationReq = 0;
- ShmOCPP16Data->SpMsg.bits.DiagnosticsStatusNotificationConf = 1;
- //No fields are defined.
- }
- void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
- {
- DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
- //struct json_object *obj;
- // obj = json_tokener_parse(payload);
- ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = 0;
- ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationConf = 1;
- //No fields are defined.
- }
- void handleHeartbeatResponse(char *payload, int gun_index)
- {
- mtrace();
- //double diff_t;
- struct tm tp;
- char buf[28]={0};
- char timebuf[50]={0};
- char sstr[30]={ 0 };
- int c = 0;
- char *loc;
- //[3,"9c2e3c41-ab34-409e-8902-f5f48b6de641",{"currentTime":"2018-09-06T02:22:57.171Z"}]
- if((HeartBeatCount%360) == 0)
- {
- DEBUG_INFO("handleHeartbeatResponse ...\n");
- DEBUG_INFO("After 1 hour, It will print out Heartbeat.\n");
- }
- HeartBeatCount = HeartBeatCount + 1;
- c = 0;
- loc = strstr(payload, "currentTime");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("currentTime")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("currentTime")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy((char *)ShmOCPP16Data->Heartbeat.ResponseCurrentTime,sstr);
- // #ifdef SystemLogMessage
- // DEBUG_INFO("currentTime: %s\n", ShmOCPP16Data->Heartbeat.ResponseCurrentTime);
- // #endif
- strptime((const char *)ShmOCPP16Data->Heartbeat.ResponseCurrentTime, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- //time_t utc = mktime(&tp);
- strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
- memset(timebuf, 0, sizeof timebuf);
- sprintf(timebuf,"date -s '%s'",buf);
- system(timebuf);
- //==============================================
- // RTC sync
- //==============================================
- system("/sbin/hwclock -w --systohc");
- if(FirstHeartBeat == 0)
- {
- FirstHeartBeat = 1;
- }
- HeartBeatWithNOResponse = 0;
- }
- void handleMeterValuesResponse(char *payload, int gun_index)
- {
- mtrace();
- //struct json_object *obj;
- DEBUG_INFO("handleMeterValuesResponse ...\n");
- //No fields are defined.
- }
- void handleStartTransactionResponse(char *payload, int gun_index)
- {
- mtrace();
- char sstr[28]={ 0 };
- int c = 0;
- char *loc;
- int transactionIdInt = 0;
- //[3,"f7da35db-9d9b-4362-841f-26424be1064f",{"idTagInfo":{"expiryDate":"2020-06-19T01:10:00.000Z","parentIdTag":"1UF1YvGvmNbLF17sP6LY","status":"Accepted"},"transactionId":2146754131}]
- DEBUG_INFO("handleStartTransactionResponse\n");
- //****************expiryDate********************/
- loc = strstr(payload, "expiryDate");
- if(loc == NULL)
- {
- strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ExpiryDate, "");
- }
- else
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("expiryDate")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("expiryDate")+c];
- c++;
- }
- sstr[c] = '\0';
- sprintf((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ExpiryDate, "%s", sstr);
- }
- //****************parentIdTag********************/
- loc = strstr(payload, "parentIdTag");
- if(loc == NULL)
- {
- strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ParentIdTag, "");
- }
- else
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("parentIdTag")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("parentIdTag")+c];
- c++;
- }
- sstr[c] = '\0';
- sprintf((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ParentIdTag, "%s", sstr);
- }
- //****************status********************/
- loc = strstr(payload, "status");
- if(loc == NULL)
- {
- strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "");
- }
- else
- {
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("status")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("status")+c];
- c++;
- }
- sstr[c] = '\0';
- sprintf((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "%s", sstr);
- }
- //****************transactionId********************/
- c=0;
- loc = strstr(payload, "transactionId");
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[strlen("transactionId")+2+c] != '}') && (loc[strlen("transactionId")+2+c] != ','))
- {
- sstr[c] = loc[strlen("transactionId")+2+c];
- c++;
- }
- sstr[c] = '\0';
- ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId = atoi(sstr);
- transactionIdInt = ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId;
- TransactionId[gun_index] = transactionIdInt;
- DEBUG_INFO("gun_index: %d\n", gun_index);
- DEBUG_INFO("test TransactionId[gun_index]: %d\n", TransactionId[gun_index]);
- ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf = 1;
- ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq = 0;
- #ifdef SystemLogMessage
- DEBUG_INFO("idTagInfo-expiryDate: %s\n", ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ExpiryDate);
- DEBUG_INFO("idTagInfo-parentIdTag: %s\n", ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.ParentIdTag);
- DEBUG_INFO("idTagInfo-status: %s\n", ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status);
- DEBUG_INFO("transactionId: %d\n", ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId);
- #endif
- if(strcmp((const char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Accepted") == 0)
- {
- //add Charging Record
- SettingChargingRecord(gun_index, transactionIdInt);
- }
- //DEBUG_INFO("Start Charging ErrorCode=%s\n", ShmOCPP16Data->StatusNotification[gun_index].ErrorCode);
- }
- void handleStatusNotificationResponse(char *payload, int gun_index)
- {
- mtrace();
- printf("handleStatusNotificationResponse\n");
- cpinitateMsg.bits[gun_index].StatusNotificationReq = 0;
- cpinitateMsg.bits[gun_index].StatusNotificationConf = 1;
- }
- void handleStopTransactionnResponse(char *payload, int gun_index)
- {
- mtrace();
- char sstr[30]={ 0 };
- int c = 0;
- char *loc;
- //[3,"e79c0728-dd4c-4038-a90e-bb0eb23e1ee0",{"idTagInfo":{"expiryDate":"2020-06-19T01:10:00.000Z","parentIdTag":"1UF1YvGvmNbLF17sP6LY","status":"Accepted"}}]
- ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionConf = 1;
- ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq = 0;
- loc = strstr(payload, "idTagInfo");
- //***********************idTagInfo************************/
- if(loc != NULL)
- {
- //***********************expiryDate************************/
- loc = strstr(payload, "expiryDate");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("expiryDate")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("expiryDate")+c];
- c++;
- }
- sstr[c] = '\0';
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].ResponseIdTagInfo.ExpiryDate, "%s", sstr);
- }
- //***********************parentIdTag************************/
- loc = strstr(payload, "parentIdTag");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("parentIdTag")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("parentIdTag")+c];
- c++;
- }
- sstr[c] = '\0';
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].ResponseIdTagInfo.ParentIdTag, "%s", sstr);
- }
- //***********************status************************/
- loc = strstr(payload, "status");
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen("status")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("status")+c];
- c++;
- }
- sstr[c] = '\0';
- sprintf((char *)ShmOCPP16Data->StopTransaction[gun_index].ResponseIdTagInfo.Status, "%s", sstr);
- }
- #ifdef SystemLogMessage
- DEBUG_INFO("idTagInfo-expiryDate: %s\n", ShmOCPP16Data->StopTransaction[gun_index].ResponseIdTagInfo.ExpiryDate);
- DEBUG_INFO("idTagInfo-parentIdTag: %s\n", ShmOCPP16Data->StopTransaction[gun_index].ResponseIdTagInfo.ParentIdTag);
- DEBUG_INFO("idTagInfo-status: %s\n", ShmOCPP16Data->StopTransaction[gun_index].ResponseIdTagInfo.Status);
- #endif
- }
- //==========================================
- // 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)
- {
- FILE *fp;
- FILE *outfile;
- char str[200]={0};
- char sstr[100]={0};
- int c = 0;
- char *loc;
- printf("initialConfigurationTable \n");
- memset(&(ShmOCPP16Data->ConfigurationTable), 0, sizeof(struct OCPP16ConfigurationTable) );
- if((access("/Storage/OCPP/OCPPConfiguration",F_OK))==-1)
- {
- outfile = fopen("/Storage/OCPP/OCPPConfiguration" , "w+");
- if(outfile == NULL) {
- DEBUG_INFO("Error opening file");
- return FALSE;
- }
- /*Core Profile*/
- //AllowOfflineTxForUnknownId
- ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemAccessibility = 1;
- printf("AllowoddlineTXForUnknownId type: %d \n", ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemAccessibility);
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemName, "AllowOfflineTxForUnknownId");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData, "TRUE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","AllowOfflineTxForUnknownId", "false", "TRUE");
- //AuthorizationCacheEnabled
- ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemName, "AuthorizationCacheEnabled");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemData, "FALSE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","AuthorizationCacheEnabled", "false", "FALSE");
- //AuthorizeRemoteTxRequests
- ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemName, "AuthorizeRemoteTxRequests");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemData, "TRUE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","AuthorizeRemoteTxRequests", "true", "TRUE");
- //BlinkRepeat
- ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemName, "BlinkRepeat");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemData, "0" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","BlinkRepeat", "false", "0");
- //ClockAlignedDataInterval
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemName, "ClockAlignedDataInterval");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData, "0" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ClockAlignedDataInterval", "false", "0");
- //ConnectionTimeOut
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemName, "ConnectionTimeOut");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData, "180" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ConnectionTimeOut", "false", "180");
- //GetConfigurationMaxKeys
- ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemAccessibility =0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemName, "GetConfigurationMaxKeys");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemData, "43" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","GetConfigurationMaxKeys", "true", "43");
- // HeartbeatInterval
- ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemName, "HeartbeatInterval");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemData, "10" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","HeartbeatInterval", "false", "10");
- // LightIntensity
- ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemName, "LightIntensity");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemData, "0" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","LightIntensity", "false", "0");
- // LocalAuthorizeOffline
- ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemName, "LocalAuthorizeOffline");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemData, "TRUE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","LocalAuthorizeOffline", "true", "TRUE");
- // LocalPreAuthorize
- ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemName, "LocalPreAuthorize");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemData, "FALSE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","LocalPreAuthorize", "true", "FALSE");
- // MaxEnergyOnInvalidId
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemName, "MaxEnergyOnInvalidId");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemData, "0" );
- ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = 0;
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MaxEnergyOnInvalidId", "false", "0");
- // MeterValuesAlignedData
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemName, "MeterValuesAlignedData");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemData, "Current.Export,Energy.Active.Export.Interval,Power.Active.Export,Voltage,SOC" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MeterValuesAlignedData", "false", "Current.Export,Energy.Active.Export.Interval,Power.Active.Export,Voltage,SOC");
- // MeterValuesAlignedDataMaxLength
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemName, "MeterValuesAlignedDataMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemData, "5" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MeterValuesAlignedDataMaxLength", "true", "5");
- // MeterValuesSampledData
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemName, "MeterValuesSampledData");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemData, "Current.Export,Energy.Active.Export.Interval,Power.Active.Export,Voltage,SOC" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MeterValuesSampledData", "false", "Current.Export,Energy.Active.Export.Interval,Power.Active.Export,Voltage,SOC");
- // MeterValuesSampledDataMaxLength
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemName, "MeterValuesSampledDataMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemData, "5" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MeterValuesSampledDataMaxLength", "true", "5");
- // MeterValueSampleInterval
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemName, "MeterValueSampleInterval");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData, "10" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MeterValueSampleInterval", "false", "10");
- // MinimumStatusDuration
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemName, "MinimumStatusDuration");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemData, "0" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MinimumStatusDuration", "false", "0");
- // NumberOfConnectors
- ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemName, "NumberOfConnectors");
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData, "%d", (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY));
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData, "%d", AC_QUANTITY);
- }
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","NumberOfConnectors", "true", ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData);
- // ResetRetries
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemName, "ResetRetries");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemData, "3" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ResetRetries", "false", "3");
- // ConnectorPhaseRotation
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemName, "ConnectorPhaseRotation");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "NotApplicable" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ConnectorPhaseRotation", "false", "NotApplicable");
- // ConnectorPhaseRotationMaxLength
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemName, "ConnectorPhaseRotationMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemData, "1" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ConnectorPhaseRotationMaxLength", "true", "1");
- // StopTransactionOnEVSideDisconnect
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemName, "StopTransactionOnEVSideDisconnect");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemData, "TRUE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTransactionOnEVSideDisconnect", "true", "TRUE");
- // StopTransactionOnInvalidId
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemName, "StopTransactionOnInvalidId");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData, "FALSE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTransactionOnInvalidId", "false", "FALSE");
- // StopTxnAlignedData
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemName, "StopTxnAlignedData");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemData, "Energy.Active.Import.Register" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTxnAlignedData", "false", "Energy.Active.Import.Register");
- // StopTxnAlignedDataMaxLength
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemName, "StopTxnAlignedDataMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemData, "0" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTxnAlignedDataMaxLength", "true", "0");
- // StopTxnSampledData
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemName, "StopTxnSampledData");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemData, "Current.Export,Energy.Active.Export.Interval,Power.Active.Export,Voltage,SOC" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTxnSampledData", "false", "Current.Export,Energy.Active.Export.Interval,Power.Active.Export,Voltage,SOC");
- // StopTxnSampledDataMaxLength
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemName, "StopTxnSampledDataMaxLength");
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemData, "%d", 6);
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemData, "%d", 5);
- }
- //strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemData, "0" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTxnSampledDataMaxLength", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemData);
- // SupportedFeatureProfiles
- ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemName, "SupportedFeatureProfiles");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemData, "Core,FirmwareManagement,LocalAuthListManagement,Reservation,SmartCharging,RemoteTrigger" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","SupportedFeatureProfiles", "true", "Core,FirmwareManagement,LocalAuthListManagement,Reservation,SmartCharging,RemoteTrigger");
- // SupportedFeatureProfilesMaxLength
- ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemName, "SupportedFeatureProfilesMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemData, "6" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","SupportedFeatureProfilesMaxLength", "true", "6");
- // TransactionMessageAttempts
- ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemName, "TransactionMessageAttempts");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemData, "3" );
- TransactionMessageAttemptsValue = atoi((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemData);
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","TransactionMessageAttempts", "false", "3");
- // TransactionMessageRetryInterval
- ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemName, "TransactionMessageRetryInterval");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData, "60" );
- TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","TransactionMessageRetryInterval", "false", "60");
- // UnlockConnectorOnEVSideDisconnect
- ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemName, "UnlockConnectorOnEVSideDisconnect");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemData, "TRUE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","UnlockConnectorOnEVSideDisconnect", "true", "TRUE");
- // WebSocketPingInterval
- ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemName, "WebSocketPingInterval");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemData, "30" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","WebSocketPingInterval", "false", "30");
- //* Local Auth List Management Profile*/
- #if 0
- //For OCTT Test Case
- ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemName, "LocalAuthorizationListEnabled");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData, "TRUE" );
- #endif
- #if 1
- //LocalAuthListEnabled
- ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemName, "LocalAuthListEnabled");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData, "TRUE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","LocalAuthListEnabled", "false", "TRUE");
- #endif
- //LocalAuthListMaxLength
- ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemName, "LocalAuthListMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemData, "500" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","LocalAuthListMaxLength", "true", "500");
- //SendLocalListMaxLength
- ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemName, "SendLocalListMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemData, "500" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","SendLocalListMaxLength", "true", "500");
- //ReserveConnectorZeroSupported
- ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemName, "ReserveConnectorZeroSupported");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemData, "FALSE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ReserveConnectorZeroSupported", "true", "FALSE");
- //* Smart Charging Profile */
- //ChargeProfileMaxStackLevel
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemName, "ChargeProfileMaxStackLevel");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemData, "3" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ChargeProfileMaxStackLevel", "true", "3");
- // ChargingScheduleAllowedChargingRateUnit
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemName, "ChargingScheduleAllowedChargingRateUnit");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemData, "Current" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ChargingScheduleAllowedChargingRateUnit", "true", "Current");
- // ChargingScheduleMaxPeriods
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemName, "ChargingScheduleMaxPeriods");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemData, "10" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ChargingScheduleMaxPeriods", "true", "10");
- // ConnectorSwitch3to1PhaseSupported
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemName, "ConnectorSwitch3to1PhaseSupported");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemData, "TRUE" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ConnectorSwitch3to1PhaseSupported", "true", "TRUE");
- // MaxChargingProfilesInstalled
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemName, "MaxChargingProfilesInstalled");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData, "9" );
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MaxChargingProfilesInstalled", "true", "9");
- fclose(outfile);
- }
- else
- {
- //DEBUG_INFO("../Storage/OCPP/OCPPConfiguration EXit\n");
- char keystr[60]={0};
- char readonlystr[10]={0};
- char valuestr[100]={0};
- fp = fopen("/Storage/OCPP/OCPPConfiguration" , "r");
- if(fp == NULL) {
- DEBUG_INFO("Error opening file");
- return FALSE;
- }
- while( fgets (str, sizeof(str), fp)!=NULL )
- {
- str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
- //*************************key*********************************/
- loc = strstr(str, "key");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("key")+3+c] != '\"')
- {
- sstr[c] = loc[strlen("key")+3+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(keystr,sstr);
- //*************************readonly*********************************/
- loc = strstr(str, "readonly");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("readonly")+2+c] != ',')
- {
- sstr[c] = loc[strlen("readonly")+2+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(readonlystr,sstr);
- //*************************value*********************************/
- loc = strstr(str, "value");
- c = 0;
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("value")+3+c] != '\"')
- {
- sstr[c] = loc[strlen("value")+3+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(valuestr,sstr);
- // DEBUG_INFO("keystr=%s\n",keystr);
- // DEBUG_INFO("readonlystr=%s\n",readonlystr);
- // DEBUG_INFO("valuestr=%s\n",valuestr);
- if(strcmp(keystr, "AllowOfflineTxForUnknownId") == 0)
- {
- //Charger.AllowOfflineTxForUnknownId = (value.toLowerCase().equals("true")?true:false);
- ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData, "%s", valuestr );
- // DEBUG_INFO("AllowOfflineTxForUnknownId setting\n");
- // DEBUG_INFO("AllowOfflineTxForUnknownId setting\n");
- }
- if(strcmp(keystr, "AuthorizationCacheEnabled") == 0)
- {
- //Charger.AuthorizationCacheEnabled = (value.toLowerCase().equals("true")?true:false);
- ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "AuthorizeRemoteTxRequests") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "BlinkRepeat") == 0)
- {
- //Charger.BlinkRepeat = Integer.parseInt(value);
- ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "ClockAlignedDataInterval") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "ConnectionTimeOut") == 0 )
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData, "%d", atoi(valuestr));
- }
- if(strcmp(keystr, "GetConfigurationMaxKeys") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemData, "%d", atoi(valuestr));
- }
- if(strcmp(keystr, "HeartbeatInterval") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemData, "%d", atoi(valuestr));
- HeartBeatWaitTime = atoi(valuestr);
- }
- if(strcmp(keystr, "LightIntensity") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemData, "%d", atoi(valuestr));
- }
- if(strcmp(keystr, "LocalAuthorizeOffline") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "LocalPreAuthorize") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "MaxEnergyOnInvalidId") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemData, "%d", atoi(valuestr) );
- ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = atoi(valuestr)/1000;
- }
- if(strcmp(keystr, "MeterValuesAlignedData") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "MeterValuesAlignedDataMaxLength") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemData, "%d", atoi(valuestr));
- }
- if(strcmp(keystr, "MeterValuesSampledData") == 0 )
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "MeterValuesSampledDataMaxLength") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemData, "%d", atoi(valuestr));
- }
- if(strcmp(keystr, "MeterValueSampleInterval") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData, "%d", atoi(valuestr));
- }
- if(strcmp(keystr, "MinimumStatusDuration") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "NumberOfConnectors") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "ResetRetries") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "ConnectorPhaseRotation") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "ConnectorPhaseRotationMaxLength") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "StopTransactionOnEVSideDisconnect") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "StopTransactionOnInvalidId") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "StopTxnAlignedData") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "StopTxnAlignedDataMaxLength") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "StopTxnSampledData") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "StopTxnSampledDataMaxLength") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "SupportedFeatureProfiles") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "SupportedFeatureProfilesMaxLength") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "TransactionMessageAttempts") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemData, "%d", atoi(valuestr) );
- TransactionMessageAttemptsValue = atoi(valuestr);
- }
- if(strcmp(keystr, "TransactionMessageRetryInterval") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemAccessibility= (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData, "%d", atoi(valuestr) );
- TransactionMessageRetryIntervalValue = atoi(valuestr);
- }
- if(strcmp(keystr, "UnlockConnectorOnEVSideDisconnect") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "WebSocketPingInterval") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "LocalAuthListEnabled") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "LocalAuthListMaxLength") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "SendLocalListMaxLength") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "ReserveConnectorZeroSupported") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "ChargeProfileMaxStackLevel") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "ChargingScheduleAllowedChargingRateUnit") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemData, "%s", valuestr );
- }
- if(strcmp(keystr, "ChargingScheduleMaxPeriods") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemData, "%d", atoi(valuestr) );
- }
- if(strcmp(keystr, "ConnectorSwitch3to1PhaseSupported") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemData, "%s", valuestr);
- }
- if(strcmp(keystr, "MaxChargingProfilesInstalled") == 0)
- {
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData, "%d", atoi(valuestr) );
- }
- }
- fclose(fp);
- }
- return 0;
- }
- void StoreConfigurationTable(void)
- {
- FILE *outfile;
- outfile = fopen("/Storage/OCPP/OCPPConfiguration" , "w+");
- if(outfile == NULL)
- {
- DEBUG_INFO("Error opening file");
- return ;
- }
- /*Core Profile*/
- //AllowOfflineTxForUnknownId
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemAccessibility = 1;
- printf("AllowoddlineTXForUnknownId type: %d \n", ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemAccessibility);
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemName, "AllowOfflineTxForUnknownId");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData, "TRUE" );
- */
- //DEBUG_INFO("data=%s\n",data);
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","AllowOfflineTxForUnknownId", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData);
- //AuthorizationCacheEnabled
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemName, "AuthorizationCacheEnabled");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemData, "FALSE" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","AuthorizationCacheEnabled", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemData);
- //AuthorizeRemoteTxRequests
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemName, "AuthorizeRemoteTxRequests");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemData, "TRUE" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","AuthorizeRemoteTxRequests", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemData);
- //BlinkRepeat
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemName, "BlinkRepeat");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemData, "0" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","BlinkRepeat", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemData);
- //ClockAlignedDataInterval
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemName, "ClockAlignedDataInterval");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData, "0" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ClockAlignedDataInterval", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData);
- //ConnectionTimeOut
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemName, "ConnectionTimeOut");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData, "180" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ConnectionTimeOut", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData);
- //GetConfigurationMaxKeys
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemAccessibility =0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemName, "GetConfigurationMaxKeys");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemData, "43" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","GetConfigurationMaxKeys", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemData);
- // HeartbeatInterval
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemName, "HeartbeatInterval");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemData, "10" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","HeartbeatInterval", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemData);
- // LightIntensity
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemName, "LightIntensity");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemData, "0" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","LightIntensity", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemData);
- // LocalAuthorizeOffline
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemName, "LocalAuthorizeOffline");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemData, "TRUE" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","LocalAuthorizeOffline", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemData);
- // LocalPreAuthorize
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemName, "LocalPreAuthorize");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemData, "FALSE" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","LocalPreAuthorize", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemData);
- // MaxEnergyOnInvalidId
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemName, "MaxEnergyOnInvalidId");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemData, "0" );
- */
- //ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = 0;
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MaxEnergyOnInvalidId", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemData);
- // MeterValuesAlignedData
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemName, "MeterValuesAlignedData");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemData, "Current.Export,Energy.Active.Export.Interval,Power.Active.Export,Voltage,SOC" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MeterValuesAlignedData", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemData);
- // MeterValuesAlignedDataMaxLength
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemName, "MeterValuesAlignedDataMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemData, "5" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MeterValuesAlignedDataMaxLength", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemData);
- // MeterValuesSampledData
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemName, "MeterValuesSampledData");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemData, "Current.Export,Energy.Active.Export.Interval,Power.Active.Export,Voltage,SOC" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MeterValuesSampledData", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemData);
- // MeterValuesSampledDataMaxLength
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemName, "MeterValuesSampledDataMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemData, "5" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MeterValuesSampledDataMaxLength", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemData);
- // MeterValueSampleInterval
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemName, "MeterValueSampleInterval");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData, "10" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MeterValueSampleInterval", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData);
- // MinimumStatusDuration
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemName, "MinimumStatusDuration");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemData, "0" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MinimumStatusDuration", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemData);
- // NumberOfConnectors
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemName, "NumberOfConnectors");
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData, "%d", (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY));
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData, "%d", AC_QUANTITY);
- }
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","NumberOfConnectors", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData);
- // ResetRetries
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemName, "ResetRetries");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemData, "3" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ResetRetries", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemData);
- // ConnectorPhaseRotation
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemName, "ConnectorPhaseRotation");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "NotApplicable" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ConnectorPhaseRotation", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData);
- // ConnectorPhaseRotationMaxLength
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemName, "ConnectorPhaseRotationMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemData, "1" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ConnectorPhaseRotationMaxLength", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemData);
- // StopTransactionOnEVSideDisconnect
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemName, "StopTransactionOnEVSideDisconnect");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemData, "TRUE" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTransactionOnEVSideDisconnect", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemData);
- // StopTransactionOnInvalidId
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemName, "StopTransactionOnInvalidId");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData, "FALSE" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTransactionOnInvalidId", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData);
- // StopTxnAlignedData
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemName, "StopTxnAlignedData");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemData, "Energy.Active.Import.Register" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTxnAlignedData", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemData);
- // StopTxnAlignedDataMaxLength
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemName, "StopTxnAlignedDataMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemData, "0" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTxnAlignedDataMaxLength", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemData);
- // StopTxnSampledData
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemName, "StopTxnSampledData");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemData, "Energy.Active.Import.Register" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTxnSampledData", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemData);
- // StopTxnSampledDataMaxLength
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemName, "StopTxnSampledDataMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemData, "0" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","StopTxnSampledDataMaxLength", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemData);
- // SupportedFeatureProfiles
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemName, "SupportedFeatureProfiles");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemData, "Core,FirmwareManagement,LocalAuthListManagement,Reservation,SmartCharging,RemoteTrigger" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","SupportedFeatureProfiles", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemData);
- // SupportedFeatureProfilesMaxLength
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemName, "SupportedFeatureProfilesMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemData, "6" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","SupportedFeatureProfilesMaxLength", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemData);
- // TransactionMessageAttempts
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemName, "TransactionMessageAttempts");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemData, "3" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","TransactionMessageAttempts", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemData);
- // TransactionMessageRetryInterval
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemName, "TransactionMessageRetryInterval");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData, "60" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","TransactionMessageRetryInterval", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
- // UnlockConnectorOnEVSideDisconnect
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemName, "UnlockConnectorOnEVSideDisconnect");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemData, "TRUE" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","UnlockConnectorOnEVSideDisconnect", "true", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemData);
- // WebSocketPingInterval
- /*
- ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemName, "WebSocketPingInterval");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemData, "30" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","WebSocketPingInterval", "false", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemData);
- //* Local Auth List Management Profile*/
- //LocalAuthListEnabled
- /*
- ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility = 1;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemName, "LocalAuthListEnabled");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData, "TRUE" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","LocalAuthListEnabled", "false", (char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData);
- //LocalAuthListMaxLength
- /*
- ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemName, "LocalAuthListMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemData, "500" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","LocalAuthListMaxLength", "true", (char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemData);
- //SendLocalListMaxLength
- /*
- ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemName, "SendLocalListMaxLength");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemData, "500" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","SendLocalListMaxLength", "true", (char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemData);
- //ReserveConnectorZeroSupported
- /*
- ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemName, "ReserveConnectorZeroSupported");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemData, "FALSE" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ReserveConnectorZeroSupported", "true", (char *)ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemData);
- //* Smart Charging Profile */
- //ChargeProfileMaxStackLevel
- /*
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemName, "ChargeProfileMaxStackLevel");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemData, "3" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ChargeProfileMaxStackLevel", "true", (char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemData);
- // ChargingScheduleAllowedChargingRateUnit
- /*
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemName, "ChargingScheduleAllowedChargingRateUnit");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemData, "Current" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ChargingScheduleAllowedChargingRateUnit", "true", (char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemData);
- // ChargingScheduleMaxPeriods
- /*
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemName, "ChargingScheduleMaxPeriods");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemData, "10" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ChargingScheduleMaxPeriods", "true", (char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemData);
- // ConnectorSwitch3to1PhaseSupported
- /*
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemName, "ConnectorSwitch3to1PhaseSupported");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemData, "TRUE" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","ConnectorSwitch3to1PhaseSupported", "true", (char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemData);
- // MaxChargingProfilesInstalled
- /*
- ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemAccessibility = 0;
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemName, "MaxChargingProfilesInstalled");
- strcpy((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData, "9" );
- */
- fprintf(outfile,"{\"key\":\"%s\",\"readonly\": %s,\"value\":\"%s\"}\n","MaxChargingProfilesInstalled", "true", (char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData);
- fclose(outfile);
- }
- void getKeyValue(char *keyReq)
- {
- int isEmpty = FALSE;
- int isKnowKey = FALSE;
- //int unKnowIndex = 0;
- DEBUG_INFO("getKeyValue \n");
- DEBUG_INFO("keyReq=%s \n",keyReq);
- if((keyReq == NULL) || (strlen(keyReq) == 0))
- isEmpty = TRUE;
- if(isEmpty || strcmp(keyReq, "AllowOfflineTxForUnknownId") == 0)
- {
- DEBUG_INFO("AllowOfflineTxForUnknownId\n");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_AllowOfflineTxForUnknownId].Item, "AllowOfflineTxForUnknownId");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AllowOfflineTxForUnknownId].Key, "AllowOfflineTxForUnknownId");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AllowOfflineTxForUnknownId].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AllowOfflineTxForUnknownId].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AllowOfflineTxForUnknownId].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "AuthorizationCacheEnabled") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_AuthorizationCacheEnabled].Item, "AuthorizationCacheEnabled");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthorizationCacheEnabled].Key, "AuthorizationCacheEnabled");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthorizationCacheEnabled].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthorizationCacheEnabled].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthorizationCacheEnabled].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "AuthorizeRemoteTxRequests") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_AuthorizeRemoteTxRequests].Item, "AuthorizeRemoteTxRequests");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthorizeRemoteTxRequests].Key, "AuthorizeRemoteTxRequests");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthorizeRemoteTxRequests].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthorizeRemoteTxRequests].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_AuthorizeRemoteTxRequests].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "BlinkRepeat") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_BlinkRepeat].Item, "BlinkRepeat");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_BlinkRepeat].Key, "BlinkRepeat");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_BlinkRepeat].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_BlinkRepeat].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_BlinkRepeat].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "ClockAlignedDataInterval") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ClockAlignedDataInterval].Item, "ClockAlignedDataInterval");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ClockAlignedDataInterval].Key, "ClockAlignedDataInterval");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ClockAlignedDataInterval].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ClockAlignedDataInterval].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ClockAlignedDataInterval].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "ConnectionTimeOut") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ConnectionTimeOut].Item, "ConnectionTimeOut");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectionTimeOut].Key, "ConnectionTimeOut");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectionTimeOut].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectionTimeOut].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectionTimeOut].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "GetConfigurationMaxKeys") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_GetConfigurationMaxKeys].Item, "GetConfigurationMaxKeys");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_GetConfigurationMaxKeys].Key, "GetConfigurationMaxKeys");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_GetConfigurationMaxKeys].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_GetConfigurationMaxKeys].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_GetConfigurationMaxKeys].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "HeartbeatInterval") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_HeartbeatInterval].Item, "HeartbeatInterval");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_HeartbeatInterval].Key, "HeartbeatInterval");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_HeartbeatInterval].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_HeartbeatInterval].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_HeartbeatInterval].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "LightIntensity") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_LightIntensity].Item, "LightIntensity");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LightIntensity].Key, "LightIntensity");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LightIntensity].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LightIntensity].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LightIntensity].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "LocalAuthorizeOffline") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_LocalAuthorizeOffline].Item, "LocalAuthorizeOffline");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthorizeOffline].Key, "LocalAuthorizeOffline");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthorizeOffline].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthorizeOffline].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthorizeOffline].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "LocalPreAuthorize") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_LocalPreAuthorize].Item, "LocalPreAuthorize");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalPreAuthorize].Key, "LocalPreAuthorize");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalPreAuthorize].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalPreAuthorize].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalPreAuthorize].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "MaxEnergyOnInvalidId") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_MaxEnergyOnInvalidId].Item, "MaxEnergyOnInvalidId");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MaxEnergyOnInvalidId].Key, "MaxEnergyOnInvalidId");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MaxEnergyOnInvalidId].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MaxEnergyOnInvalidId].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MaxEnergyOnInvalidId].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemData );
- ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemData)/1000;
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "MeterValuesAlignedData") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_MeterValuesAlignedData].Item, "MeterValuesAlignedData");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesAlignedData].Key, "MeterValuesAlignedData");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesAlignedData].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesAlignedData].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesAlignedData].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "MeterValuesAlignedDataMaxLength") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_MeterValuesAlignedDataMaxLength].Item, "MeterValuesAlignedDataMaxLength");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesAlignedDataMaxLength].Key, "MeterValuesAlignedDataMaxLength");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesAlignedDataMaxLength].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesAlignedDataMaxLength].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesAlignedDataMaxLength].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "MeterValuesSampledData") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_MeterValuesSampledData].Item, "MeterValuesSampledData");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesSampledData].Key, "MeterValuesSampledData");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesSampledData].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesSampledData].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesSampledData].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "MeterValuesSampledDataMaxLength") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_MeterValuesSampledDataMaxLength].Item, "MeterValuesSampledDataMaxLength");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesSampledDataMaxLength].Key, "MeterValuesSampledDataMaxLength");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesSampledDataMaxLength].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesSampledDataMaxLength].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValuesSampledDataMaxLength].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "MeterValueSampleInterval") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_MeterValueSampleInterval].Item, "MeterValueSampleInterval");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValueSampleInterval].Key, "MeterValueSampleInterval");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValueSampleInterval].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValueSampleInterval].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MeterValueSampleInterval].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "MinimumStatusDuration") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_MinimumStatusDuration].Item, "MinimumStatusDuration");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MinimumStatusDuration].Key, "MinimumStatusDuration");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MinimumStatusDuration].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MinimumStatusDuration].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MinimumStatusDuration].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[17].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "NumberOfConnectors") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_NumberOfConnectors].Item, "NumberOfConnectors");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_NumberOfConnectors].Key, "NumberOfConnectors");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_NumberOfConnectors].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_NumberOfConnectors].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_NumberOfConnectors].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "ResetRetries") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ResetRetries].Item, "ResetRetries");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ResetRetries].Key, "ResetRetries");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ResetRetries].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ResetRetries].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ResetRetries].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "ConnectorPhaseRotation") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ConnectorPhaseRotation].Item, "ConnectorPhaseRotation");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorPhaseRotation].Key, "ConnectorPhaseRotation");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorPhaseRotation].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorPhaseRotation].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorPhaseRotation].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "ConnectorPhaseRotationMaxLength") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ConnectorPhaseRotationMaxLength].Item, "ConnectorPhaseRotationMaxLength");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorPhaseRotationMaxLength].Key, "ConnectorPhaseRotationMaxLength");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorPhaseRotationMaxLength].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorPhaseRotationMaxLength].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorPhaseRotationMaxLength].Value,(const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "StopTransactionOnEVSideDisconnect") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_StopTransactionOnEVSideDisconnect].Item, "StopTransactionOnEVSideDisconnect");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTransactionOnEVSideDisconnect].Key, "StopTransactionOnEVSideDisconnect");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTransactionOnEVSideDisconnect].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTransactionOnEVSideDisconnect].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTransactionOnEVSideDisconnect].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "StopTransactionOnInvalidId") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_StopTransactionOnInvalidId].Item, "StopTransactionOnInvalidId");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTransactionOnInvalidId].Key, "StopTransactionOnInvalidId");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTransactionOnInvalidId].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTransactionOnInvalidId].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTransactionOnInvalidId].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "StopTxnAlignedData") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_StopTxnAlignedData].Item, "StopTxnAlignedData");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnAlignedData].Key, "StopTxnAlignedData");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnAlignedData].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnAlignedData].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnAlignedData].Value,(const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "StopTxnAlignedDataMaxLength") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_StopTxnAlignedDataMaxLength].Item, "StopTxnAlignedDataMaxLength");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnAlignedDataMaxLength].Key, "StopTxnAlignedDataMaxLength");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnAlignedDataMaxLength].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnAlignedDataMaxLength].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnAlignedDataMaxLength].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "StopTxnSampledData") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_StopTxnSampledData].Item, "StopTxnSampledData");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnSampledData].Key, "StopTxnSampledData");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnSampledData].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnSampledData].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnSampledData].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "StopTxnSampledDataMaxLength") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_StopTxnSampledDataMaxLength].Item, "StopTxnSampledDataMaxLength");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnSampledDataMaxLength].Key, "StopTxnSampledDataMaxLength");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnSampledDataMaxLength].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnSampledDataMaxLength].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_StopTxnSampledDataMaxLength].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "SupportedFeatureProfiles") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_SupportedFeatureProfiles].Item, "SupportedFeatureProfiles");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SupportedFeatureProfiles].Key, "SupportedFeatureProfiles");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SupportedFeatureProfiles].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SupportedFeatureProfiles].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SupportedFeatureProfiles].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "SupportedFeatureProfilesMaxLength") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_SupportedFeatureProfilesMaxLength].Item, "SupportedFeatureProfilesMaxLength");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SupportedFeatureProfilesMaxLength].Key, "SupportedFeatureProfilesMaxLength");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SupportedFeatureProfilesMaxLength].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SupportedFeatureProfilesMaxLength].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SupportedFeatureProfilesMaxLength].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "TransactionMessageAttempts") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_TransactionMessageAttempts].Item, "TransactionMessageAttempts");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_TransactionMessageAttempts].Key, "TransactionMessageAttempts");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_TransactionMessageAttempts].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_TransactionMessageAttempts].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_TransactionMessageAttempts].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "TransactionMessageRetryInterval") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_TransactionMessageRetryInterval].Item, "TransactionMessageRetryInterval");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_TransactionMessageRetryInterval].Key, "TransactionMessageRetryInterval");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_TransactionMessageRetryInterval].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_TransactionMessageRetryInterval].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_TransactionMessageRetryInterval].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "UnlockConnectorOnEVSideDisconnect") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_UnlockConnectorOnEVSideDisconnect].Item, "UnlockConnectorOnEVSideDisconnect");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_UnlockConnectorOnEVSideDisconnect].Key, "UnlockConnectorOnEVSideDisconnect");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_UnlockConnectorOnEVSideDisconnect].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_UnlockConnectorOnEVSideDisconnect].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_UnlockConnectorOnEVSideDisconnect].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "WebSocketPingInterval") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_WebSocketPingInterval].Item, "WebSocketPingInterval");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_WebSocketPingInterval].Key, "WebSocketPingInterval");
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_WebSocketPingInterval].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_WebSocketPingInterval].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_WebSocketPingInterval].Value, (const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemData );
- isKnowKey = TRUE;
- }
- #if 0
- //For OCTT Test Case
- if(isEmpty || strcmp(keyReq, "LocalAuthorizationListEnabled") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_LocalAuthListEnabled].Item, "LocalAuthorizationListEnabled");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListEnabled].Key, "LocalAuthorizationListEnabled");
- if(ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListEnabled].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListEnabled].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListEnabled].Value, (const char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData );
- isKnowKey = TRUE;
- }
- #endif
- #if 1
- if(isEmpty || strcmp(keyReq, "LocalAuthListEnabled") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_LocalAuthListEnabled].Item, "LocalAuthListEnabled");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListEnabled].Key, "LocalAuthListEnabled");
- if(ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListEnabled].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListEnabled].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListEnabled].Value, (const char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData );
- isKnowKey = TRUE;
- }
- #endif
- if(isEmpty || strcmp(keyReq, "LocalAuthListMaxLength") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_LocalAuthListMaxLength].Item, "LocalAuthListMaxLength");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListMaxLength].Key, "LocalAuthListMaxLength");
- if(ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListMaxLength].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListMaxLength].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_LocalAuthListMaxLength].Value, (const char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "SendLocalListMaxLength") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_SendLocalListMaxLength].Item, "SendLocalListMaxLength");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SendLocalListMaxLength].Key, "SendLocalListMaxLength");
- if(ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SendLocalListMaxLength].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SendLocalListMaxLength].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_SendLocalListMaxLength].Value, (const char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemData );
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "ReserveConnectorZeroSupported") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ReserveConnectorZeroSupported].Item, "ReserveConnectorZeroSupported");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ReserveConnectorZeroSupported].Key, "ReserveConnectorZeroSupported");
- if(ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ReserveConnectorZeroSupported].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ReserveConnectorZeroSupported].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ReserveConnectorZeroSupported].Value,(const char *)ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemData);
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "ChargeProfileMaxStackLevel") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ChargeProfileMaxStackLevel].Item, "ChargeProfileMaxStackLevel");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargeProfileMaxStackLevel].Key, "ChargeProfileMaxStackLevel");
- if(ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargeProfileMaxStackLevel].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargeProfileMaxStackLevel].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargeProfileMaxStackLevel].Value, (const char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemData);
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "ChargingScheduleAllowedChargingRateUnit") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ChargingScheduleAllowedChargingRateUnit].Item, "ChargingScheduleAllowedChargingRateUnit");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargingScheduleAllowedChargingRateUnit].Key, "ChargingScheduleAllowedChargingRateUnit");
- if(ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargingScheduleAllowedChargingRateUnit].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargingScheduleAllowedChargingRateUnit].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargingScheduleAllowedChargingRateUnit].Value, (const char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemData);
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "ChargingScheduleMaxPeriods") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ChargingScheduleMaxPeriods].Item, "ChargingScheduleMaxPeriods");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargingScheduleMaxPeriods].Key, "ChargingScheduleMaxPeriods");
- if(ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargingScheduleMaxPeriods].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargingScheduleMaxPeriods].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ChargingScheduleMaxPeriods].Value, (const char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemData);
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "ConnectorSwitch3to1PhaseSupported") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_ConnectorSwitch3to1PhaseSupported].Item, "ConnectorSwitch3to1PhaseSupported");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorSwitch3to1PhaseSupported].Key, "ConnectorSwitch3to1PhaseSupported");
- if(ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorSwitch3to1PhaseSupported].ReadOnly, "0"/*"FALSE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorSwitch3to1PhaseSupported].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_ConnectorSwitch3to1PhaseSupported].Value, (const char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemData);
- isKnowKey = TRUE;
- }
- if(isEmpty || strcmp(keyReq, "MaxChargingProfilesInstalled") == 0 )
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.Key[GetConfiguration_MaxChargingProfilesInstalled].Item, "MaxChargingProfilesInstalled");
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MaxChargingProfilesInstalled].Key, "MaxChargingProfilesInstalled");
- if(ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemAccessibility == 1)
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MaxChargingProfilesInstalled].ReadOnly, "0"/*"FLASE"*/);
- }
- else
- {
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MaxChargingProfilesInstalled].ReadOnly, "1"/*"TRUE"*/);
- }
- strcpy((char *)ShmOCPP16Data->GetConfiguration.ResponseConfigurationKey[GetConfiguration_MaxChargingProfilesInstalled].Value, (const char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData);
- isKnowKey = TRUE;
- }
- //=========================================================
- if(!isEmpty && !isKnowKey)
- {
- DEBUG_INFO("unKnowIndex =%d\n", UnknownKeynum);
- strcpy(unknownkey[UnknownKeynum], keyReq);
- UnknownKeynum = UnknownKeynum + 1;
- }
- }
- void processUnkownKey(void)
- {
- DEBUG_INFO("processUnkownKey\n");
- memset(ShmOCPP16Data->GetConfiguration.ResponseUnknownKey, 0 , sizeof(struct StructConfigurationKeyItems)* 10);
- for(int index=0; index < UnknownKeynum; index++)
- {
- if(ShmOCPP16Data->GetConfiguration.ResponseUnknownKey[index].Item[0] == 0)
- {
- strcpy((char *)(ShmOCPP16Data->GetConfiguration.ResponseUnknownKey[index].Item), unknownkey[index]);
- }
- }
- }
- int setKeyValue(char *key, char *value)
- {
- int isSuccess = NotSupported;
- int check_ascii=0;
- char str[10]={0};
- #ifdef Debug
- DEBUG_INFO(" setKeyValue key-value=%s %s\n",key,value);
- #endif
- if(strcmp(key, "AllowOfflineTxForUnknownId") == 0)
- {
- //Charger.AllowOfflineTxForUnknownId = (value.toLowerCase().equals("true")?true:false);
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemAccessibility == 1)
- {
- strcpy(str, (const char*)value);
- for(int i = 0; str[i]; i++){
- str[i] = tolower(str[i]);
- }
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "AuthorizationCacheEnabled") == 0)
- {
- //Charger.AuthorizationCacheEnabled = (value.toLowerCase().equals("true")?true:false);
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemAccessibility == 1)
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizationCacheEnabled].ItemData, "%s", value/*(strcmp(value, "true")==0) ?TRUE:FALSE*/ );
- isSuccess = ConfigurationStatus_Accepted;
- //updateSetting("AuthorizationCacheEnabled", (Charger.AuthorizationCacheEnabled?"1":"0"));
- updateSetting("AuthorizationCacheEnabled",(char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[1].ItemData);
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "AuthorizeRemoteTxRequests") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemAccessibility == 1)
- {
- strcpy(str, (const char*)value);
- for(int i = 0; str[i]; i++)
- {
- str[i] = tolower(str[i]);
- }
- //Charger.AuthorizeRemoteTxRequests = (value.toLowerCase().equals("true")?true:false);
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AuthorizeRemoteTxRequests].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "BlinkRepeat") == 0)
- {
- //Charger.BlinkRepeat = Integer.parseInt(value);
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[BlinkRepeat].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "ClockAlignedDataInterval") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.ClockAlignedDataInterval = Integer.parseInt(value)*1000;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ClockAlignedDataInterval].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "ConnectionTimeOut") == 0 )
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.ConnectionTimeOut = Integer.parseInt(value)*1000;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData, "%d", atoi(value));
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "GetConfigurationMaxKeys") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.HeartbeatInterval = Integer.parseInt(value)*1000;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "HeartbeatInterval") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.HeartbeatInterval = Integer.parseInt(value)*1000;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[HeartbeatInterval].ItemData, "%d", atoi(value));
- HeartBeatWaitTime = atoi(value);
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "LightIntensity") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LightIntensity].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "LocalAuthorizeOffline") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemAccessibility == 1)
- {
- strcpy(str, (const char*)value);
- for(int i = 0; str[i]; i++)
- {
- str[i] = tolower(str[i]);
- }
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- updateSetting("LocalAuthorizeOffline", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalAuthorizeOffline].ItemData);
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "LocalPreAuthorize") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemAccessibility == 1)
- {
- strcpy(str, (const char*)value);
- for(int i = 0; str[i]; i++)
- {
- str[i] = tolower(str[i]);
- }
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[LocalPreAuthorize].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "MaxEnergyOnInvalidId") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MaxEnergyOnInvalidId].ItemData, "%d", atoi(value) );
- ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = atoi(value)/1000;
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "MeterValuesAlignedData") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemAccessibility == 1)
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedData].ItemData, "%s", value );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "MeterValuesAlignedDataMaxLength") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.MeterValueSampleInterval = Integer.parseInt(value)*1000;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesAlignedDataMaxLength].ItemData, "%d", atoi(value));
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "MeterValuesSampledData") == 0 )
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemAccessibility == 1)
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledData].ItemData, "%s", value );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "MeterValuesSampledDataMaxLength") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.MeterValueSampleInterval = Integer.parseInt(value)*1000;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValuesSampledDataMaxLength].ItemData, "%d", atoi(value));
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "MeterValueSampleInterval") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.MeterValueSampleInterval = Integer.parseInt(value)*1000;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData, "%d", atoi(value));
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "MinimumStatusDuration") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.MinimumStatusDuration = Integer.parseInt(value);
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "NumberOfConnectors") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.ResetRetries = Integer.parseInt(value);
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[NumberOfConnectors].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "ResetRetries") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.ResetRetries = Integer.parseInt(value);
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ResetRetries].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "ConnectorPhaseRotation") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemAccessibility == 1)
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotation].ItemData, "%s", value );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "ConnectorPhaseRotationMaxLength") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectorPhaseRotationMaxLength].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "StopTransactionOnEVSideDisconnect") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemAccessibility == 1)
- {
- strcpy(str, (const char*)value);
- for(int i = 0; str[i]; i++)
- {
- str[i] = tolower(str[i]);
- }
- //Charger.StopTransactionOnEVSideDisconnect = (value.toLowerCase().equals("true")?true:false);
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "StopTransactionOnInvalidId") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemAccessibility == 1)
- {
- strcpy(str, (const char*)value);
- for(int i = 0; str[i]; i++)
- {
- str[i] = tolower(str[i]);
- }
- //Charger.StopTransactionOnInvalidId = (value.toLowerCase().equals("true")?true:false);
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnInvalidId].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "StopTxnAlignedData") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemAccessibility == 1)
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedData].ItemData, "%s", value );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "StopTxnAlignedDataMaxLength") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnAlignedDataMaxLength].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "StopTxnSampledData") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemAccessibility == 1)
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledData].ItemData, "%s", value );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "StopTxnSampledDataMaxLength") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTxnSampledDataMaxLength].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "SupportedFeatureProfiles") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemAccessibility == 1)
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfiles].ItemData, "%s", value );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "SupportedFeatureProfilesMaxLength") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[SupportedFeatureProfilesMaxLength].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "TransactionMessageAttempts") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.TransactionMessageAttempts = Integer.parseInt(value);
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemData, "%d", atoi(value) );
- TransactionMessageAttemptsValue = atoi(value);
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "TransactionMessageRetryInterval") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- //Charger.TransactionMessageRetryInterval = Integer.parseInt(value)*1000;
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData, "%d", atoi(value) );
- TransactionMessageRetryIntervalValue = atoi(value);
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "UnlockConnectorOnEVSideDisconnect") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemAccessibility == 1)
- {
- strcpy(str, (const char*)value);
- for(int i = 0; str[i]; i++)
- {
- str[i] = tolower(str[i]);
- }
- //Charger.UnlockConnectorOnEVSideDisconnect = (value.toLowerCase().equals("true")?true:false);
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[UnlockConnectorOnEVSideDisconnect].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "WebSocketPingInterval") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[WebSocketPingInterval].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- #if 0
- //For OCPP Test Case
- if(strcmp(key, "LocalAuthorizationListEnabled") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility == 1)
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData, "%s", (strcmp(value, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- //updateSetting("LocalAuthorizationListEnabled", (char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData);
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- #endif
- #if 1
- if(strcmp(key, "LocalAuthListEnabled") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemAccessibility == 1)
- {
- strcpy(str, (const char*)value);
- for(int i = 0; str[i]; i++)
- {
- str[i] = tolower(str[i]);
- }
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- updateSetting("LocalAuthListEnabled", (char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListEnabled].ItemData);
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- #endif
- if(strcmp(key, "LocalAuthListMaxLength") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[LocalAuthListMaxLength].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "SendLocalListMaxLength") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.LocalAuthListManagementProfile[SendLocalListMaxLength].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "ReserveConnectorZeroSupported") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemAccessibility == 1)
- {
- strcpy(str, (const char*)value);
- for(int i = 0; str[i]; i++)
- {
- str[i] = tolower(str[i]);
- }
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.ReservationProfile[ReserveConnectorZeroSupported].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "ChargeProfileMaxStackLevel") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargeProfileMaxStackLevel].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "ChargingScheduleAllowedChargingRateUnit") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemAccessibility == 1)
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleAllowedChargingRateUnit].ItemData, "%s", value );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "ChargingScheduleMaxPeriods") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ChargingScheduleMaxPeriods].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "ConnectorSwitch3to1PhaseSupported") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemAccessibility == 1)
- {
- strcpy(str, (const char*)value);
- for(int i = 0; str[i]; i++)
- {
- str[i] = tolower(str[i]);
- }
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[ConnectorSwitch3to1PhaseSupported].ItemData, "%s", (strcmp(str, "true")==0) ?"TRUE":"FALSE" );
- isSuccess = ConfigurationStatus_Accepted;
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- if(strcmp(key, "MaxChargingProfilesInstalled") == 0)
- {
- if(ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemAccessibility == 1)
- {
- check_ascii = value[0];
- if( (check_ascii < 48) || (check_ascii > 57) )
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- else
- {
- sprintf((char *)ShmOCPP16Data->ConfigurationTable.SmartChargingProfile[MaxChargingProfilesInstalled].ItemData, "%d", atoi(value) );
- isSuccess = ConfigurationStatus_Accepted;
- }
- }
- else
- {
- isSuccess = ConfigurationStatus_Rejected;
- }
- }
- return isSuccess;
- }
- int updateSetting(char *key, char *value)
- {
- mtrace();
- int isSuccess = FALSE;
- char string[1000]={0}, buffer[1000]={0};
- char strtemp[50]={0};
- char sstr[50]={ 0 };//sstr[200]={ 0 };
- int pos, c = 0;
- char *loc;
- int pos1=0;
- FILE *f = fopen("/var/www/settings1", "r");
- if(f == NULL)
- {
- #ifdef Debug
- DEBUG_ERROR("/var/www/settings1 does not exist!\n");
- #endif
- return isSuccess;
- }
- fseek(f, 0, SEEK_END);
- long fsize = ftell(f);
- fseek(f, 0, SEEK_SET); /* same as rewind(f); */
- fread(string, 1, fsize, f);
- fclose(f);
- string[fsize] = 0;
- loc = strstr(string, key);
- if(loc != NULL)
- {
- DEBUG_INFO("key exist!\n");
- pos = loc - string-1;
- f = fopen("/var/www/settings1", "w");
- strncpy(buffer, string, pos);
- fprintf(f, "%s", buffer);
- memset(sstr ,0, sizeof(sstr) );
- c = 0;
- while (loc[3+strlen(key/*"LocalAuthListEnabled"*/)+c] != '\"')
- {
- sstr[c] = loc[3+strlen(key/*"LocalAuthListEnabled"*/)+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- pos1 = fsize -pos -(3+strlen(key/*"LocalAuthListEnabled"*/)+c)-1;
- sprintf(strtemp,"\"%s\":\"%s\"",key,value);
- fprintf(f, "%s", strtemp /*"\"LocalAuthListEnabled\":\"fault\""*/);
- memset(buffer ,0, sizeof(buffer) );
- strncpy(buffer, loc+(3+strlen(key/*"LocalAuthListEnabled"*/)+c)+1, pos1);
- //printf("buffer=%s",buffer);
- fprintf(f, "%s", buffer);
- fclose(f);
- }
- else
- {
- printf("key not exist!\n");
- f = fopen("/var/www/settings1", "w+");
- fputs(string, f);
- fseek(f, -1, SEEK_CUR);
- //fprintf(f, "%s", ",\"LocalAuthListEnabled\":\"true\"}");
- sprintf(strtemp,",\"%s\":\"%s\"}",key,value);
- fputs(strtemp/*",\"LocalAuthListEnabled\":\"true\"}"*/, f);
- fclose(f);
- }
- isSuccess = TRUE;
- return isSuccess;
- }
- int TransactionMessageAttemptsGet(void)
- {
- return TransactionMessageAttemptsValue;//atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageAttempts].ItemData);
- }
- int FirstHeartBeatResponse(void)
- {
- return FirstHeartBeat;
- }
- int TransactionMessageRetryIntervalGet(void)
- {
- return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
- }
- #define SA struct sockaddr
- #define MAXBUF 1024
- //static int m_socket_data;
- //static int sockfd;
- int ReadHttpStatus(int sock){
- //char c;
- char buff[1024]="",*ptr=buff+1;
- int bytes_received, status;
- DEBUG_INFO("Begin Response ..\n");
- while((bytes_received = recv(sock, ptr, 1, 0))){
- if(bytes_received==-1){
- perror("ReadHttpStatus");
- exit(1);
- }
- if((ptr[-1]=='\r') && (*ptr=='\n' )) break;
- ptr++;
- }
- *ptr=0;
- ptr=buff+1;
- sscanf(ptr,"%*s %d ", &status);
- DEBUG_INFO("%s\n",ptr);
- DEBUG_INFO("status=%d\n",status);
- DEBUG_INFO("End Response ..\n");
- return (bytes_received>0)?status:0;
- }
- //the only filed that it parsed is 'Content-Length'
- int ParseHeader(int sock){
- //char c;
- char buff[1024]="",*ptr=buff+4;
- int bytes_received;
- DEBUG_INFO("Begin HEADER ..\n");
- while((bytes_received = recv(sock, ptr, 1, 0))){
- if(bytes_received==-1){
- perror("Parse Header");
- exit(1);
- }
- if(
- (ptr[-3]=='\r') && (ptr[-2]=='\n' ) &&
- (ptr[-1]=='\r') && (*ptr=='\n' )
- ) break;
- ptr++;
- }
- *ptr=0;
- ptr=buff+4;
- //printf("%s",ptr);
- if(bytes_received){
- ptr=strstr(ptr,"Content-Length:");
- if(ptr){
- sscanf(ptr,"%*s %d",&bytes_received);
- }else
- bytes_received=-1; //unknown size
- DEBUG_INFO("Content-Length: %d\n",bytes_received);
- }
- DEBUG_INFO("End HEADER ..\n");
- return bytes_received ;
- }
- int httpDownLoadFile(char *location, char *path, char *filename,char *url)
- {
- char rmFileCmd[100]={0};
- char FilePath[100]={0};
- char ftpbuf[200];
- int systemresult;
- //DEBUG_INFO("filename=%s\n",filename);
- //DEBUG_INFO("url=%s\n",url);
- sprintf(FilePath,"../mnt/%s",filename);
- if((access(FilePath,F_OK))!=-1)
- {
- DEBUG_INFO("filename=%s exist.\n",FilePath);
- sprintf(rmFileCmd,"rm -f %s",FilePath);
- system(rmFileCmd);
- }
- memset(ftpbuf, 0, sizeof(ftpbuf));
- sprintf(ftpbuf, "wget --tries=3 -O ../mnt/%s -c %s",filename, url);
- //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
- systemresult = system(ftpbuf);
- //DEBUG_INFO("systemresult=%d\n",systemresult);
- if(systemresult != 0)
- {
- DEBUG_INFO("http DownLoad error!\n");
- return FALSE;
- }
- return TRUE;
- }
- int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
- {
- char rmFileCmd[100]={0};
- char FilePath[100]={0};
- char ftpbuf[200];
- int systemresult;
- //char temp[100];
- #if 0
- struct hostent* server;
- char *IPbuffer;
- server = gethostbyname(location);
- // To convert an Internet network
- // address into ASCII string
- IPbuffer = inet_ntoa(*((struct in_addr*)
- server->h_addr_list[0]));
- #endif
- sprintf(FilePath,"../mnt/%s",filename);
- if((access(FilePath,F_OK))!=-1)
- {
- DEBUG_INFO("filename=%s exist.\n",FilePath);
- sprintf(rmFileCmd,"rm -f %s",FilePath);
- system(rmFileCmd);
- }
- memset(ftpbuf, 0, sizeof(ftpbuf));
- sprintf(ftpbuf, "wget --tries=3 -O ../mnt/%s -c %s",filename, url);
- //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
- //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
- //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
- systemresult = system(ftpbuf);
- //DEBUG_INFO("systemresult=%d\n",systemresult);
- if(systemresult != 0)
- {
- printf("wget error!\n");
- return FALSE;
- }
- return TRUE;
- }
- int httpUploadFile(char *location, char *path, char *filename,char *url)
- {
- char rmFileCmd[100]={0};
- char FilePath[100]={0};
- char ftpbuf[200];
- char filenametemp[60]={0};
- int systemresult;
- //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);
- sscanf(filename, "%*2[.]%s", filenametemp);
- fprintf(fp, "%s\n", filenametemp);
- fclose(fp);
- }
- memset(ftpbuf, 0, sizeof(ftpbuf));
- sprintf(ftpbuf, "%s","../bin/php-cgi /var/www/ocpp_upload.php");
- systemresult = system(ftpbuf);
- DEBUG_INFO("systemresult=%d\n",systemresult);
- if(systemresult != 0)
- {
- DEBUG_INFO("http upload error!\n");
- return FALSE;
- }
- return TRUE;
- }
- int ftpFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
- {
- struct hostent* server;
- char *IPbuffer;
- char ftpbuf[200];
- int systemresult;
- // To retrieve host information
- server = gethostbyname(location);
- // To convert an Internet network
- // address into ASCII string
- IPbuffer = inet_ntoa(*((struct in_addr*)
- server->h_addr_list[0]));
- memset(ftpbuf, 0, sizeof(ftpbuf));
- /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
- /* format : ftpput -u username -p passwd IP target source*/
- sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
- DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
- //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
- systemresult = system(ftpbuf);
- DEBUG_INFO("systemresult=%d\n",systemresult);
- if(systemresult != 0)
- {
- DEBUG_INFO("ftpput error!\n");
- return FALSE;
- }
- return TRUE;
- }
- int SettingChargingRecord(int target, int transactionId)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING))
- {
- addBuff(target, transactionId, 0);
- return TRUE;
- }
- }
- for (int index = 0; index < CCS_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING))
- {
- addBuff(target, transactionId, 0);
- return TRUE;
- }
- }
- for (int index = 0; index < GB_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING))
- {
- addBuff(target, transactionId, 0);
- return TRUE;
- }
- }
- }
- else
- {
- for (int index = 0; index < AC_QUANTITY; index++)
- {
- if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == target)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING))
- {
- addBuff(target, transactionId, 0);
- return TRUE;
- }
- }
- }
- return FALSE;
- }
- int addBuff(int gun_idx, int user_id, int cmd_sn)
- {
- int isSuccess = FALSE;
- //char *query = NULL;
- sqlite3_stmt *stmt;
- int rc; // return code
- char str[20];
- sprintf(str,"%d",user_id);
- sqlite3_prepare_v2(db, "insert into log_buffer (user_id, cmd_sn, charger_id, gun_type, gun_no, rfid_no, stime, etime, time_len, s_soc, e_soc, stop_reason, power, meter_before, meter_after, charge_price, reserve, surplus_before, surplus_after, service_price, is_pay ,charge_strategy, charge_parameter, vin, vehicle_no, start_method, card_type, is_upload, guid, is_buf2OK) values (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16,?17,?18,?19,?20,?21,?22,?23,?24,?25,?26,?27,?28,?29,?30);", -1, &stmt, NULL); /* 1 */
- sqlite3_bind_text(stmt, 1, str, -1, SQLITE_STATIC); /* 2 */
- rc = sqlite3_step(stmt); /* 3 */
- if (rc != SQLITE_DONE) {
- printf("ERROR inserting data: %s\n", sqlite3_errmsg(db));
- goto out;
- }
- sqlite3_finalize(stmt);
- // free(query);
- out:
- //----------------------
- // close SQLite database
- //----------------------
- sqlite3_close(db);
- printf("database closed.\n");
- return isSuccess;
- }
- /**
- * Place the contents of the specified file into a memory buffer
- *
- * @param[in] filename The path and name of the file to read
- * @param[out] filebuffer A pointer to the contents in memory
- * @return status 0 success, 1 on failure
- */
- int get_file_contents(const char* filename, char** outbuffer) {
- FILE* file = NULL;
- long filesize;
- const int blocksize = 1;
- size_t readsize;
- char* filebuffer;
- // Open the file
- file = fopen(filename, "r");
- if (NULL == file)
- {
- printf("'%s' not opened\n", filename);
- exit(EXIT_FAILURE);
- }
- // Determine the file size
- fseek(file, 0, SEEK_END);
- filesize = ftell(file);
- rewind (file);
- // Allocate memory for the file contents
- filebuffer = (char*) malloc(sizeof(char) * filesize);
- *outbuffer = filebuffer;
- if (filebuffer == NULL)
- {
- fputs ("malloc out-of-memory", stderr);
- exit(EXIT_FAILURE);
- }
- // Read in the file
- readsize = fread(filebuffer, blocksize, filesize, file);
- if (readsize != filesize)
- {
- fputs ("didn't read file completely",stderr);
- exit(EXIT_FAILURE);
- }
- // Clean exit
- fclose(file);
- return EXIT_SUCCESS;
- }
- static int selectSqlCount = 0;
- static int callback(void *data, int argc, char **argv, char **azColName){
- int i;
- printf("%s: ", (const char*)data);
- selectSqlCount = argc;
- for(i = 0; i<argc; i++){
- printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
- }
- printf("\n");
- return 0;
- }
- static int versioncallback(void *data, int argc, char **argv, char **azColName){
- //int i;
- //printf("%s:\n", (const char*)data);
- localversion = argv[5] ? atoi(argv[5]) : 0;
- printf("localversion=%d\n", localversion);
- return 0;
- }
- static int IdTagcallback(void *data, int argc, char **argv, char **azColName){
- //int i;
- //printf("%s:\n", (const char*)data);
- //idTag
- sprintf(idTagAuthorization,"%s", argv[1] ? argv[1] : "NULL");
- sprintf(idTagQuery.idTagstr,"%s", argv[1] ? argv[1] : "NULL");
- //parentIdTag
- sprintf(idTagQuery.parentIdTag,"%s", argv[2] ? argv[2] : "NULL");
- //expir_date
- sprintf(idTagQuery.expiryDate,"%s", argv[3] ? argv[3] : "NULL");
- //status
- sprintf(idTagQuery.idTagstatus,"%s", argv[4] ? argv[4] : "NULL");
- //version
- idTagQuery.listVersionInt = atoi(argv[5]);
- DEBUG_INFO("IdTag=%s\n", idTagAuthorization);
- return 0;
- }
- static int deleteIdTagcallback(void *data, int argc, char **argv, char **azColName){
- int i;
- //printf("%s:\n", (const char*)data);
- #if 1
- for(i=0; i<argc; i++){
- DEBUG_INFO("%s = %s", azColName[i], argv[i] ? argv[i] : "NULL");
- }
- //printf("");
- #endif
- // localversion = argv[5] ? atoi(argv[5]) : 0;
- // printf("localversion=%d\n", localversion);
- return 0;
- }
- /** sqlite3_exec的回调。
- *
- * 向控制台打印查询的结果。
- *
- * @param in data 传递给回调函数的数据。
- * @param in n_columns sqlite3_exec执行结果集中列的数量。
- * @param in col_values sqlite3_exec执行结果集中每一列的数据。
- * @param in col_names sqlite3_exec执行结果集中每一列的名称。
- * @return 状态码。
- */
- int sqlite3_exec_callback(void *data, int n_columns, char **col_values, char **col_names)
- {
- for (int i = 0; i < n_columns; i++)
- {
- DEBUG_INFO("%s/t", col_values[i]);
- }
- DEBUG_INFO("/n");
- return 0;
- }
- void OCPP_getListVerion()
- {
- int rc = 0;
- // const char* data = "Callback function called";
- char sql[100];
- char zErrMsg[100];
- memset(sql, 0, 100);
- memset(zErrMsg, 0, 100);
- strcpy(sql, "select * from ocpp_auth_local order by idx desc");
- /* Execute SQL statement */
- rc = sqlite3_exec(db, sql, versioncallback, 0, (char **)&zErrMsg);
- DEBUG_INFO("rc=%d\n",rc);
- if( rc != SQLITE_OK ){
- DEBUG_INFO("SQL error: %s", zErrMsg);
- //sqlite3_free(zErrMsg);
- }else{
- DEBUG_INFO("Operation done successfully");
- }
- }
- void OCPP_getIdTag(char *idTag)
- {
- int rc = 0;
- // const char* data = "Callback function called";
- char sql[100];
- char zErrMsg[100];
- memset(sql, 0, 100);
- memset(zErrMsg, 0, 100);
- memset(idTagAuthorization, 0, sizeof(idTagAuthorization));
- memset(&idTagQuery, 0, sizeof(idTagQuery));
- sprintf(sql,"select * from ocpp_auth_local where idtag='%s'", idTag);
- /* Execute SQL statement */
- rc = sqlite3_exec(db, sql, IdTagcallback, 0, (char **)&zErrMsg);
- if( rc != SQLITE_OK ){
- DEBUG_INFO("SQL error: %s", zErrMsg);
- //sqlite3_free(zErrMsg);
- }else{
- printf("Operation done successfully");
- }
- //return ver;
- }
- void OCPP_get_TableAuthlocalAllData(void)
- {
- int rc = 0;
- // const char* data = "Callback function called";
- char sql[100];
- char zErrMsg[100];
- memset(sql, 0, 100);
- memset(zErrMsg, 0, 100);
- sprintf(sql,"select * from ocpp_auth_local ");
- /* Execute SQL statement */
- rc = sqlite3_exec(db, sql, &sqlite3_exec_callback, 0,(char **)&zErrMsg);
- // rc = sqlite3_exec(db, sql, IdTagcallback, 0, &zErrMsg);
- if( rc != SQLITE_OK ){
- DEBUG_INFO("SQL error: %s", zErrMsg);
- //sqlite3_free(zErrMsg);
- }else{
- DEBUG_INFO("Operation done successfully");
- }
- //return ver;
- }
- int OCPP_cleanLocalList()
- {
- char * sqlcleanLocalList = "delete from ocpp_auth_local";
- char *errMsg = 0;
- int rc =sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg);
- if (SQLITE_OK != rc)
- {
- DEBUG_INFO("%s\n",errMsg);
- return FALSE;
- }
- else
- {
- DEBUG_INFO("delete ocpp_auth_local table successfully\n");
- }
- return TRUE;
- }
- int OCPP_addLocalList_1(int version, char *idTag, char *parentTage, char *expiryDate, char *status)
- {
- int isSuccess = FALSE;
- int ret = 0;
- //const char* data = "Callback function called";
- char sql[200];
- char zErrMsg[100];
- memset(sql, 0, 200);
- memset(zErrMsg, 0, 100);
- sprintf(sql,"insert or replace into ocpp_auth_local (idtag, parent_idtag, expir_date, status, version) " "VALUES ('%s', '%s', '%s', '%s', %d ); ""SELECT * from ocpp_auth_local", idTag, parentTage, expiryDate, status, version);
- //* Execute SQL statement */
- //zErrMsg = 0;
- ret = sqlite3_exec(db, sql, callback, 0, (char **)&zErrMsg);
- if( ret != SQLITE_OK ){
- DEBUG_INFO("SQL error: %s\n", zErrMsg);
- // free(zErrMsg);
- // free(sql);
- return isSuccess;
- }
- DEBUG_INFO("successfully Insert records created\n");
- isSuccess = TRUE;
- return isSuccess;
- }
- void OCPP_deleteIdTag(char *idTag)
- {
- //int ver = 0;
- //int isSuccess = FALSE;
- int rc = 0;
- char sql[100];
- char zErrMsg[100];
- memset(sql, 0, 100);
- memset(zErrMsg, 0, 100);
- sprintf(sql,"DELETE from ocpp_auth_local where idtag='%s'; SELECT * from ocpp_auth_local;", idTag);
- //* Execute SQL statement */
- rc = sqlite3_exec(db, sql, deleteIdTagcallback, 0,(char **)&zErrMsg);
- if( rc != SQLITE_OK ){
- DEBUG_INFO("SQL error: %s", zErrMsg);
- //sqlite3_free(zErrMsg);
- }else{
- DEBUG_INFO("Operation done successfully");
- }
- }
- int OCPP_addLocalList(int version, char *idTag, char *parentTage, char *expiryDate, char *status)
- {
- int isSuccess = FALSE;
- int ret = 0;
- const char* data = "Callback function called";
- char sql[200];
- char zErrMsg[100];
- memset(sql, 0, 200);
- memset(zErrMsg, 0, 100);
- //* selectFromTable */
- // sql = select * from ocpp_auth_local where starring='Jodie Foster';
- sprintf(sql,"select * from ocpp_auth_local where idtag='%s'", idTag);
- //* Execute SQL statement */
- selectSqlCount = 0;
- ret = sqlite3_exec(db, sql, callback, (void*)data,(char **)&zErrMsg);
- if( ret != SQLITE_OK ){
- printf("Error SQL: %s\n", zErrMsg);
- }
- printf("successfully select operation done\n");
- memset(sql, 0, 200);
- memset(zErrMsg, 0, 100);
- if(selectSqlCount == 0)
- {
- //Insert
- //sql = "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) " "VALUES (1, ? Paul?? 32, ? California?? 20000.00 ); ";
- sprintf(sql,"INSERT INTO ocpp_auth_local (idtag, parent_idtag, expir_date, status, version) " "VALUES ('%s', '%s', '%s', '%s', %d ); ", idTag, parentTage, expiryDate, status, version);
- DEBUG_INFO("sql:%s\n", sql);
- //* Execute SQL statement */
- //zErrMsg = 0;
- ret = sqlite3_exec(db, sql, callback, 0,(char **)&zErrMsg);
- if( ret != SQLITE_OK ){
- printf("SQL error: %s\n", zErrMsg);
- return isSuccess;
- }
- DEBUG_INFO("successfully Insert records created\n");
- isSuccess = TRUE;
- }
- else
- {
- //Update
- //* Create merged SQL statement */
- sprintf(sql, "UPDATE ocpp_auth_local set parent_idtag = '%s', expir_date = '%s', status ='%s', version =%d where idtag='%s'; " "SELECT * from ocpp_auth_local", parentTage, expiryDate, status, version, idTag);
- /* Execute SQL statement */
- ret = sqlite3_exec(db, sql, callback, (void*)data,(char **)&zErrMsg);
- if( ret != SQLITE_OK ){
- printf("SQL error: %s\n", zErrMsg);
- //sqlite3_free(zErrMsg);
- //sqlite3_free(sql);
- return isSuccess;
- }
- DEBUG_INFO("Successfully operation done \n");
- isSuccess = TRUE;
- }
- return isSuccess;
- }
- int GetOcppServerURL()
- {
- int result = FALSE;
- memset(OcppProtocol, 0, sizeof(OcppProtocol));
- memset(OcppHost, 0, sizeof(OcppHost));
- memset(OcppTempPath, 0, sizeof(OcppTempPath));
- if((ShmSysConfigAndInfo->SysConfig.OcppServerURL != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) )
- {
- //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.OcppServerURL =%s\n",ShmSysConfigAndInfo->SysConfig.OcppServerURL);
- sscanf((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,
- "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
- OcppProtocol, OcppHost, &OcppPort, OcppTempPath);
- result = TRUE;
- // DEBUG_INFO("OcppProtocol =%s\n",OcppProtocol);
- // DEBUG_INFO("OcppHost =%s\n",OcppHost);
- // DEBUG_INFO("OcppPort =%d\n",OcppPort);
- // DEBUG_INFO("OcppTempPath =%s\n",OcppTempPath);
- goto End;
- }
- else if((ShmOCPP16Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP16Data->OcppServerURL,"") != 0))
- {
- //DEBUG_INFO("ShmOCPP16Data->OcppServerURL =%s\n",ShmOCPP16Data->OcppServerURL);
- sscanf((const char *)ShmOCPP16Data->OcppServerURL,
- "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
- OcppProtocol, OcppHost, &OcppPort, OcppTempPath);
- result = TRUE;
- // DEBUG_INFO("OcppProtocol =%s\n",OcppProtocol);
- // DEBUG_INFO("OcppHost =%s\n",OcppHost);
- // DEBUG_INFO("OcppPort =%d\n",OcppPort);
- // DEBUG_INFO("OcppTempPath =%s\n",OcppTempPath);
- goto End;
- }
- else
- {
- strcpy(OcppHost,"");
- }
- End:
- 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;
- goto End;
- }
- else if((ShmOCPP16Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP16Data->ChargeBoxId,"") != 0))
- {
- if(OcppTempPath == NULL)
- {
- sprintf(OcppPath,"/%s",ShmOCPP16Data->ChargeBoxId);
- }
- else
- {
- sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP16Data->ChargeBoxId);
- }
- result = TRUE;
- goto End;
- }
- else
- {
- strcpy(OcppPath,"");
- }
- End:
- //DEBUG_INFO("OcppPath=%s\n",OcppPath);
- return result;
- }
- int GetOcppPort()
- {
- return OcppPort;
- }
- int GetOcppConnStatus(void)
- {
- return ShmOCPP16Data->OcppConnStatus;
- }
- void SetOcppConnStatus(uint8_t status)
- {
- ShmOCPP16Data->OcppConnStatus = status;
- ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
- if(status == FALSE)
- {
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
- {
- SystemInitial = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
- }
- else
- {
- SystemInitial = AC_QUANTITY;
- }
- }
- }
- int GetHeartBeatWithNOResponse(void)
- {
- return HeartBeatWithNOResponse;
- }
- void SetHeartBeatWithNOResponse(void)
- {
- HeartBeatWithNOResponse = 0;
- }
- int GetTransactionId(int gunindex)
- {
- return TransactionId[gunindex];
- }
- void SetTransactionIdZero(int gunindex)
- {
- TransactionId[gunindex] = 0;
- }
- int InternetDisconnect(void)
- {
- //DEBUG_INFO("ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi=%d\n",ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi);
- //DEBUG_INFO("ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=%d\n",ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet);
- //DEBUG_INFO("ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi=%d\n",ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi);
- return (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi );
- }
- void GetChargingProfileRequest(int gunindex)
- {
- mtrace();
- //int connectorIdInt, durationInt;
- //char chargingRateUnitStr[4]={0};
- int tempdurationInt = 0;
- int tempchargingProfileId = 0;
- int tempstackLevel = 0;
- int temptransactionId = 0;
- float tempminChargingRateFloat = 0.0;
- char tempchargingProfilePurposeStr[24]={0};
- char tempchargingProfileKindStr[12]={0};
- char temprecurrencyKindStr[8]={0};
- char tempvalidFromStr[28]={0},tempchargingRateUnitStr[4]={0}, tempstartScheduleStr[30]={0};
- char tempvalidToStr[28]={0};
- int tempStartPeriodInt = 0;
- float tempLimitInt = 0.0;//0.1;
- int tempNumberPhasesInt=0;
- char fname[200];
- //char comfirmstr[20];
- float MinChargingRate =0.0;
- double diff_t;
- struct tm tp;
- FILE *fptr1;//, *fptr2;
- int c = 0;
- char * pch;
- char *loc;
- char sstr[200]={ 0 };
- int n_chargingProfile = 0;
- int n_SchedulePeriods = 0;
- char SchedulePeriodList[10][200]={0};
- char sLineWord[800]={0};
- char word[1000]={0};
- int confirmPeriods = 0;
- struct StructProfile ChargePointMaxProfile;
- struct StructProfile TxDefaultProfile;
- struct StructProfile TxProfile;
- struct StructProfile TxDefaultProfiletemp[2]={0};
- struct StructChargingProfile ChargePointMaxProfile_TEMP={0};
- struct StructChargingProfile TxDefaultProfile_TEMP={0};
- struct StructChargingProfile TxProfile_TEMP={0};
- int TxDefaultProfileFileIsNull=FALSE;
- int ChargePointMaxProfileIsNull=FALSE;
- int TxProfileIsNull=FALSE;
- // int CompositeSceduleIndex = 0;
- char ChargePointMaxProfileScheduleStr[30]={0};
- char TxDefaultProfileScheduleStr[30]={0};
- char TxProfileScheduleStr[30]={0};
- memset(&ChargePointMaxProfile,0,sizeof(struct StructProfile));
- memset(&TxDefaultProfile,0,sizeof(struct StructProfile));
- memset(&TxProfile,0,sizeof(struct StructProfile));
- memset(&ShmOCPP16Data->SmartChargingProfile[gunindex],0,sizeof(struct StructChargingProfile));
- DEBUG_INFO("GetChargingProfileRequest\n");
- //*****************************ChargePointMaxProfile******************************************/
- strcpy(fname, ChargePointMaxProfile_JSON);
- ChargePointMaxProfileIsNull=TRUE;
- if((access(ChargePointMaxProfile_JSON,F_OK))!=-1)
- {
- fptr1 = fopen(fname, "r");
- int c;
- c = fgetc(fptr1);
- //DEBUG_INFO("c:%d\n",c);
- rewind(fptr1);
- if(c == EOF)
- {
- DEBUG_INFO("\n End of file reached.");
- ChargePointMaxProfileIsNull=TRUE;
- fclose(fptr1);
- }
- else
- {
- ChargePointMaxProfileIsNull=FALSE;
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- if(strcmp(word, "chargingProfileId") == 0)
- {
- n_chargingProfile = n_chargingProfile + 1;
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- int i = 0;
- int j = 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL ) {
- //***********chargingProfileId**************/
- c = 0;
- loc = strstr(sLineWord, "chargingProfileId");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[2+strlen("chargingProfileId")+c] != '\"')
- {
- sstr[c] = loc[2+strlen("chargingProfileId")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempchargingProfileId = atoi(sstr);
- }
- else
- {
- tempchargingProfileId = 0;
- }
- //***********stackLevel**************/
- c = 0;
- loc = strstr(sLineWord, "stackLevel");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[2+strlen("stackLevel")+c] != '\"')
- {
- sstr[c] = loc[2+strlen("stackLevel")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempstackLevel = atoi(sstr);
- }
- else
- {
- tempstackLevel = 0;
- }
- //***********chargingProfilePurpose **************/
- c = 0;
- loc = strstr(sLineWord, "chargingProfilePurpose");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingProfilePurposeStr,sstr);
- }
- else
- {
- strcpy(tempchargingProfilePurposeStr,"");
- }
- //***********chargingProfileKind **************/
- c = 0;
- loc = strstr(sLineWord, "chargingProfileKind");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("chargingProfileKind")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfileKind")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingProfileKindStr,sstr);
- }
- else
- {
- strcpy(tempchargingProfileKindStr,"");
- }
- //***********recurrencyKind **************/
- c = 0;
- loc = strstr(sLineWord, "recurrencyKind");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("recurrencyKind")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("recurrencyKind")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(temprecurrencyKindStr,sstr);
- }
- else
- {
- strcpy(temprecurrencyKindStr,"");
- }
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "validFrom");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidFromStr,sstr);
- }
- else
- {
- strcpy(tempvalidFromStr,"");
- }
- //***********validTo **************/
- c = 0;
- loc = strstr(sLineWord, "validTo");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("validTo")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validTo")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidToStr,sstr);
- }
- else
- {
- strcpy(tempvalidToStr,"");
- }
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "validFrom");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidFromStr,sstr);
- }
- else
- {
- strcpy(tempvalidFromStr,"");
- }
- //***********validTo **************/
- c = 0;
- loc = strstr(sLineWord, "validTo");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validTo")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validTo")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidToStr,sstr);
- }
- else
- {
- strcpy(tempvalidToStr,"");
- }
- //***********duration**************/
- c = 0;
- loc = strstr(sLineWord, "duration");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[2+strlen("duration")+c] != ',')
- {
- sstr[c] = loc[2+strlen("duration")+c];
- c++;
- }
- sstr[c] = '\0';
- tempdurationInt = atoi(sstr);
- }
- else
- {
- tempdurationInt = 0;
- }
- //**********startSchedule**********/
- c = 0;
- loc = strstr(sLineWord, "startSchedule");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("startSchedule")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startSchedule")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempstartScheduleStr, sstr);
- strcpy(ChargePointMaxProfileScheduleStr, sstr);
- //**********chargingRateUnit**********/
- c = 0;
- loc = strstr(sLineWord, "chargingRateUnit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingRateUnitStr, sstr);
- //**********minChargingRate*******/
- c = 0;
- loc = strstr(sLineWord, "minChargingRate");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[2+strlen("minChargingRate")+c] != ',')&&(loc[2+strlen("minChargingRate")+c] != '}'))
- {
- sstr[c] = loc[2+strlen("minChargingRate")+c];
- c++;
- }
- sstr[c] = '\0';
- tempminChargingRateFloat = atof(sstr);
- }
- else
- {
- tempminChargingRateFloat = 0.0;
- }
- //
- strptime(tempstartScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- time_t utc = mktime(&tp);
- time_t t = time(NULL);
- diff_t = difftime(t, utc);
- //DEBUG_INFO("diff_t=%f\n",diff_t);
- //parsing strings to words
- i = 0;
- loc = strstr(sLineWord, "chargingSchedulePeriod");
- loc = loc+3+strlen("chargingSchedulePeriod");
- pch = strtok(loc ,"{");
- while (pch != NULL)
- {
- strcpy(SchedulePeriodList[i], pch);
- pch = strtok (NULL, "{");
- i = i + 1;
- }
- n_SchedulePeriods = i;
- for(int i=0;i<n_SchedulePeriods;i++)
- {
- //*************startPeriod****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "startPeriod");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("startPeriod")+2+c] != ',')
- {
- sstr[c] = loc[strlen("startPeriod")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempStartPeriodInt = atoi(sstr);
- //*************limit****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "limit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("limit")+2+c] != ',')
- {
- sstr[c] = loc[strlen("limit")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempLimitInt = atof(sstr);
- //*************numberPhases****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "numberPhases");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("numberPhases")+2+c] != '}')
- {
- sstr[c] = loc[strlen("numberPhases")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempNumberPhasesInt = atoi(sstr);
- if(j == 0)
- {
- ChargePointMaxProfile.Duration = tempdurationInt;
- ChargePointMaxProfile.TotalPeriod = n_SchedulePeriods;
- ChargePointMaxProfile.Period[i].Limit = tempLimitInt;
- ChargePointMaxProfile.Period[i].NumberPhases = tempNumberPhasesInt;
- ChargePointMaxProfile.Period[i].StartPeriod = tempStartPeriodInt;
- ChargePointMaxProfile_TEMP.ChargingProfileId = tempchargingProfileId;
- ChargePointMaxProfile_TEMP.StackLevel = tempstackLevel;
- ChargePointMaxProfile_TEMP.TransactionId = 0;
- strcpy((char *)ChargePointMaxProfile_TEMP.ChargingSchedule.ChargingRateUnit, (const char *)tempchargingRateUnitStr);
- strcpy((char *)ChargePointMaxProfile_TEMP.ChargingProfileKind, (const char *)tempchargingProfileKindStr);
- strcpy((char *)ChargePointMaxProfile_TEMP.ChargingProfilePurpose, (const char *)tempchargingProfilePurposeStr);
- strcpy((char *)ChargePointMaxProfile_TEMP.RecurrencyKind, (const char *)temprecurrencyKindStr);
- strcpy((char *)ChargePointMaxProfile_TEMP.ChargingSchedule.StartSchedule, (const char *)tempstartScheduleStr);
- strcpy((char *)ChargePointMaxProfile_TEMP.ValidFrom, (const char *)tempvalidFromStr);
- strcpy((char *)ChargePointMaxProfile_TEMP.ValidTo, (const char *)tempvalidToStr);
- }
- }
- if(MinChargingRate < tempminChargingRateFloat)
- {
- MinChargingRate = tempminChargingRateFloat;
- }
- ChargePointMaxProfile_TEMP.ChargingSchedule.MinChargingRate = MinChargingRate;
- if(confirmPeriods < n_SchedulePeriods)
- {
- confirmPeriods = n_SchedulePeriods;
- }
- j = j + 1;
- }
- fclose(fptr1);
- }
- }// the end of access file ChargePointMaxProfile
- //****************************TxDefaultProfile************************************************/
- switch(gunindex + 1)
- {
- case 0:
- strcpy(fname, TxDefaultProfile_0_JSON );
- break;
- case 1:
- strcpy(fname, TxDefaultProfile_1_JSON );
- break;
- case 2:
- strcpy(fname, TxDefaultProfile_2_JSON );
- break;
- default:
- strcpy(fname, TxDefaultProfile_1_JSON );
- break;
- }
- TxDefaultProfileFileIsNull=TRUE;
- if((access(fname,F_OK))!=-1)
- {
- fptr1 = fopen(fname, "r");
- c = 0;
- c = fgetc(fptr1);
- //DEBUG_INFO("c:%d\n",c);
- rewind(fptr1);
- if(c == EOF)
- {
- DEBUG_INFO("\n End of file reached.");
- TxDefaultProfileFileIsNull=TRUE;
- fclose(fptr1);
- }
- else
- {
- TxDefaultProfileFileIsNull=FALSE;
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- if(strcmp(word, "chargingProfileId") == 0)
- {
- n_chargingProfile = n_chargingProfile + 1;
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- int i = 0;
- int j = 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL ) {
- #if 0
- /***********connectorId****************/
- c = 0;
- loc = strstr(sLineWord, "connectorId");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempconnectorIdInt = atoi(sstr);
- #endif
- //***********chargingProfileId**************/
- c = 0;
- loc = strstr(sLineWord, "chargingProfileId");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[2+strlen("chargingProfileId")+c] != '\"')
- {
- sstr[c] = loc[2+strlen("chargingProfileId")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempchargingProfileId = atoi(sstr);
- }
- else
- {
- tempchargingProfileId = 0;
- }
- //***********stackLevel**************/
- c = 0;
- loc = strstr(sLineWord, "stackLevel");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[2+strlen("stackLevel")+c] != '\"')
- {
- sstr[c] = loc[2+strlen("stackLevel")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempstackLevel = atoi(sstr);
- }
- else
- {
- tempstackLevel = 0;
- }
- //***********chargingProfilePurpose **************/
- c = 0;
- loc = strstr(sLineWord, "chargingProfilePurpose");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingProfilePurposeStr,sstr);
- }
- else
- {
- strcpy(tempchargingProfilePurposeStr,"");
- }
- //***********chargingProfileKind **************/
- c = 0;
- loc = strstr(sLineWord, "chargingProfileKind");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("chargingProfileKind")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfileKind")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingProfileKindStr,sstr);
- }
- else
- {
- strcpy(tempchargingProfileKindStr,"");
- }
- //***********recurrencyKind **************/
- c = 0;
- loc = strstr(sLineWord, "recurrencyKind");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("recurrencyKind")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("recurrencyKind")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(temprecurrencyKindStr,sstr);
- }
- else
- {
- strcpy(temprecurrencyKindStr,"");
- }
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "validFrom");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidFromStr,sstr);
- }
- else
- {
- strcpy(tempvalidFromStr,"");
- }
- //***********validTo **************/
- c = 0;
- loc = strstr(sLineWord, "validTo");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validTo")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validTo")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidToStr,sstr);
- }
- else
- {
- strcpy(tempvalidToStr,"");
- }
- //***********duration**************/
- c = 0;
- loc = strstr(sLineWord, "duration");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[2+strlen("duration")+c] != ',')
- {
- sstr[c] = loc[2+strlen("duration")+c];
- c++;
- }
- sstr[c] = '\0';
- tempdurationInt = atoi(sstr);
- }
- else
- {
- tempdurationInt = 0;
- }
- //**********startSchedule**********/
- c = 0;
- loc = strstr(sLineWord, "startSchedule");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("startSchedule")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startSchedule")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempstartScheduleStr, sstr);
- strcpy(TxDefaultProfileScheduleStr, sstr);
- //**********chargingRateUnit**********/
- c = 0;
- loc = strstr(sLineWord, "chargingRateUnit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingRateUnitStr, sstr);
- //**********minChargingRate*******/
- c = 0;
- loc = strstr(sLineWord, "minChargingRate");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[2+strlen("minChargingRate")+c] != ',')&&(loc[2+strlen("minChargingRate")+c] != '}'))
- {
- sstr[c] = loc[2+strlen("minChargingRate")+c];
- c++;
- }
- sstr[c] = '\0';
- tempminChargingRateFloat = atof(sstr);
- }
- else
- {
- tempminChargingRateFloat = 0.0;
- }
- //
- strptime(tempstartScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- time_t utc = mktime(&tp);
- time_t t = time(NULL);
- diff_t = difftime(t, utc);
- printf("diff between startScheduleStr and now =%f\n",diff_t);
- //parsing strings to words
- i = 0;
- loc = strstr(sLineWord, "chargingSchedulePeriod");
- loc = loc+3+strlen("chargingSchedulePeriod");
- pch = strtok(loc ,"{");
- while (pch != NULL)
- {
- strcpy(SchedulePeriodList[i], pch);
- pch = strtok (NULL, "{");
- i = i + 1;
- }
- n_SchedulePeriods = i;
- for(int i=0;i<n_SchedulePeriods;i++)
- {
- //*************startPeriod****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "startPeriod");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("startPeriod")+2+c] != ',')
- {
- sstr[c] = loc[strlen("startPeriod")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempStartPeriodInt = atoi(sstr);
- //*************limit****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "limit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("limit")+2+c] != ',')
- {
- sstr[c] = loc[strlen("limit")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempLimitInt = atof(sstr);
- //*************numberPhases****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "numberPhases");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("numberPhases")+2+c] != '}')
- {
- sstr[c] = loc[strlen("numberPhases")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempNumberPhasesInt = atoi(sstr);
- if(j == 0)
- {
- TxDefaultProfile.Duration = tempdurationInt;
- TxDefaultProfile.TotalPeriod = n_SchedulePeriods;
- TxDefaultProfile.Period[i].Limit = tempLimitInt;
- TxDefaultProfile.Period[i].NumberPhases = tempNumberPhasesInt;
- TxDefaultProfile.Period[i].StartPeriod = tempStartPeriodInt;
- TxDefaultProfile_TEMP.ChargingProfileId = tempchargingProfileId;
- TxDefaultProfile_TEMP.StackLevel = tempstackLevel;
- TxDefaultProfile_TEMP.TransactionId = 0;
- TxDefaultProfile_TEMP.ChargingSchedule.Duration = tempdurationInt;
- strcpy((char *)TxDefaultProfile_TEMP.ChargingSchedule.ChargingRateUnit, (const char *)tempchargingRateUnitStr);
- strcpy((char *)TxDefaultProfile_TEMP.ChargingProfileKind, (const char *)tempchargingProfileKindStr);
- strcpy((char *)TxDefaultProfile_TEMP.ChargingProfilePurpose, (const char *)tempchargingProfilePurposeStr);
- strcpy((char *)TxDefaultProfile_TEMP.RecurrencyKind, (const char *)temprecurrencyKindStr);
- strcpy((char *)TxDefaultProfile_TEMP.ChargingSchedule.StartSchedule, (const char *)tempstartScheduleStr);
- strcpy((char *)TxDefaultProfile_TEMP.ValidFrom, (const char *)tempvalidFromStr);
- strcpy((char *)TxDefaultProfile_TEMP.ValidTo, (const char *)tempvalidToStr);
- }
- else
- {
- //other stack level charging Profile
- TxDefaultProfiletemp[j-1].Period[i].Limit = tempLimitInt;
- TxDefaultProfiletemp[j-1].Period[i].NumberPhases = tempNumberPhasesInt;
- TxDefaultProfiletemp[j-1].Period[i].StartPeriod = tempStartPeriodInt;
- TxDefaultProfiletemp[j-1].Duration = tempdurationInt;
- TxDefaultProfiletemp[j-1].TotalPeriod = n_SchedulePeriods;
- }
- }
- if(MinChargingRate < tempminChargingRateFloat)
- {
- MinChargingRate = tempminChargingRateFloat;
- }
- TxDefaultProfile_TEMP.ChargingSchedule.MinChargingRate = MinChargingRate;
- if(confirmPeriods < n_SchedulePeriods)
- confirmPeriods = n_SchedulePeriods;
- j = j + 1;
- }
- fclose(fptr1);
- //Stacking Charging Profiles
- for(int l=0; l <(j-1) ;l++)
- {
- for(int k=0; k < TxDefaultProfiletemp[l].TotalPeriod; k++)
- {
- if(TxDefaultProfiletemp[l].Period[k].StartPeriod > TxDefaultProfile.Duration)
- {
- if((k >0) && ((TxDefaultProfiletemp[l].Period[k-1].StartPeriod < TxDefaultProfile.Duration) &&(TxDefaultProfiletemp[l].Period[k-1].StartPeriod >= TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod-1].StartPeriod )))
- {
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].Limit = TxDefaultProfiletemp[l].Period[k-1].Limit;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].NumberPhases = TxDefaultProfiletemp[l].Period[k-1].NumberPhases;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].StartPeriod = TxDefaultProfile.Duration;
- TxDefaultProfile.TotalPeriod = TxDefaultProfile.TotalPeriod + 1;
- TxDefaultProfile.Duration = TxDefaultProfiletemp[l].Duration;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].Limit = TxDefaultProfiletemp[l].Period[k].Limit;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].NumberPhases = TxDefaultProfiletemp[l].Period[k].NumberPhases;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].StartPeriod = TxDefaultProfiletemp[l].Period[k].StartPeriod;
- TxDefaultProfile.TotalPeriod = TxDefaultProfile.TotalPeriod + 1;
- TxDefaultProfile.Duration = TxDefaultProfiletemp[l].Duration;
- }
- else
- {
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].Limit = TxDefaultProfiletemp[l].Period[k].Limit;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].NumberPhases = TxDefaultProfiletemp[l].Period[k].NumberPhases;
- TxDefaultProfile.Period[TxDefaultProfile.TotalPeriod].StartPeriod = TxDefaultProfiletemp[l].Period[k].StartPeriod;
- TxDefaultProfile.TotalPeriod = TxDefaultProfile.TotalPeriod + 1;
- TxDefaultProfile.Duration = TxDefaultProfiletemp[l].Duration;
- }
- }
- }
- }
- //end of Stacking Charging Profiles
- }
- }// the end of ACCESS TxDefaultProfile
- //****************************TxProfile************************************************/
- switch(gunindex + 1)
- {
- case 0:
- break;
- case 1:
- strcpy(fname, TxProfile_1_JSON );
- break;
- case 2:
- strcpy(fname, TxProfile_2_JSON );
- break;
- default:
- strcpy(fname, TxProfile_1_JSON );
- break;
- }
- TxProfileIsNull=TRUE;
- if((access(fname,F_OK))!=-1)
- {
- fptr1 = fopen(fname, "r");
- c = 0;
- c = fgetc(fptr1);
- //DEBUG_INFO("c:%d\n",c);
- rewind(fptr1);
- if(c == EOF)
- {
- DEBUG_INFO("\n End of file reached.");
- TxProfileIsNull=TRUE;
- fclose(fptr1);
- }
- else
- {
- TxProfileIsNull=FALSE;
- while(fscanf(fptr1, "%s", word) != EOF)
- {
- if(strcmp(word, "chargingProfileId") == 0)
- {
- n_chargingProfile = n_chargingProfile + 1;
- }
- }
- rewind(fptr1);
- //search Charging Profile Element
- int i= 0;
- int j= 0;
- while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL ) {
- #if 0
- /***********connectorId****************/
- c = 0;
- loc = strstr(sLineWord, "connectorId");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("connectorId")+2+c] != ',')
- {
- sstr[c] = loc[strlen("connectorId")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempconnectorIdInt = atoi(sstr);
- #endif
- //***********chargingProfileId**************/
- c = 0;
- loc = strstr(sLineWord, "chargingProfileId");
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[2+strlen("chargingProfileId")+c] != '\"')
- {
- sstr[c] = loc[2+strlen("chargingProfileId")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempchargingProfileId = atoi(sstr);
- }
- else
- {
- tempchargingProfileId = 0;
- }
- //***********transactionId **************/
- c = 0;
- loc = strstr(sLineWord, "transactionId");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[2+strlen("transactionId")+c] != '\"')
- {
- sstr[c] = loc[2+strlen("transactionId")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- temptransactionId = atoi(sstr);
- }
- else
- {
- temptransactionId = 0;
- }
- //***********stackLevel**************/
- c = 0;
- loc = strstr(sLineWord, "stackLevel");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[2+strlen("stackLevel")+c] != '\"')
- {
- sstr[c] = loc[2+strlen("stackLevel")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempstackLevel = atoi(sstr);
- }
- else
- {
- tempstackLevel = 0;
- }
- //***********chargingProfilePurpose **************/
- c = 0;
- loc = strstr(sLineWord, "chargingProfilePurpose");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingProfilePurposeStr,sstr);
- }
- else
- {
- strcpy(tempchargingProfilePurposeStr,"");
- }
- //***********chargingProfileKind **************/
- c = 0;
- loc = strstr(sLineWord, "chargingProfileKind");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("chargingProfileKind")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingProfileKind")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingProfileKindStr,sstr);
- }
- else
- {
- strcpy(tempchargingProfileKindStr,"");
- }
- //***********recurrencyKind **************/
- c = 0;
- loc = strstr(sLineWord, "recurrencyKind");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[3+strlen("recurrencyKind")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("recurrencyKind")+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- strcpy(temprecurrencyKindStr,sstr);
- }
- else
- {
- strcpy(temprecurrencyKindStr,"");
- }
- //***********validFrom**************/
- c = 0;
- loc = strstr(sLineWord, "validFrom");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validFrom")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validFrom")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidFromStr,sstr);
- }
- else
- {
- strcpy(tempvalidFromStr,"");
- }
- //***********validTo**************/
- c = 0;
- loc = strstr(sLineWord, "validTo");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("validTo")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("validTo")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempvalidToStr,sstr);
- }
- else
- {
- strcpy(tempvalidToStr,"");
- }
- //***********duration**************/
- c = 0;
- loc = strstr(sLineWord, "duration");
- //DEBUG_INFO("loc=%s\n",loc);
- memset(sstr ,0, sizeof(sstr) );
- if(loc != NULL)
- {
- while (loc[2+strlen("duration")+c] != '\"')
- {
- sstr[c] = loc[2+strlen("duration")+c];
- c++;
- }
- sstr[c] = '\0';
- tempdurationInt = atoi(sstr);
- }
- else
- {
- tempdurationInt = 0;
- }
- //**********startSchedule**********/
- c = 0;
- loc = strstr(sLineWord, "startSchedule");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("startSchedule")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("startSchedule")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempstartScheduleStr, sstr);
- strcpy(TxProfileScheduleStr, sstr);
- //**********chargingRateUnit**********/
- c = 0;
- loc = strstr(sLineWord, "chargingRateUnit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[3+strlen("chargingRateUnit")+c] != '\"')
- {
- sstr[c] = loc[3+strlen("chargingRateUnit")+c];
- c++;
- }
- sstr[c] = '\0';
- strcpy(tempchargingRateUnitStr, sstr);
- //**********minChargingRate*******/
- c = 0;
- loc = strstr(sLineWord, "minChargingRate");
- if(loc != NULL)
- {
- memset(sstr ,0, sizeof(sstr) );
- while ((loc[2+strlen("minChargingRate")+c] != ',')&&(loc[2+strlen("minChargingRate")+c] != '}'))
- {
- sstr[c] = loc[2+strlen("minChargingRate")+c];
- c++;
- }
- sstr[c] = '\0';
- tempminChargingRateFloat = atof(sstr);
- }
- else
- {
- tempminChargingRateFloat = 0.0;
- }
- //
- strptime(tempstartScheduleStr, "%Y-%m-%dT%H:%M:%S", &tp);
- tp.tm_isdst = -1;
- time_t utc = mktime(&tp);
- time_t t = time(NULL);
- diff_t = difftime(t, utc);
- //DEBUG_INFO("diff_t=%f\n",diff_t);
- //parsing strings to words
- i = 0;
- loc = strstr(sLineWord, "chargingSchedulePeriod");
- loc = loc+3+strlen("chargingSchedulePeriod");
- pch = strtok(loc ,"{");
- while (pch != NULL)
- {
- strcpy(SchedulePeriodList[i], pch);
- pch = strtok (NULL, "{");
- i = i + 1;
- }
- n_SchedulePeriods = i;
- for(int i=0;i<n_SchedulePeriods;i++)
- {
- //*************startPeriod****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "startPeriod");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("startPeriod")+2+c] != ',')
- {
- sstr[c] = loc[strlen("startPeriod")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempStartPeriodInt = atoi(sstr);
- //*************limit****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "limit");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("limit")+2+c] != ',')
- {
- sstr[c] = loc[strlen("limit")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempLimitInt = atof(sstr);
- //*************numberPhases****************/
- c = 0;
- loc = strstr(SchedulePeriodList[i], "numberPhases");
- memset(sstr ,0, sizeof(sstr) );
- while (loc[strlen("numberPhases")+2+c] != '}')
- {
- sstr[c] = loc[strlen("numberPhases")+2+c];
- //printf("i=%d sstr=%c\n",c, sstr[c]);
- c++;
- }
- sstr[c] = '\0';
- tempNumberPhasesInt = atoi(sstr);
- //TxProfile.Duration = durationInt;
- TxProfile.TotalPeriod = n_SchedulePeriods;
- TxProfile.Period[i].Limit = tempLimitInt;
- TxProfile.Period[i].NumberPhases = tempNumberPhasesInt;
- TxProfile.Period[i].StartPeriod = tempStartPeriodInt;
- }
- if(MinChargingRate < tempminChargingRateFloat)
- {
- MinChargingRate = tempminChargingRateFloat;
- }
- TxProfile_TEMP.ChargingSchedule.MinChargingRate = MinChargingRate;
- if(confirmPeriods < n_SchedulePeriods)
- confirmPeriods = n_SchedulePeriods;
- if(j == 0)
- {
- TxProfile_TEMP.ChargingProfileId = tempchargingProfileId;
- TxProfile_TEMP.StackLevel = tempstackLevel;
- TxProfile_TEMP.TransactionId = 0;
- TxProfile_TEMP.ChargingSchedule.Duration = tempdurationInt;
- strcpy((char *)TxProfile_TEMP.ChargingSchedule.ChargingRateUnit, (const char *)tempchargingRateUnitStr);
- strcpy((char *)TxProfile_TEMP.ChargingProfileKind, (const char *)tempchargingProfileKindStr);
- strcpy((char *)TxProfile_TEMP.ChargingProfilePurpose, (const char *)tempchargingProfilePurposeStr);
- strcpy((char *)TxProfile_TEMP.RecurrencyKind, (const char *)temprecurrencyKindStr);
- strcpy((char *)TxProfile_TEMP.ChargingSchedule.StartSchedule, (const char *)tempstartScheduleStr);
- strcpy((char *)TxProfile_TEMP.ValidFrom, (const char *)tempvalidFromStr);
- strcpy((char *)TxProfile_TEMP.ValidTo, (const char *)tempvalidToStr);
- }
- }
- fclose(fptr1);
- }
- }// the end of ACCESS TxProfile
- //CompositeSchedule
- int period=0;
- if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==FALSE) && (TxProfileIsNull==FALSE) )
- {
- //TxProfile
- strcpy(CurrentChargingProfileScheduleStr,TxProfileScheduleStr);
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId = TxProfile_TEMP.ChargingProfileId;
- ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId = temptransactionId;
- ShmOCPP16Data->SmartChargingProfile[gunindex].StackLevel = TxProfile_TEMP.StackLevel;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.Duration = TxProfile_TEMP.ChargingSchedule.Duration ;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.MinChargingRate = TxProfile_TEMP.ChargingSchedule.MinChargingRate;
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingRateUnit, (const char *)TxProfile_TEMP.ChargingSchedule.ChargingRateUnit);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileKind, (const char *)TxProfile_TEMP.ChargingProfileKind );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfilePurpose, (const char *)TxProfile_TEMP.ChargingProfilePurpose );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.StartSchedule,(const char *)TxProfile_TEMP.ChargingSchedule.StartSchedule);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].RecurrencyKind, (const char *)TxProfile_TEMP.RecurrencyKind);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidFrom, (const char *)TxProfile_TEMP.ValidFrom);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidTo, (const char *)TxProfile_TEMP.ValidTo);
- for(int k=0; k < TxProfile.TotalPeriod;k++)
- {
- if(TxProfile.Period[k].Limit < ChargePointMaxProfile.Period[0].Limit)
- {
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period].Limit = TxProfile.Period[k].Limit;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxProfile.Period[k].NumberPhases;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxProfile.Period[k].StartPeriod;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = TxProfile.Period[k].Limit;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxProfile.Period[k].NumberPhases;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxProfile.Period[k].StartPeriod;
- period = period + 1;
- }
- else
- {
- if( (TxProfile.Period[k-1].Limit >= ChargePointMaxProfile.Period[0].Limit) && (TxProfile.Period[k].Limit >= ChargePointMaxProfile.Period[0].Limit))
- {
- }
- else
- {
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxProfile.Period[k].NumberPhases;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxProfile.Period[k].StartPeriod;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxProfile.Period[k].NumberPhases;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxProfile.Period[k].StartPeriod;
- period = period + 1;
- }
- }
- }
- for(int l=0; l < TxDefaultProfile.TotalPeriod;l++)
- {
- if((TxDefaultProfile.Period[l].StartPeriod < 86400)&&(TxDefaultProfile.Period[l].StartPeriod > ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period-1].StartPeriod))
- {
- if(TxDefaultProfile.Period[l].Limit < ChargePointMaxProfile.Period[0].Limit)
- {
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period].Limit = TxDefaultProfile.Period[l].Limit;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = TxDefaultProfile.Period[l].Limit;
- }
- else
- {
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].Limit = ChargePointMaxProfile.Period[0].Limit;
- }
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[period].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- period = period + 1;
- }
- }
- }
- else if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==FALSE) && (TxProfileIsNull==TRUE) )
- {
- //TxDefaultProfile
- strcpy(CurrentChargingProfileScheduleStr,TxDefaultProfileScheduleStr);
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId = TxDefaultProfile_TEMP.ChargingProfileId;
- ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId = 0;
- ShmOCPP16Data->SmartChargingProfile[gunindex].StackLevel = TxDefaultProfile_TEMP.StackLevel;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.Duration = TxDefaultProfile_TEMP.ChargingSchedule.Duration ;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.MinChargingRate = TxDefaultProfile_TEMP.ChargingSchedule.MinChargingRate;
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingRateUnit, (const char *)TxDefaultProfile_TEMP.ChargingSchedule.ChargingRateUnit );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileKind, (const char *)TxDefaultProfile_TEMP.ChargingProfileKind );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfilePurpose, (const char *)TxDefaultProfile_TEMP.ChargingProfilePurpose );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.StartSchedule,(const char *)TxDefaultProfile_TEMP.ChargingSchedule.StartSchedule);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].RecurrencyKind, (const char *)TxDefaultProfile_TEMP.RecurrencyKind);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidFrom, (const char *)TxDefaultProfile_TEMP.ValidFrom);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidTo, (const char *)TxDefaultProfile_TEMP.ValidTo);
- for(int l=0; l < TxDefaultProfile.TotalPeriod;l++)
- {
- if(TxProfile.Period[l].Limit < ChargePointMaxProfile.Period[0].Limit)
- {
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].Limit = TxDefaultProfile.Period[l].Limit;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].Limit = TxDefaultProfile.Period[l].Limit;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- period = period + 1;
- }
- else
- {
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].Limit = ChargePointMaxProfile.Period[0].Limit;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].Limit = ChargePointMaxProfile.Period[0].Limit;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- period = period + 1;
- }
- }
- }
- else if((TxDefaultProfileFileIsNull==FALSE) && (ChargePointMaxProfileIsNull==TRUE) && (TxProfileIsNull==TRUE) )
- {
- //TxDefaultProfile
- strcpy(CurrentChargingProfileScheduleStr,TxDefaultProfileScheduleStr);
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId = TxDefaultProfile_TEMP.ChargingProfileId;
- ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId = 0;
- ShmOCPP16Data->SmartChargingProfile[gunindex].StackLevel = TxDefaultProfile_TEMP.StackLevel;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.Duration = TxDefaultProfile_TEMP.ChargingSchedule.Duration;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.MinChargingRate = TxDefaultProfile_TEMP.ChargingSchedule.MinChargingRate;
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingRateUnit, (const char *)TxDefaultProfile_TEMP.ChargingSchedule.ChargingRateUnit );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileKind, (const char *)TxDefaultProfile_TEMP.ChargingProfileKind );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfilePurpose, (const char *)TxDefaultProfile_TEMP.ChargingProfilePurpose );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.StartSchedule, (const char *)TxDefaultProfile_TEMP.ChargingSchedule.StartSchedule);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].RecurrencyKind, (const char *)TxDefaultProfile_TEMP.RecurrencyKind);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidFrom, (const char *)TxDefaultProfile_TEMP.ValidFrom);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidTo, (const char *)TxDefaultProfile_TEMP.ValidTo);
- for(int l=0; l < TxDefaultProfile.TotalPeriod;l++)
- {
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].Limit = TxDefaultProfile.Period[l].Limit;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].Limit = TxDefaultProfile.Period[l].Limit;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = TxDefaultProfile.Period[l].NumberPhases;
- //ShmOCPP16Data->GetCompositeSchedule[CompositeSceduleIndex].ResponseChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = TxDefaultProfile.Period[l].StartPeriod;
- period = period + 1;
- }
- }
- else if((TxDefaultProfileFileIsNull==TRUE) && (ChargePointMaxProfileIsNull==FALSE) && (TxProfileIsNull==TRUE) )
- {
- //ChargePointMaxProfile
- strcpy(CurrentChargingProfileScheduleStr,ChargePointMaxProfileScheduleStr);
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId = ChargePointMaxProfile_TEMP.ChargingProfileId;
- ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId = 0;
- ShmOCPP16Data->SmartChargingProfile[gunindex].StackLevel = ChargePointMaxProfile_TEMP.StackLevel;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.Duration = 86400 ;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.MinChargingRate = ChargePointMaxProfile_TEMP.ChargingSchedule.MinChargingRate;
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingRateUnit, (const char *)ChargePointMaxProfile_TEMP.ChargingSchedule.ChargingRateUnit );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileKind, (const char *)ChargePointMaxProfile_TEMP.ChargingProfileKind );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfilePurpose, (const char *)ChargePointMaxProfile_TEMP.ChargingProfilePurpose );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.StartSchedule, (const char *)ChargePointMaxProfile_TEMP.ChargingSchedule.StartSchedule);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].RecurrencyKind, (const char *)ChargePointMaxProfile_TEMP.RecurrencyKind);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidFrom, (const char *)ChargePointMaxProfile_TEMP.ValidFrom);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidTo, (const char *)ChargePointMaxProfile_TEMP.ValidTo);
- for(int l=0; l < ChargePointMaxProfile.TotalPeriod;l++)
- {
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].Limit = ChargePointMaxProfile.Period[l].Limit;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].NumberPhases = ChargePointMaxProfile.Period[l].NumberPhases;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[l].StartPeriod = ChargePointMaxProfile.Period[l].StartPeriod;
- period = period + 1;
- }
- }
- else if((TxDefaultProfileFileIsNull==TRUE) && (ChargePointMaxProfileIsNull==TRUE) && (TxProfileIsNull==FALSE) )
- {
- //TxProfile
- strcpy(CurrentChargingProfileScheduleStr,TxProfileScheduleStr);
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId = TxProfile_TEMP.ChargingProfileId;
- ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId = temptransactionId;
- ShmOCPP16Data->SmartChargingProfile[gunindex].StackLevel = TxProfile_TEMP.StackLevel;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.Duration = TxProfile_TEMP.ChargingSchedule.Duration ;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.MinChargingRate = TxProfile_TEMP.ChargingSchedule.MinChargingRate;
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingRateUnit, (const char *)TxProfile_TEMP.ChargingSchedule.ChargingRateUnit);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileKind, (const char *)TxProfile_TEMP.ChargingProfileKind );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfilePurpose, (const char *)TxProfile_TEMP.ChargingProfilePurpose );
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.StartSchedule,(const char *)TxProfile_TEMP.ChargingSchedule.StartSchedule);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].RecurrencyKind, (const char *)TxProfile_TEMP.RecurrencyKind);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidFrom, (const char *)TxProfile_TEMP.ValidFrom);
- strcpy((char *)ShmOCPP16Data->SmartChargingProfile[gunindex].ValidTo, (const char *)TxProfile_TEMP.ValidTo);
- for(int k=0; k < TxProfile.TotalPeriod;k++)
- {
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[k].Limit = TxProfile.Period[k].Limit;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[k].NumberPhases = TxProfile.Period[k].NumberPhases;
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[k].StartPeriod = TxProfile.Period[k].StartPeriod;
- }
- }
- confirmPeriods = period;
- DEBUG_INFO("confirmPeriods=%d\n",confirmPeriods);
- DEBUG_INFO("\nchargingProfileId =%d, transactionId =%d\n, stackLevel =%d, chargingProfilePurpose=%s, chargingProfileKind=%s, recurrencyKind =%s, validFrom =%s, validTo =%s, duration=%d , startSchedule =%s, chargingRateUnit=%s, minChargingRate=%f,"
- "startPeriod0 =%d, limit0=%f, numberPhases0=%d\n"
- "startPeriod1 =%d, limit1=%f, numberPhases1=%d\n"
- "startPeriod2 =%d, limit2=%f, numberPhases2=%d\n"
- "startPeriod3 =%d, limit3=%f, numberPhases3=%d\n"
- "startPeriod4 =%d, limit4=%f, numberPhases4=%d\n"
- "startPeriod5 =%d, limit5=%f, numberPhases5=%d\n"
- "startPeriod6 =%d, limit6=%f, numberPhases6=%d\n"
- "startPeriod7 =%d, limit7=%f, numberPhases7=%d\n"
- "startPeriod8 =%d, limit8=%f, numberPhases8=%d\n"
- "startPeriod9 =%d, limit9=%f, numberPhases9=%d\n",
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileId,
- ShmOCPP16Data->SmartChargingProfile[gunindex].TransactionId,
- ShmOCPP16Data->SmartChargingProfile[gunindex].StackLevel,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfilePurpose,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingProfileKind,
- ShmOCPP16Data->SmartChargingProfile[gunindex].RecurrencyKind,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ValidFrom,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ValidTo,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.Duration,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.StartSchedule,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingRateUnit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.MinChargingRate,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[0].StartPeriod,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[0].Limit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[0].NumberPhases,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[1].StartPeriod,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[1].Limit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[1].NumberPhases,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[2].StartPeriod,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[2].Limit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[2].NumberPhases,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[3].StartPeriod,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[3].Limit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[3].NumberPhases,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[4].StartPeriod,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[4].Limit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[4].NumberPhases,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[5].StartPeriod,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[5].Limit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[5].NumberPhases,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[6].StartPeriod,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[6].Limit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[6].NumberPhases,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[7].StartPeriod,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[7].Limit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[7].NumberPhases,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[8].StartPeriod,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[8].Limit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[8].NumberPhases,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[9].StartPeriod,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[9].Limit,
- ShmOCPP16Data->SmartChargingProfile[gunindex].ChargingSchedule.ChargingSchedulePeriod[9].NumberPhases);
- }
- void LWS_Send(char * str)
- {
- //=====================================================
- // Check InternetConn 0: disconnected, 1: connected
- //====================================================
- if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
- {
- DEBUG_INFO("\n offline now !!!\n");
- return;
- }
- pthread_mutex_lock(&lock);
- memset(SendBuffer,0,SendBufLen);
- sprintf((char *)SendBuffer, "%s", str);
- pthread_mutex_unlock(&lock);
- lws_callback_on_writable(wsi_client);
- lws_service(context, 10000);//timeout_ms
- }
|