123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328 |
- /*
- * Main.c
- *
- * Created on: 2019年8月6日
- * Author: 7564
- */
- #include <sys/time.h>
- #include <sys/timeb.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <sys/ioctl.h>
- #include <sys/socket.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <sys/shm.h>
- #include <sys/mman.h>
- #include <linux/wireless.h>
- #include <arpa/inet.h>
- #include <netinet/in.h>
- #include <unistd.h>
- #include <stdarg.h>
- #include <stdio.h> /*標準輸入輸出定義*/
- #include <stdlib.h> /*標準函數庫定義*/
- #include <unistd.h> /*Unix 標準函數定義*/
- #include <fcntl.h> /*檔控制定義*/
- #include <termios.h> /*PPSIX 終端控制定義*/
- #include <errno.h> /*錯誤號定義*/
- #include <errno.h>
- #include <string.h>
- #include <time.h>
- #include <ctype.h>
- #include <ifaddrs.h>
- #include <math.h>
- #include <stdbool.h>
- #include "../../define.h"
- #include "Config.h"
- #include "Module_EvComm.h"
- #include "Common.h"
- typedef unsigned char byte;
- #define NO_DEFINE 255
- #define OPTION_CNT 3
- #define STR_OPTION '-'
- #define OPTION_REFLASH 0x00000001
- #define OPTION_LOOP 0x00000002
- #define OPTION_TIME 0x00000004
- #define MAX_SUB_CMD_QUANTITY 16
- #define MAX_SUB_CMD_LENGTH 128
- #define STR_OPT_REFLASH 'f'
- #define STR_OPT_LOOP 'l'
- #define STR_OPT_TIME 't'
- #define TTY_PATH "/dev/tty"
- #define STTY_US "stty raw -echo -F "
- #define STTY_DEF "stty -raw echo -F "
- struct SysConfigAndInfo *ShmSysConfigAndInfo;
- struct StatusCodeData *ShmStatusCodeData;
- struct PrimaryMcuData *ShmPrimaryMcuData;
- struct CHAdeMOData *ShmCHAdeMOData;
- struct CcsData *ShmCcsData;
- struct GBTData *ShmGBTData;
- struct FanModuleData *ShmFanModuleData;
- struct RelayModuleData *ShmRelayModuleData;
- struct LedModuleData *ShmLedModuleData;
- struct PsuData *ShmPsuData;
- ChargerInfoData *ShmChargerInfo;
- PsuPositionInfoData *ShmPsuPosition;
- PsuGroupingInfoData *ShmPsuGrouping;
- struct OCPP16Data *ShmOCPP16Data;
- struct OCPP20Data *ShmOCPP20Data;
- struct ChargingInfoData *_chargingData[CONNECTOR_QUANTITY];
- struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
- char MultiSubCmd[MAX_SUB_CMD_QUANTITY][MAX_SUB_CMD_LENGTH];
- int totalSubCnt = 0;
- char *msg = "state : get gun state (index) \n"
- "card : scanning card (x) : \n"
- "gun : get gun plugit state (index) \n"
- "lock : get gun locked state (index) \n"
- "self : self test state (x) \n"
- "ver : ver of board (407 or index or rb or fan) \n"
- "ac : get ac relay state (x) \n"
- "gunchg: set gun start charging \n"
- "gunstp: set gun stop charging \n"
- "gunext: extend gun capability \n";
- bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData)
- {
- for (byte index = 0; index < CHAdeMO_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)
- {
- chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
- return true;
- }
- }
- for (byte index = 0; index < CCS_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)
- {
- chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
- return true;
- }
- }
- for (byte index = 0; index < GB_QUANTITY; index++)
- {
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)
- {
- chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
- return true;
- }
- }
- if(GENERAL_GUN_QUANTITY > 0 && target < GENERAL_GUN_QUANTITY)
- {
- chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ConnectorInfo[target].GeneralChargingData;
- return true;
- }
- return false;
- }
- bool FindAcChargingInfoData(byte target, struct ChargingInfoData **acChargingData)
- {
- if (target < AC_QUANTITY)
- {
- acChargingData[target] = &ShmSysConfigAndInfo->SysInfo.AcChargingData[target];
- return true;
- }
- return false;
- }
- int InitShareMemory()
- {
- int result = PASS;
- int MeterSMId;
- //initial ShmSysConfigAndInfo
- if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
- {
- result = FAIL;
- }
- else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- result = FAIL;
- }
- else
- {}
- //initial ShmStatusCodeData
- if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
- {
- result = FAIL;
- }
- else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- result = FAIL;
- }
- else
- {}
- if (CHAdeMO_QUANTITY > 0) {
- if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData),
- IPC_CREAT | 0777)) < 0) {
- result = FAIL;
- } else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0))
- == (void *) -1) {
- result = FAIL;
- } else {
- }
- }
- if (CCS_QUANTITY > 0) {
- if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData),
- IPC_CREAT | 0777)) < 0) {
- result = FAIL;
- } else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
- result = FAIL;
- } else {
- }
- }
- if (GB_QUANTITY > 0) {
- if ((MeterSMId = shmget(ShmGBTCommKey, sizeof(struct GBTData),
- IPC_CREAT | 0777)) < 0) {
- return 0;
- } else if ((ShmGBTData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
- return 0;
- }
- memset(ShmGBTData, 0, sizeof(struct GBTData));
- }
- if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), IPC_CREAT | 0777)) < 0)
- {
- result = FAIL;
- }
- else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- result = FAIL;
- }
- if ((MeterSMId = shmget(ShmFanBdKey, sizeof(struct FanModuleData), IPC_CREAT | 0777)) < 0)
- {
- result = FAIL;
- }
- else if ((ShmFanModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- result = FAIL;
- }
- if ((MeterSMId = shmget(ShmRelayBdKey, sizeof(struct RelayModuleData), IPC_CREAT | 0777)) < 0)
- {
- result = FAIL;
- }
- else if ((ShmRelayModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- result = FAIL;
- }
- if ((MeterSMId = shmget(ShmLedBdKey, sizeof(struct LedModuleData), 0777)) < 0)
- {
- result = FAIL;
- }
- else if ((ShmLedModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- result = FAIL;
- }
- if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), IPC_CREAT | 0777)) < 0)
- {
- result = FAIL;
- }
- else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- result = FAIL;
- }
- if ((MeterSMId = shmget(SM_ChargerInfoKey, sizeof(ChargerInfoData), IPC_CREAT | 0777)) < 0)
- {
- result = FAIL;
- }
- else if ((ShmChargerInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- result = FAIL;
- }
- if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
- {
- result = FAIL;
- }
- else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- result = FAIL;
- }
- if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
- {
- result = FAIL;
- }
- else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
- {
- result = FAIL;
- }
- if(result == PASS)
- {
- ShmPsuPosition = &ShmChargerInfo->PsuPosition;
- ShmPsuGrouping = &ShmChargerInfo->PsuGrouping;
- }
- return result;
- }
- void Get_Ocpp_TransactionId(int gun_index, char *transactionId)
- {
- if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
- {
- sprintf(transactionId, "%d", ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId);
- return;
- }
- if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
- {
- strcpy(transactionId, (char *)&ShmOCPP20Data->TransactionEvent [gun_index].transactionInfo.transactionId[0]);
- return;
- }
- sprintf(transactionId, "%d", 0);
- }
- static void get_char(char *word)
- {
- fd_set rfds;
- struct timeval tv;
- FD_ZERO(&rfds);
- FD_SET(0, &rfds);
- tv.tv_sec = 0;
- tv.tv_usec = 10; //wait input timout time
- //if input
- if (select(1, &rfds, NULL, NULL, &tv) > 0)
- {
- fgets(word, 128, stdin);
- }
- }
- // return command length
- int ParsingCmd(char *inputString, char *outputString)
- {
- bool valid = false, done = false;
- int len = 0, start = 0;
- for(int i = 0; i < strlen(inputString); i++)
- {
- if(!valid)
- {
- if(inputString[i] != ' ' && inputString[i] != '\0' && inputString[i] != '\r' && inputString[i] != '\n')
- {
- valid = true;
- start = i;
- }
- }
- else
- {
- if(inputString[i] == ' ' || inputString[i] == '\0' || inputString[i] == '\r' || inputString[i] == '\n' || len >= MAX_SUB_CMD_LENGTH)
- {
- done = true;
- break;
- }
- }
- len = (valid && !done) ? len + 1 : len;
- }
- if(valid)
- {
- memcpy(outputString, &inputString[start], len);
- outputString[len] = '\0';
- }
- return len;
- }
- bool IsOption(char *strCmd, unsigned int *opt)
- {
- int len = 0;
- char str_opt[OPTION_CNT] = {STR_OPT_REFLASH, STR_OPT_LOOP, STR_OPT_TIME};
- unsigned int opt_value[OPTION_CNT] = {OPTION_REFLASH, OPTION_LOOP, OPTION_TIME};
- len = strlen(strCmd);
- if(len == 2)
- {
- if(strCmd[0] == STR_OPTION)
- {
- for(int i = 0; i < OPTION_CNT; i++)
- {
- if(strCmd[1] == str_opt[i])
- {
- *opt |= opt_value[i];
- return true;
- }
- }
- }
- }
- return false;
- }
- // inputCmdString: console input string
- // outputCmdString: input string parsed
- // return command quantity
- int InputStringNormalize(char *inputCmdString, char *outputCmdString, unsigned int *opt)
- {
- int len = 0, cnt = 0, start = 0;
- int cmdLen = 0, totalLen = 0;
- len = strlen(inputCmdString);
- *opt = 0;
- if(len > 0)
- {
- while(start < len)
- {
- if(inputCmdString[start] != ' ' && inputCmdString[start] != '\0' &&
- inputCmdString[start] != '\r' && inputCmdString[start] != '\n')
- {
- cmdLen = ParsingCmd(&inputCmdString[start], &outputCmdString[totalLen]);
- if(cmdLen > 0)
- {
- //printf("Find %d Cmd: %s\r\n", cnt + 1, &outputCmdString[totalLen]);
- if(!IsOption(&outputCmdString[totalLen], opt))
- {
- outputCmdString[totalLen + cmdLen] = ' ';
- cnt++;
- totalLen += cmdLen + 1;
- }
- start += cmdLen;
- }
- }
- else
- {
- start++;
- }
- }
- outputCmdString[totalLen - 1] = '\0';
- }
- return cnt;
- }
- int MainAndSubCommandParsing(char *normalCmd, char *mainCmd, char *subCmd)
- {
- int len = 0, totalLen = 0;
- int quantity = 0;
- strcpy(mainCmd, "");
- strcpy(subCmd, "");
- totalLen = strlen(normalCmd);
- if(totalLen > 0)
- {
- len = ParsingCmd(normalCmd, mainCmd);
- //printf("Find MainCmd: %s\r\n", mainCmd);
- quantity = len > 0 ? (quantity + 1) : quantity;
- if(len > 0 && totalLen > len)
- {
- strcpy(subCmd, &normalCmd[len + 1]);
- //printf("Find SubCmd: %s\r\n", subCmd);
- len = strlen(subCmd);
- quantity = len > 0 ? (quantity + 1) : quantity;
- }
- }
- return quantity;
- }
- int GetCommandSring(char *outputCmdString)
- {
- int len = 0, cnt = 0;
- int cmdLen = 0, totalLen = 0;
- char word[128];
- memset(word, 0x00, sizeof(word));
- get_char(word);
- len = strlen(word);
- if(len == 0)
- {
- return -1;
- }
- int start = 0;
- while(start < len - 1)
- {
- if(word[start] != ' ' && word[start] != '\0')
- {
- cmdLen = ParsingCmd(&word[start], &outputCmdString[totalLen]);
- char newCmd[MAX_SUB_CMD_LENGTH];
- memset(newCmd, 0x00, MAX_SUB_CMD_LENGTH);
- memcpy(newCmd, &outputCmdString[totalLen], cmdLen);
- cnt = cmdLen > 0 ? cnt + 1 : cnt;
- totalLen += cmdLen + 1;
- start += cmdLen;
- }
- else
- {
- start++;
- }
- }
- return cnt;
- }
- bool IsLoopStopCmd(void)
- {
- bool stop = false;
- int cnt = 0;
- char cmd[256];
- char totalCmd[256];
- memset(cmd, 0x00, 256);
- memset(totalCmd, 0x00, 256);
- cnt = GetCommandSring(totalCmd);
- if(cnt > 0)
- {
- strcpy(&cmd[0], totalCmd);
- if(strcmp(&cmd[0], "c") == 0)
- {
- stop = true;
- }
- }
- return stop;
- }
- void ConsoleReflash(int groupCnt, int lineCnt)
- {
- for(int i = 0; i < groupCnt; i++)
- {
- for(int i = 0; i < lineCnt; i++)
- {
- printf("\033[1A");
- printf("\033[K");
- }
- }
- printf("\r");
- }
- int GetSubCommand(char *inputCmd)
- {
- unsigned int paraOpt = 0;
- int loopLimit = 0;
- char normalString[128];
- totalSubCnt = InputStringNormalize(inputCmd, normalString, ¶Opt);
- if(totalSubCnt > MAX_SUB_CMD_QUANTITY)
- {
- totalSubCnt = MAX_SUB_CMD_QUANTITY;
- }
- if(totalSubCnt > 0)
- {
- loopLimit = totalSubCnt > 1 ? totalSubCnt - 1 : 1;
- for(int i = 0; i < loopLimit; i++)
- {
- memset(&MultiSubCmd[i][0], 0x00, MAX_SUB_CMD_LENGTH);
- memset(&MultiSubCmd[i + 1][0], 0x00, MAX_SUB_CMD_LENGTH);
- MainAndSubCommandParsing(normalString, &MultiSubCmd[i][0], &MultiSubCmd[i + 1][0]);
- strcpy(normalString, &MultiSubCmd[i + 1][0]);
- }
- }
- return totalSubCnt;
- }
- void RunStatusProc(char *v1, char *v2)
- {
- printf("OrderCharging = %d \n", ShmSysConfigAndInfo->SysInfo.OrderCharging);
- printf("WaitForPlugit = %d \n", ShmSysConfigAndInfo->SysInfo.WaitForPlugit);
- if (strcmp(v1, "ac") == 0)
- {
- if (!FindAcChargingInfoData(0, &ac_chargingInfo[0]))
- {
- printf("FindChargingInfoData (AC) false \n");
- }
- printf("AC Status = %d \n", ac_chargingInfo[0]->ConnectorPlugIn);
- return;
- }
- int _index = atoi(v1);
- if (_index <= 3)
- {
- if (!FindChargingInfoData(_index, &_chargingData[0]))
- {
- printf ("FindChargingInfoData error\n");
- return;
- }
- if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0)
- {
- // get
- printf ("index = %x, status = %x (%d)\n", _index, _chargingData[_index]->SystemStatus, _chargingData[_index]->IsAvailable);
- printf ("SystemTimeoutFlag = %d, PageIndex = %d\n",
- ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag, ShmSysConfigAndInfo->SysInfo.PageIndex);
- printf("ConnectorAlarmCode = %s \n", _chargingData[_index]->ConnectorAlarmCode);
- printf("EvConnAlarmCode = %s \n", _chargingData[_index]->EvConnAlarmCode);
- printf("RemotenAlarmCode = %s \n", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[_index].RemotenAlarmCode);
- }
- else
- {
- // set
- _chargingData[_index]->SystemStatus = atoi(v2);
- }
- }
- else
- {
- if (!FindAcChargingInfoData(0, &ac_chargingInfo[0]))
- {
- printf("FindChargingInfoData (AC) false \n");
- }
- if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0)
- {
- // get
- printf ("AC Type, status = %x (%d)\n", ac_chargingInfo[0]->SystemStatus, ac_chargingInfo[0]->IsAvailable);
- }
- else
- {
- // set
- ac_chargingInfo[0]->SystemStatus = atoi(v2);
- }
- }
- }
- void RunCardProc(char *v1, char *v2)
- {
- if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0)
- {
- if (ShmSysConfigAndInfo->SysInfo.WaitForPlugit)
- {
- ShmSysConfigAndInfo->SysInfo.WaitForPlugit = 0x00;
- printf ("SysInfo.WaitForPlugit = %x \n", ShmSysConfigAndInfo->SysInfo.WaitForPlugit);
- }
- else
- {
- ShmSysConfigAndInfo->SysInfo.WaitForPlugit = 0x01;
- printf ("SysInfo.WaitForPlugit = %x \n", ShmSysConfigAndInfo->SysInfo.WaitForPlugit);
- }
- }
- else
- {
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
- memcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, v1, strlen(v1));
- ShmSysConfigAndInfo->SysConfig.UserId[strlen(v1)] = '\0';
- printf("StartUserId = %s \n", ShmSysConfigAndInfo->SysConfig.UserId);
- }
- }
- void RunGunPlugitProc(char *v1, char *v2)
- {
- if (strcmp(v1, "ac") == 0)
- {
- if (!FindAcChargingInfoData(0, &ac_chargingInfo[0]))
- {
- printf("FindChargingInfoData (AC) false \n");
- }
- if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0)
- {
- // get
- printf("ConnectorPlugIn = %d \n", ac_chargingInfo[0]->ConnectorPlugIn);
- }
- else
- {
- // set
- ac_chargingInfo[0]->ConnectorPlugIn = atoi(v2);
- }
- return;
- }
- int _index = atoi(v1);
- if (!FindChargingInfoData(_index, &_chargingData[0]))
- {
- printf("FindChargingInfoData error\n");
- return;
- }
- if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0)
- {
- // get
- printf("index = %x, plug it = %x\n", _index, _chargingData[_index]->ConnectorPlugIn);
- }
- else
- {
- // set
- _chargingData[_index]->ConnectorPlugIn = atoi(v2);
- }
- }
- void GetGunLockStatusProc(char *v1, char *v2)
- {
- int _index = atoi(v1);
- if (!FindChargingInfoData(_index, &_chargingData[0]))
- {
- printf("FindChargingInfoData error\n");
- return;
- }
- if (strcmp(v2, "-1") != 0 && strcmp(v2, "") != 0)
- {
- _chargingData[_index]->GunLocked = atoi(v2);
- }
- printf("Gun Locked Status = %d \n", _chargingData[_index]->GunLocked);
- }
- void SetSystemIDProc()
- {
- char *systemId = "Alston_Test";
- memcpy(&ShmSysConfigAndInfo->SysConfig.SystemId, systemId, strlen(systemId));
- }
- void RunSelfProc()
- {
- printf("self test status = %x\n", ShmSysConfigAndInfo->SysInfo.SelfTestSeq);
- }
- void ShowFwVer(void)
- {
- printf("\r\nPower Cabinet, Model Name: %s, SN: %s", ShmSysConfigAndInfo->SysConfig.ModelName, ShmSysConfigAndInfo->SysConfig.SerialNumber);
- printf("\r\n Csu Bootload: %s", ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev);
- //printf("\r\n Csu Kernel: %s", ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev);
- printf("\r\n Csu Kernel: ");
- for(int i = 0; i < strlen((char *)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev); i++)
- {
- if(ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev[i] != '\r' && ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev[i] != '\n')
- {
- printf("%c", ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev[i]);
- }
- }
- printf("\r\n Csu Root Fs: %s [%s]", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, ShmChargerInfo->SysMisc.SubVersion);
- printf("\r\n Csu Primary: %s", ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev);
- printf("\r\n Fan Module: %s", ShmSysConfigAndInfo->SysInfo.FanModuleFwRev);
- printf("\r\n Relay1 Module: %s", ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev);
- printf("\r\n Relay2 Module: %s", ShmSysConfigAndInfo->SysInfo.Relay2ModuleFwRev);
- for(int i = 0; i < ShmSysConfigAndInfo->SysInfo.DispenserInfo.DispenserQuantity; i++)
- {
- printf("\r\n\r\nDispenser[%d] Status: %d", i, ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].LocalStatus);
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].LocalStatus != _DS_None &&
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].LocalStatus != _DS_Timeout)
- {
- printf(", Model Name: %s", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].ModelName);
- printf("\r\n Csu Bootload: %s", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].CsuBootLoadFwRev);
- //printf("\r\n Csu Kernel: %s", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].CsuKernelFwRev);
- printf("\r\n Csu Kernel: ");
- for(int j = 0; j < strlen((char *)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].CsuKernelFwRev); j++)
- {
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].CsuKernelFwRev[j] != '\r' &&
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].CsuKernelFwRev[j] != '\n')
- {
- printf("%c", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].CsuKernelFwRev[j]);
- }
- }
- printf("\r\n Csu Root Fs: %s", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].CsuRootFsFwRev);
- printf("\r\n Csu Primary: %s", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].CsuPrimFwRev);
- printf("\r\n Fan Module: %s", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].FanModuleFwRev);
- printf("\r\n Relay Module: %s", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].RelayModuleFwRev);
- printf("\r\n Connector 1: %s", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].Connector1FwRev);
- printf("\r\n Connector 2: %s", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].Connector2FwRev);
- printf("\r\n Led Module: %s", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].LedModuleFwRev);
- }
- }
- printf("\r\n\r\n");
- }
- void GetFwVerProc(char *v1)
- {
- if (strcmp(v1, "407") == 0)
- {
- printf("407 FW Version = %s \n", ShmPrimaryMcuData->version);
- }
- else if (strcmp(v1, "0") == 0 || strcmp(v1, "1") == 0 || strcmp(v1, "2") == 0 || strcmp(v1, "3") == 0)
- {
- int _index = atoi(v1);
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[_index].Enable)
- {
- int dispenser = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[_index].ParentDispensetIndex;
- int ParentIndex = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[_index].GeneralChargingData.Index;
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].LocalStatus != _DS_None &&
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].LocalStatus != _DS_Timeout)
- {
- if(ParentIndex == 0)
- {
- printf("Gun %d FW Version = %s \n", _index, ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].Connector1FwRev);
- }
- else
- {
- printf("Gun %d FW Version = %s \n", _index, ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].Connector1FwRev);
- }
- }
- }
- else
- {
- printf("Gun %d is disable\r\n", _index);
- }
- }
- else if (strcmp(v1, "rb") == 0)
- {
- printf("RB1 Version = %s \n", ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev);
- printf("RB2 Version = %s \n", ShmSysConfigAndInfo->SysInfo.Relay2ModuleFwRev);
- }
- else if (strcmp(v1, "fan") == 0)
- {
- printf("FAN Version = %s \n", ShmSysConfigAndInfo->SysInfo.FanModuleFwRev);
- }
- else if (strcmp(v1, "dc") == 0)
- {
- printf("DC Main Version = %s \n", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
- }
- else if (strcmp(v1, "led") == 0)
- {
- printf("LED Version = %s \n", ShmSysConfigAndInfo->SysInfo.LedModuleFwRev);
- }
- }
- void CreateOneError(char *v1)
- {
- int value = atoi(v1);
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PrimaryStestFail = value;
- ShmSysConfigAndInfo->SysConfig.BillingData.isBilling = value;
- }
- void GetAuthorizeFlag(char *v1)
- {
- if (strcmp(v1, "-1") == 0|| strcmp(v1, "") == 0)
- printf("AuthorizeFlag = %d \n", ShmSysConfigAndInfo->SysInfo.AuthorizeFlag);
- else
- ShmSysConfigAndInfo->SysInfo.AuthorizeFlag = atoi(v1);
- }
- void GetOrClearId(char *v1)
- {
- int _index = atoi(v1);
- if (!FindChargingInfoData(_index, &_chargingData[0]))
- {
- printf("FindChargingInfoData error\n");
- return;
- }
- printf("Card Number = %s \n", _chargingData[_index]->StartUserId);
- }
- void FwUpdateFlagProc()
- {
- ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = 0x01;
- }
- void CheckAcStatus(char *v1)
- {
- if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0)
- {
- printf(" AC Contactor Ctrl: %d\r\n", ShmChargerInfo->Control.RelayCtrl.bits.AcContactor);
- printf(" AC Off By Psu : %d\r\n", ShmChargerInfo->Control.RelayCtrl.bits.AcContactorOffByPsu);
- printf(" AC Off ByEmergency: %d\r\n", ShmChargerInfo->Control.RelayCtrl.bits.AcContactorOffByEmergency);
- printf("AC Contactor Status: %d\r\n", ShmSysConfigAndInfo->SysInfo.AcContactorStatus);
- }
- else
- {
- if(system("pidof -s main > /dev/null") != 0)
- {
- if(strcmp(v1, "0") == 0)
- {
- ShmChargerInfo->Control.RelayCtrl.bits.AcContactor = false;
- ShmChargerInfo->Control.RelayCtrl.bits.AcContactorOffByPsu = false;
- ShmChargerInfo->Control.RelayCtrl.bits.AcContactorOffByEmergency = false;
- printf("Set AC Contactor Off\r\n");
- }
- else
- {
- ShmChargerInfo->Control.RelayCtrl.bits.AcContactor = true;
- ShmChargerInfo->Control.RelayCtrl.bits.AcContactorOffByPsu = false;
- ShmChargerInfo->Control.RelayCtrl.bits.AcContactorOffByEmergency = false;
- printf("Set AC Contactor On\r\n");
- }
- }
- else
- {
- printf("main task is running\r\n");
- }
- }
- }
- void SetCableChkStatus(char *v1, char *v2)
- {
- int _index = atoi(v1);
- if (!FindChargingInfoData(_index, &_chargingData[0]))
- {
- printf ("FindChargingInfoData error\n");
- return;
- }
- _chargingData[_index]->GroundFaultStatus = atoi(v2);
- }
- void SetPowerValue(char *v1, char *v2)
- {
- int _index = atoi(v1);
- float _Current = atof(v2);
- // 盲沖的時候才允許使用~
- if (_chargingData[_index]->Type != 9)
- return;
- if (!FindChargingInfoData(_index, &_chargingData[0]))
- {
- printf ("FindChargingInfoData error\n");
- return;
- }
- _chargingData[_index]->EvBatterytargetCurrent = _Current;
- }
- void GetSystemInfo(void)
- {
- printf ("Power Cabinet\r\n");
- printf (" -System ID: [%s]\r\n", (char *)&ShmSysConfigAndInfo->SysConfig.SystemId);
- printf (" -ModelName: [%s], SerialNumber: [%s]\r\n",
- (char *)&ShmSysConfigAndInfo->SysConfig.ModelName,
- (char *)&ShmSysConfigAndInfo->SysConfig.SerialNumber);
- printf (" -CSURootFs: %s [%s]\r\n", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, ShmChargerInfo->SysMisc.SubVersion);
- }
- bool SetModelName(char *modelName);
- void ModelNameCmd(char *inputCmd, unsigned int opt)
- {
- int totalCnt = 0, maxPara = 0;
- maxPara = 2;
- totalCnt = GetSubCommand(inputCmd);
- printf("\r\n");
- if(totalCnt == 0)
- {
- GetSystemInfo();
- printf("\r\n");
- return;
- }
- if(totalCnt != maxPara || strcmp(&MultiSubCmd[0][0], "set") != EQUAL)
- {
- printf("Input cmd fail ------ model [set] [model name]\r\n\r\n");
- return;
- }
- if(SetModelName(&MultiSubCmd[0][0]))
- {
- printf("\r\n");
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = true;
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashImmediately = true;
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashAndReset = true;
- }
- }
- bool SetSerialNumber(char *serialNumber);
- void SerialNumberCmd(char *inputCmd, unsigned int opt)
- {
- int totalCnt = 0, maxPara = 0;
- maxPara = 2;
- totalCnt = GetSubCommand(inputCmd);
- printf("\r\n");
- if(totalCnt != maxPara)
- {
- printf("Input cmd fail ------ model [set] [serial number]\r\n\r\n");
- return;
- }
- if(SetSerialNumber(&MultiSubCmd[1][0]))
- {
- printf("\r\n");
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = true;
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashImmediately = true;
- }
- }
- void SetFanSpeed(char *v1)
- {
- int speed = atoi(v1);
- ShmFanModuleData->TestFanSpeed = speed;
- }
- void GetFanSpeed()
- {
- printf("Target Speed = %d \n", ShmFanModuleData->TestFanSpeed);
- printf("ShmFanModuleData->PresentFan1Speed = %d \n", ShmFanModuleData->PresentFan1Speed);
- printf("ShmFanModuleData->PresentFan2Speed = %d \n", ShmFanModuleData->PresentFan2Speed);
- printf("ShmFanModuleData->PresentFan3Speed = %d \n", ShmFanModuleData->PresentFan3Speed);
- printf("ShmFanModuleData->PresentFan4Speed = %d \n", ShmFanModuleData->PresentFan4Speed);
- }
- void SetDebugMode(char *v1)
- {
- int mode = atoi(v1);
- ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag = mode;
- }
- void SetGFDMode(char *v1)
- {
- int mode = atoi(v1);
- ShmSysConfigAndInfo->SysConfig.AlwaysGfdFlag = mode;
- }
- // PSU 0 PSU 1 PSU 2 ...
- // Gun Temp Chiller DD/PFC/Amb DD/PFC/Amb DD/PFC/Amb DD/PFC/Amb
- // 1 XXX XXX XXX/XXX/XXX XXX/XXX/XXX XXX/XXX/XXX XXX/XXX/XXX
- void GetTemperature(char *inputCmd, unsigned int opt)
- {
- bool keepRun = false;
- bool reflash = false;
- int time = 0;
- struct timespec _Loop_time;
- char strGunTemp[16], strChillerTemp[16];
- if((opt & OPTION_REFLASH) || (opt & OPTION_LOOP) > 0)
- {
- keepRun = true;
- }
- printf("\r\n");
- printf(" PSU 0 PSU 1 PSU 2 .....\r\n");
- printf(" Gun Temp Chiller DD/PFC/Amb DD/PFC/Amb DD/PFC/Amb DD/PFC/Amb\r\n");
- do
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(time >= 1000)
- {
- if(reflash)
- {
- ConsoleReflash(CONNECTOR_QUANTITY, 1);
- }
- for(int i = 0; i < CONNECTOR_QUANTITY; i++)
- {
- sprintf(strGunTemp, "N/A");
- sprintf(strChillerTemp, "N/A");
- if(_chargingData[i]->ConnectorTemp != 0 && _chargingData[i]->ConnectorTemp != 0xFF)
- {
- sprintf(strGunTemp, "%3d", _chargingData[i]->ConnectorTemp - 60);
- }
- if(_chargingData[i]->ChillerTemp != 0 && _chargingData[i]->ChillerTemp != 0xFF)
- {
- sprintf(strChillerTemp, "%3d", _chargingData[i]->ChillerTemp - 60);
- }
- printf(" %d %s %s ", i + 1, strGunTemp, strChillerTemp);
- for(int j = 0; j < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; j++)
- {
- printf(" %3d/%3d/%3d",
- ShmPsuData->PsuGroup[i].PsuModule[j].ExletTemp,
- ShmPsuData->PsuGroup[i].PsuModule[j].InletTemp,
- ShmPsuData->PsuGroup[i].PsuModule[j].CriticalTemp1);
- }
- printf("\r\n");
- }
- GetClockTime(&_Loop_time);
- if((opt & OPTION_REFLASH) > 0)
- {
- reflash = true;
- }
- }
- if(keepRun)
- {
- keepRun = IsLoopStopCmd() ? false : true;
- usleep(10000);
- }
- }while(keepRun);
- }
- void GetInputVol(char *inputCmd, unsigned int opt)
- {
- bool keepRun = false;
- bool reflash = false;
- int time = 0;
- struct timespec _Loop_time;
- if((opt & OPTION_REFLASH) || (opt & OPTION_LOOP) > 0)
- {
- keepRun = true;
- }
- printf("\r\n");
- do
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(time >= 1000)
- {
- if(reflash)
- {
- ConsoleReflash(1, 1);
- }
- printf("L1N_L12 = %4.1f V, L2N_L23 = %4.1f V, L3N_L31 = %4.1f V, DC Input: %4.1f V\r\n",
- ShmSysConfigAndInfo->SysInfo.InputVoltageR,
- ShmSysConfigAndInfo->SysInfo.InputVoltageS,
- ShmSysConfigAndInfo->SysInfo.InputVoltageT,
- ShmSysConfigAndInfo->SysInfo.InputVoltageDc);
- GetClockTime(&_Loop_time);
- if((opt & OPTION_REFLASH) > 0)
- {
- reflash = true;
- }
- }
- if(keepRun)
- {
- keepRun = IsLoopStopCmd() ? false : true;
- usleep(10000);
- }
- }while(keepRun);
- printf("\r\n");
- }
- void GetPsuInformation(char *v1, char *v2, char *v3)
- {
- printf("**********************AC Contact needed*************************\n");
- if(strcmp(v1, "count") == 0)
- {
- for (int i = 0; i < 4; i++)
- {
- printf("Group Index = %d, Module Count = %d \n", i, ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity);
- }
- }
- else if(strcmp(v1, "ver") == 0)
- {
- for (int i = 0; i < ShmPsuData->SystemInitialPsuQuantity; i++)
- {
- printf("Psu Index = %d, PriVersion = %s, SecVersion = %s \n",
- i, ShmPsuData->PsuVersion[i].FwPrimaryVersion, ShmPsuData->PsuVersion[i].FwSecondVersion);
- }
- for (int i = 0; i < ShmPsuData->GroupCount; i++)
- {
- for (int j = 0; j < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; j++)
- {
- printf("Group Index = %d, Psu Index = %d, Version = %s \n",
- i, j, ShmPsuData->PsuGroup[i].PsuModule[j].FwVersion);
- }
- }
- }
- else if(strcmp(v1, "cap") == 0)
- {
- for (int i = 0; i < ShmPsuData->GroupCount; i++)
- {
- printf("Group Index = %d, MaxCur = %d, Power = %d \n",
- i, ShmPsuData->PsuGroup[i].GroupAvailableCurrent, ShmPsuData->PsuGroup[i].GroupAvailablePower);
- }
- }
- else if(strcmp(v1, "input") == 0)
- {
- for (int i = 0; i < ShmPsuData->GroupCount; i++)
- {
- for (byte count = 0; count < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; count++)
- {
- printf("gp = %d, Index = %d, volR = %d, volS = %d, volT = %d \n",
- i, count,
- ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL1,
- ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL2,
- ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL3);
- }
- }
- }
- else if (strcmp(v1, "output") == 0)
- {
- for (int i = 0; i < ShmPsuData->GroupCount; i++)
- {
- printf("Group Index = %d, OutputV = %d, OutputC = %d \n",
- i, ShmPsuData->PsuGroup[i].GroupPresentOutputVoltage, ShmPsuData->PsuGroup[i].GroupPresentOutputCurrent);
- }
- }
- else if (strcmp(v1, "test") == 0)
- {
- int mode = atoi(v2);
- if (mode >= _TEST_MODE && mode <= _TEST_MODE)
- {
- ShmPsuData->Work_Step = mode;
- }
- }
- else if (strcmp(v1, "out") == 0)
- {
- float vol = atof(v2);
- float cur = atof(v3);
- if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE)
- {
- if (!FindChargingInfoData(0, &_chargingData[0]))
- {
- printf ("FindChargingInfoData error\n");
- return;
- }
- _chargingData[0]->EvBatterytargetVoltage = vol;
- _chargingData[0]->EvBatterytargetCurrent = cur;
- }
- }
- printf("*************************************************\n");
- }
- void GetConnectorCapInfo(char *v1)
- {
- int _GunIndex = atoi(v1);
- if (!FindChargingInfoData(_GunIndex, &_chargingData[0]))
- {
- printf ("FindChargingInfoData error\n");
- return;
- }
- printf ("Charger Max Current = %d, Max Power = %d \n",
- ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10,
- ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10);
- printf ("Index = %d, MaxPow = %f, MaxVol = %f, MaxCur = %f\n",
- _GunIndex,
- _chargingData[_GunIndex]->RealMaxPower,
- _chargingData[_GunIndex]->RealMaxVoltage,
- _chargingData[_GunIndex]->RealMaxCurrent);
- }
- void SetWiringInfo(char *v1, char *v2)
- {
- int dispenser = atoi(v1);
- int connector = atoi(v2);
- if(dispenser > 0 && dispenser <= GENERAL_GUN_QUANTITY && connector >= 0 && connector <= GENERAL_GUN_QUANTITY)
- {
- if(ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence == (dispenser - 1))
- {
- printf("\r\n");
- printf("Set Dispenser %d, Connector Quantity = %d\r\n", dispenser, connector);
- ShmSysConfigAndInfo->SysConfig.WiringInfo.WiringSetting[dispenser - 1] = connector;
- ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence = dispenser;
- ShmSysConfigAndInfo->SysConfig.WiringInfo.MaxConnectorQuantity += connector;
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = true;
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.DispenserQuantity = ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence;
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.TotalConnectorQuantity = ShmSysConfigAndInfo->SysConfig.WiringInfo.MaxConnectorQuantity;
- }
- else if(ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence > (dispenser - 1))
- {
- printf("\r\n");
- printf("Set Dispenser %d, Connector Quantity = %d\r\n", dispenser, connector);
- ShmSysConfigAndInfo->SysConfig.WiringInfo.WiringSetting[dispenser - 1] = connector;
- int quantity = 0;
- for(int i = 0; i < ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence; i++)
- {
- quantity += ShmSysConfigAndInfo->SysConfig.WiringInfo.WiringSetting[i];
- }
- ShmSysConfigAndInfo->SysConfig.WiringInfo.MaxConnectorQuantity = quantity;
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = true;
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.DispenserQuantity = ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence;
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.TotalConnectorQuantity = ShmSysConfigAndInfo->SysConfig.WiringInfo.MaxConnectorQuantity;
- }
- }
- }
- void ShowWiringInfo(void)
- {
- printf("\r\n");
- printf("********** Wiring Info **********\r\n");
- printf("Dispenser = %d, Connector = %d\r\n",
- ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence,
- ShmSysConfigAndInfo->SysConfig.WiringInfo.MaxConnectorQuantity);
- if(ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence > 0)
- {
- for(int i = 0; i < ShmSysConfigAndInfo->SysConfig.WiringInfo.DispenserSequence; i++)
- {
- printf("Dispenser[%d] <=> %d\r\n", i, ShmSysConfigAndInfo->SysConfig.WiringInfo.WiringSetting[i]);
- }
- }
- printf("\r\n");
- }
- void CleanWiringInfo(void)
- {
- printf("\r\n");
- printf("******* Clean Wiring Info *******\r\n");
- memset((char *)&ShmSysConfigAndInfo->SysConfig.WiringInfo, 0x00, sizeof(WiringInfoData));
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = true;
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashImmediately = true;
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashAndReset = true;
- printf("\r\n");
- }
- void SetSystemSoftRest(void)
- {
- printf("\r\n");
- printf("********* Set Soft Reset ********\r\n\r\n");
- ShmChargerInfo->Control.SysCtrl.bits.NeedSoftReset = true;
- }
- void SetSystemHardReboot(void)
- {
- printf("\r\n");
- printf("******** Set Hard Reboot ********\r\n\r\n");
- ShmChargerInfo->Control.SysCtrl.bits.NeedHardReset = true;
- }
- void SetGroupRole(byte group, byte role)
- {
- if(group < GENERAL_GUN_QUANTITY)
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != role)
- {
- //printf("\r\nSet Group %d Role = %d", group, role);
- }
- ShmChargerInfo->PsuGrouping.GroupCollection[group].Role = role;
- }
- }
- void SetGroupToIdle(byte group)
- {
- if(group < GENERAL_GUN_QUANTITY)
- {
- SetGroupRole(group, _GROLE_IDLE);
- ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Quantity = 0;
- memset(ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Member, 0x00, ARRAY_SIZE(ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Member));
- ShmChargerInfo->PsuGrouping.GroupCollection[group].TargetGroup = 0;
- //printf("\r\n Reset Group %02X To Idle", group);
- }
- }
- void SetGroupToMaster(byte group)
- {
- if(group < GENERAL_GUN_QUANTITY)
- {
- SetGroupRole(group, _GROLE_MASTER);
- ShmChargerInfo->PsuGrouping.GroupCollection[group].TargetGroup = group + 1;
- //printf("\r\n Set Group %02X As Master", group);
- }
- }
- void SetGroupToSlave(byte group, byte target)
- {
- if(group < GENERAL_GUN_QUANTITY && target < GENERAL_GUN_QUANTITY)
- {
- SetGroupRole(group, _GROLE_SLAVE);
- ShmChargerInfo->PsuGrouping.GroupCollection[group].TargetGroup = target + 1;
- //printf("\r\n Set Group %02X As Slave", group);
- }
- }
- // group: group index, target: target index
- // add group to target's member
- void AddGroupCollection(byte group, byte target)
- {
- int ParallelConfig = 0;
- if(group < GENERAL_GUN_QUANTITY && target < GENERAL_GUN_QUANTITY)
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[target].Role != _GROLE_MASTER)
- {
- return;
- }
- if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_IDLE &&
- ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_WAIT_IDLE &&
- ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_PRECHARGE_READY)
- {
- return;
- }
- SetGroupToSlave(group, target);
- ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity++] = group;
- ParallelConfig = ShmChargerInfo->PsuGrouping.GroupCollection[target].ParallelConfig[group];
- if(ParallelConfig != 0)
- {
- ShmPsuGrouping->ParallelRelayConfig.CtrlValue |= (1 << (ParallelConfig - 1));
- }
- //printf("\r\n Add Group %02X To Gun %d (Quantity %d), Set Parallel Relay %d On", group, target + 1, ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity, ParallelConfig);
- }
- }
- // group: group index, target: target index
- // remove group out of target's member
- void RemoveGroupCollection(byte group, byte target)
- {
- int location = 0, slave = 0;
- bool find = false;
- int ParallelConfig = 0;
- if(group < GENERAL_GUN_QUANTITY && target < GENERAL_GUN_QUANTITY)
- {
- for(int i = 0; i < ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity; i++)
- {
- if(group == ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[i])
- {
- ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[i] = 0;
- location = i;
- find = true;
- break;
- }
- }
- if(find)
- {
- for(int i = location + 1; i < ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity; i++)
- {
- slave = ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[i];
- ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[i] = 0;
- ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[i - 1] = slave;
- }
- ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity--;
- SetGroupToIdle(group);
- ParallelConfig = ShmChargerInfo->PsuGrouping.GroupCollection[target].ParallelConfig[group];
- if(ParallelConfig != 0)
- {
- ShmPsuGrouping->ParallelRelayConfig.CtrlValue &= ~(1 << (ParallelConfig - 1));
- }
- //printf("\r\n Remove Group %02X From Gun %d (Quantity %d), Clean Parallel Relay %d Off", group, target + 1, ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity, ParallelConfig);
- }
- }
- }
- // Gun(Status)(Ro)(Q) Master Member OutputVol OutputCur AvaiPower AvaiCur StabCur K1K2 ParaRelay
- // 1 (00) 00 3 00 [00] [00] [00] 0000 V 0000 A 0000 kW 0000 A 0000 A 00 XX
- void ShowGroupingInfo(void)
- {
- byte target = 0;
- printf("\r\n Gun(Status)(Ro)(Q) Master Member OutputVol OutputCur AvaiPower AvaiCur StabCur K1K2 ParaRelay");
- for(int i = 0; i < 4; i++)
- {
- target = ShmPsuGrouping->Layout[i];
- printf("\r\n %d (%2d) %2d %d %02X ",
- target + 1, _chargingData[target]->SystemStatus, ShmChargerInfo->PsuGrouping.GroupCollection[target].Role,
- ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity, ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup);
- for(int j = 0; j < 3; j++)
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[target].Role == 1 && j < ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity)
- {
- printf("[%02X] ", ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Member[j]);
- }
- else
- {
- printf(" ");
- }
- }
- printf(" %4d V %4d A %4d kW %4d A %4d A ",
- (int)_chargingData[target]->PresentChargingVoltage, (int)_chargingData[target]->PresentChargingCurrent,
- (int)(_chargingData[target]->AvailableChargingPower / 10), (int)(_chargingData[target]->AvailableChargingCurrent / 10),
- (int)(_chargingData[target]->DeratingChargingCurrent / 10));
- printf("%02X %02X",ShmPsuGrouping->OutputRelayConfig[target].CtrlValue, ShmPsuGrouping->ParallelRelayConfig.CtrlValue);
- }
- printf("\r\n\r\nSystem Capability Current = %4d.%01d A, Power = %3d.%01d kW",
- (ShmPsuData->SystemAvailableCurrent / 10), (ShmPsuData->SystemAvailableCurrent % 10),
- (ShmPsuData->SystemAvailablePower / 10), (ShmPsuData->SystemAvailablePower % 10));
- printf("\r\n\r\n");
- }
- void PsuGroupSwitchToIdle(byte group)
- {
- int master = 0, quantity = 0, location = 0, total = 0;
- if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_SLAVE)
- {
- return;
- }
- master = ShmChargerInfo->PsuGrouping.GroupCollection[group].TargetGroup - 1;
- quantity = ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Quantity;
- //printf("\r\n Search Group %02X From Gun %d", group, master + 1);
- for(int i = 0; i < quantity; i++)
- {
- if(total == 0)
- {
- if(group == ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[i])
- {
- location = i;
- total++;
- //printf("\r\n Find Group %02X At Member Index = %d", group, location);
- }
- }
- else
- {
- // find other group in the same direction
- if(ShmPsuGrouping->Location[ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[location]] < ShmPsuGrouping->Location[master])
- {
- if(ShmPsuGrouping->Location[ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[i]] < ShmPsuGrouping->Location[master])
- {
- total++;
- //printf("\r\n Find Other Group %02X In The Same Direction", ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[i]);
- }
- }
- if(ShmPsuGrouping->Location[ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[location]] > ShmPsuGrouping->Location[master])
- {
- if(ShmPsuGrouping->Location[ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[i]] > ShmPsuGrouping->Location[master])
- {
- total++;
- //printf("\r\n Find Other Group %02X In The Same Direction", ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member[i]);
- }
- }
- }
- }
- if(total > 0)
- {
- unsigned char collection[GENERAL_GUN_QUANTITY];
- //printf("\r\n There are %d Group Need To Switch Idle:", total);
- memcpy(collection, ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member, ARRAY_SIZE(ShmChargerInfo->PsuGrouping.GroupCollection[master].Partner.Member));
- for(int i = 0; i < total; i++)
- {
- //printf(" %02X", collection[i + location]);
- }
- for(int i = 0; i < total; i++)
- {
- RemoveGroupCollection(collection[i + location], master);
- }
- }
- }
- void FindPsuGroupPartner(byte master, byte quantity, PsuGroupPartner *tPartner)
- {
- int slave = 0, location = 0;
- PsuGroupPartner partner;
- memset(&partner, 0x00, sizeof(PsuGroupPartner));
- // search from left
- location = ShmChargerInfo->PsuGrouping.GroupCollection[master].Location - 1;
- for(int i = location; i >= 0; i--)
- {
- if(partner.Quantity >= quantity)
- {
- break;
- }
- slave = ShmPsuGrouping->Layout[i];
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
- {
- //printf("\r\n Find Group %02X From Left", slave);
- partner.Member[partner.Quantity++] = slave;
- }
- else
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && master == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
- {
- continue;
- }
- break;
- }
- }
- // search from right
- location = ShmChargerInfo->PsuGrouping.GroupCollection[master].Location + 1;
- for(int i = location; i < 4; i++)
- {
- if(partner.Quantity >= quantity)
- {
- break;
- }
- slave = ShmPsuGrouping->Layout[i];
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
- {
- //printf("\r\n Find Group %02X From Right", slave);
- partner.Member[partner.Quantity++] = slave;
- }
- else
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && master == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
- {
- continue;
- }
- break;
- }
- }
- memcpy(tPartner, &partner, sizeof(PsuGroupPartner));
- }
- int GetPsuGroupAvailable(byte group)
- {
- //int slave = 0, location = 0, available = 0;
- PsuGroupPartner partner;
- FindPsuGroupPartner(group, MAX_GROUP_QUANTITY, &partner);
- //printf("\r\n Gun %d Available Quantity = %d", group + 1, partner.Quantity);
- return partner.Quantity;
- #if 0
- // search from left
- location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location - 1;
- for(int i = location; i >= 0; i--)
- {
- slave = ShmPsuGrouping->Layout[i];
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
- {
- available++;
- }
- else
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
- {
- continue;
- }
- break;
- }
- }
- // search from right
- location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location + 1;
- for(int i = location; i < 4; i++)
- {
- slave = ShmPsuGrouping->Layout[i];
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
- {
- available++;
- }
- else
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
- {
- continue;
- }
- break;
- }
- }
- return available;
- #endif
- }
- void PsuGroupShareCheck(byte group)
- {
- int slave = 0, target = 0, location = 0, share = 0, total = 0;
- total = GetPsuGroupAvailable(group) + 1;
- //printf("\r\n Gun %d Total Group = %d", group + 1, total);
- // search from left
- location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location - 1;
- for(int i = location; i >= 0; i--)
- {
- slave = ShmPsuGrouping->Layout[i];
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE)
- {
- target = ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1;
- if((ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity + 1) > total)
- {
- share = (ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity + 1 - total) / 2;
- }
- //printf("\r\n Find Group %02X Have %d Resource Can Shared %d From Left", target, ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity, share);
- break;
- }
- else
- {
- break;
- }
- }
- if(share == 0)
- {
- // search from right
- location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location + 1;
- for(int i = location; i < 4; i++)
- {
- slave = ShmPsuGrouping->Layout[i];
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE)
- {
- target = ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1;
- if((ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity + 1) > total)
- {
- share = (ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity + 1 - total) / 2;
- }
- //printf("\r\n Find Group %02X Have %d Resource Can Shared %d From Left", target, ShmChargerInfo->PsuGrouping.GroupCollection[target].Partner.Quantity, share);
- break;
- }
- else
- {
- break;
- }
- }
- }
- if(share > 0)
- {
- //printf("\r\n Grab %02X", slave);
- PsuGroupSwitchToIdle(slave);
- }
- else
- {
- //printf("\r\n No Need To Grab");
- }
- }
- void SimplePsuGroupStartCharging(byte group)
- {
- //int slave = 0, location = 0;
- int available = 0;
- PsuGroupPartner partner;
- if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role == _GROLE_SLAVE)
- {
- return;
- }
- if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_IDLE && ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_MASTER)
- {
- return;
- }
- if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role == _GROLE_IDLE)
- {
- SetGroupToMaster(group);
- PsuGroupShareCheck(group);
- }
- else
- {
- available = GetPsuGroupAvailable(group);
- //printf("\r\nGun %d is already master, there are %d available group", group + 1, available);
- if(available == 0)
- {
- return;
- }
- }
- FindPsuGroupPartner(group, MAX_GROUP_QUANTITY, &partner);
- for(int i = 0; i < partner.Quantity; i++)
- {
- AddGroupCollection(partner.Member[i], group);
- }
- ShmPsuGrouping->OutputRelayConfig[group].bits.Output_N = true;
- ShmPsuGrouping->OutputRelayConfig[group].bits.Output_P = true;
- #if 0
- // search from left
- location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location - 1;
- for(int i = location; i >= 0; i--)
- {
- slave = ShmPsuGrouping->Layout[i];
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
- {
- //printf("\r\n Find %02X From Left", slave);
- AddGroupCollection(slave, group);
- }
- else
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
- {
- continue;
- }
- break;
- }
- }
- // search from right
- location = ShmChargerInfo->PsuGrouping.GroupCollection[group].Location + 1;
- for(int i = location; i < 4; i++)
- {
- slave = ShmPsuGrouping->Layout[i];
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_IDLE)
- {
- //printf("\r\n Find %02X From Right", slave);
- AddGroupCollection(slave, group);
- }
- else
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[slave].Role == _GROLE_SLAVE && group == (ShmChargerInfo->PsuGrouping.GroupCollection[slave].TargetGroup - 1))
- {
- continue;
- }
- break;
- }
- }
- #endif
- }
- void PsuGroupStopCharging(byte group)
- {
- int total = 0;
- if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role != _GROLE_MASTER)
- {
- return;
- }
- total = ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Quantity;
- if(total > 0)
- {
- unsigned char collection[GENERAL_GUN_QUANTITY];
- //printf("\r\n There are %d Group Need To Stop:", ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Quantity);
- memcpy(collection, ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Member, ARRAY_SIZE(ShmChargerInfo->PsuGrouping.GroupCollection[group].Partner.Member));
- for(int i = 0; i < total; i++)
- {
- //printf(" %02X", collection[i]);
- }
- for(int i = 0; i < total; i++)
- {
- RemoveGroupCollection(collection[i], group);
- }
- }
- SetGroupToIdle(group);
- ShmPsuGrouping->OutputRelayConfig[group].bits.Output_N = false;
- ShmPsuGrouping->OutputRelayConfig[group].bits.Output_P = false;
- }
- void RunSimplePsuGrouping(char *v1, char *v2)
- {
- int group = 0, charging = 0;
- group = atoi(v1);
- charging = atoi(v2);
- group -= 1;
- if(group >= 0 && group < 4)
- {
- if(charging > 0)
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role == _GROLE_SLAVE)
- {
- //printf("\r\nGroup %02X Is In Use, Need To Stop Charging", group);
- PsuGroupSwitchToIdle(group);
- }
- SimplePsuGroupStartCharging(group);
- }
- if(charging == 0)
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role == _GROLE_MASTER)
- {
- PsuGroupStopCharging(group);
- }
- if(ShmChargerInfo->PsuGrouping.GroupCollection[group].Role == _GROLE_SLAVE)
- {
- PsuGroupSwitchToIdle(group);
- }
- }
- ShowGroupingInfo();
- }
- }
- void ConnectionInfo(void)
- {
- int address = 0;
- for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
- {
- address = ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress;
- printf(" Connection[%d] Status: %d, DispenserIndex: %d, IP: %d.%d.%d.%d\r\n", i,
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].Status,
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].DispenserIndex,
- ((address >> 0) & 0xFF), ((address >> 8) & 0xFF), ((address >> 16) & 0xFF), ((address >> 24) & 0xFF));
- }
- }
- void GunEnableInfo(int gunIndex)
- {
- printf(" Gun %d Index: %2X, Status = %2d , %7s, MeterValue: %10.4f, Local: : %10.4f, Gun: : %10.4f\r\n", gunIndex + 1, _chargingData[gunIndex]->Index, _chargingData[gunIndex]->SystemStatus,
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].Enable ? "Enable" : "Disable",
- _chargingData[gunIndex]->PowerConsumption,
- ShmChargerInfo->MeterValue[gunIndex].LocalConsumption,
- ShmChargerInfo->MeterValue[gunIndex].GunConsumption);
- }
- int FindDispenserIpAddress(int dispenser)
- {
- int address = 0;
- for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
- {
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].Status == _CNS_DispenserMatched &&
- dispenser == ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].DispenserIndex)
- {
- address = ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress;
- }
- }
- return address;
- }
- int DispenserInfo(int dispenser)
- {
- int ipAddress = 0;
- int gunCnt = 0;
- printf(" Dispenser %d Status: %d", dispenser + 1, ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].LocalStatus);
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].LocalStatus != _DS_None &&
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].LocalStatus != _DS_Timeout)
- {
- ipAddress = FindDispenserIpAddress(dispenser);
- gunCnt = ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].ConnectorQuantity;
- printf(", ModelName: %s, IP: %d.%d.%d.%d\r\n", ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].ModelName,
- ((ipAddress >> 0) & 0xFF), ((ipAddress >> 8) & 0xFF), ((ipAddress >> 16) & 0xFF), ((ipAddress >> 24) & 0xFF));
- for(int i = 0; i < gunCnt; i++)
- {
- unsigned char gun = ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].ConnectorID[i];
- printf(" - Connector[%d] Gun %d, %s\r\n", i, gun, _chargingData[gun - 1]->ConnectorPlugIn ? "Plugged" : "Unplugged");
- }
- }
- else
- {
- printf(", No Information\r\n");
- }
- return gunCnt;
- }
- void ShowCabinetInfo(char *inputCmd, unsigned int opt)
- {
- bool keepRun = false;
- bool reflash = false;
- int time = 0;
- int dispenserLine = 0;
- struct timespec _Loop_time;
- if((opt & OPTION_REFLASH) || (opt & OPTION_LOOP) > 0)
- {
- keepRun = true;
- }
- printf("\r\n");
- printf("Power Cabinet & Dispenser Info\r\n");
- do
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(time >= 1000)
- {
- if(reflash)
- {
- ConsoleReflash(1, 2);
- ConsoleReflash(CONNECTOR_QUANTITY, 1);
- dispenserLine = dispenserLine > 0 ? (dispenserLine + 1) : dispenserLine;
- ConsoleReflash(1, dispenserLine);
- dispenserLine = 0;
- }
- printf(" Dispenser: %d / %d, Connector: %d / %d\r\n",
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.PresentDispenserQuantity,
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.DispenserQuantity,
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.PresentConnectorQuantity,
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.TotalConnectorQuantity);
- printf("\r\n");
- for(int i = 0; i < CONNECTOR_QUANTITY; i++)
- {
- GunEnableInfo(i);
- }
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.DispenserQuantity > 0)
- {
- printf("\r\n");
- for(int i = 0; i < ShmSysConfigAndInfo->SysInfo.DispenserInfo.DispenserQuantity; i++)
- {
- dispenserLine += DispenserInfo(i) + 1;
- }
- }
- GetClockTime(&_Loop_time);
- if((opt & OPTION_REFLASH) > 0)
- {
- reflash = true;
- }
- }
- if(keepRun)
- {
- keepRun = IsLoopStopCmd() ? false : true;
- usleep(10000);
- }
- }while(keepRun);
- printf("\r\n");
- }
- void SetTestControl(char *v1, char *v2)
- {
- int testItem = 0;
- int testItemLen = 5;
- int enable = 0;
- char strTest[32][32] = {"tbl", "tfsb", "chgsm", "fcre", "ubill"};
- char strItem[32][32] = {"Balance", "Fast Standby Time", "Charging Simulation", "FCharging Release Extend", "Undisposed Bill"};
- enable = atoi(v2);
- if(enable < 0)
- {
- return;
- }
- for(int i = 0; i < testItemLen; i++)
- {
- if(strcmp((char *)&strTest[i][0], v1) == 0)
- {
- testItem = i + 1;
- break;
- }
- }
- if(testItem != 0)
- {
- if(enable)
- {
- ShmChargerInfo->Control.TestCtrl.CtrlValue |= (1 << (testItem - 1));
- }
- else
- {
- ShmChargerInfo->Control.TestCtrl.CtrlValue &= ~(1 << (testItem - 1));
- }
- printf("%s %s Test Item, Test Control Value = %08X\n",
- enable ? "Enable" : "Disable", strItem[testItem - 1], ShmChargerInfo->Control.TestCtrl.CtrlValue);
- }
- else
- {
- printf("Test Item %s Not Found\n", v1);
- for(int i = 0; i < testItemLen; i++)
- {
- printf(" [%s] -> %s Test\n", strTest[i], strItem[i]);
- }
- }
- printf("\r\n");
- }
- // Gun Role Master K1K2 GTVoltage GTCurrent StableCurrent OutputLoading GunLoading DiffP_Ava DiffP_Cap DiffP_Lim
- // 1 00 00 0 0000 V 000.0 A 0000 A XXX.XX XXX.XX XXX kw XXX kW XXX kW
- void ShowGroupingDemand(void)
- {
- byte target = 0;
- unsigned char k1k2 = 0;
- printf("\r\n Gun Role Master K1K2 GTVoltage GTCurrent StableCurrent OutputLoading GunLoading DiffP_Ava DiffP_Cap DiffP_Lim");
- for(int i = 0; i < 4; i++)
- {
- target = ShmPsuGrouping->Layout[i];
- if(ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup != 0)
- {
- k1k2 = _chargingData[ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup - 1]->RelayK1K2Status;
- }
- else
- {
- k1k2 = _chargingData[target]->RelayK1K2Status;
- }
- printf("\r\n %d %2d %02X %d %4d V %3d.%d A %4d A %3d.%02d",
- target + 1, ShmChargerInfo->PsuGrouping.GroupCollection[target].Role, ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup, k1k2,
- (ShmPsuGrouping->GroupOutput[target].GTargetVoltage / 10),
- (ShmPsuGrouping->GroupOutput[target].GTargetCurrent / 10),
- (ShmPsuGrouping->GroupOutput[target].GTargetCurrent % 10),
- (int)(_chargingData[target]->AvailableChargingCurrent / 10),
- (ShmPsuGrouping->GroupOutput[target].OutputLoading / 100),
- (ShmPsuGrouping->GroupOutput[target].OutputLoading % 100));
- if(ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup == target + 1)
- {
- printf(" %3d.%02d", (ShmChargerInfo->PsuGrouping.GroupCollection[target].GunLoading / 100), (ShmChargerInfo->PsuGrouping.GroupCollection[target].GunLoading % 100));
- printf(" %3d kW %3d kW %3d kW",
- (int)ShmPsuGrouping->GroupCollection[target].DiffPower_Available,
- (int)ShmPsuGrouping->GroupCollection[target].DiffPower_Capability,
- (int)ShmPsuGrouping->GroupCollection[target].DiffPower_PhysicalLimit);
- }
- }
- printf("\r\n\r\n");
- }
- // v1: gun
- // v2: voltage
- // v3: current
- void SetGunStartCharging(char *inputCmd, unsigned int opt, unsigned char isWeb)
- {
- int totalCnt = 0, maxPara = 0;
- maxPara = 3;
- totalCnt = GetSubCommand(inputCmd);
- if(totalCnt != maxPara)
- {
- printf("Input cmd fail ------ gunchg [gun 1-4] [voltage 0-1000] [current 0-100]\r\n\r\n");
- return;
- }
- int gun = 0;
- float _voltage = 0, _current = 0;
- gun = atoi(&MultiSubCmd[0][0]);
- _voltage = atof(&MultiSubCmd[1][0]);
- _current = atof(&MultiSubCmd[2][0]);
- if(gun <= 0 || gun > GENERAL_GUN_QUANTITY || _voltage < 0 || _voltage > 1000 || _current < 0 || _current > 1200)
- {
- printf("\r\n");
- printf("Gun Start Charging Input parameter %d, %.1f, %.1f out of range\r\n", gun, _voltage, _current);
- printf("\r\n");
- return;
- }
- bool wait = true;
- int time = 0;
- struct timespec _Wait_time;
- unsigned char PreviousSystemStatus = 0xFF;
- unsigned short _targetVoltage = 0, _targetCurrent = 0;
- printf("\r\n");
- while(wait)
- {
- switch(_chargingData[gun - 1]->SystemStatus)
- {
- case S_IDLE:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_IDLE\r\n", gun);
- printf("Set Gun %d Start Charging > Voltage: %4d, Current: %d\r\n", gun, (int)_voltage, (int)_current);
- ShmChargerInfo->Control.FCharging[gun - 1].FCtrl.bits.EnableForceCharging = true;
- ShmChargerInfo->Control.FCharging[gun - 1].FCtrl.bits.StartForceCharging = true;
- ShmChargerInfo->Control.FCharging[gun - 1].FTargetVoltage = _voltage * 10;
- ShmChargerInfo->Control.FCharging[gun - 1].FTargetCurrent = _current * 10;
- if(isWeb)
- {
- ShmChargerInfo->Control.FCharging[gun - 1].FCtrl.bits.WebApiTrigger = true;
- }
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- break;
- case S_REASSIGN_CHECK:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_REASSIGN_CHECK, Wait For Request Charging\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- break;
- case S_REASSIGN:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_REASSIGN, Wait For Grouping\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- break;
- case S_PREPARNING:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_PREPARNING\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- break;
- case S_PREPARING_FOR_EV:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_PREPARING_FOR_EV\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- break;
- case S_PREPARING_FOR_EVSE:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_PREPARING_FOR_EVSE, Wait For EVSE\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- if(_targetVoltage != (int)_chargingData[gun - 1]->EvBatterytargetVoltage ||
- _targetCurrent != (int)_chargingData[gun - 1]->EvBatterytargetCurrent)
- {
- _targetVoltage = (int)_chargingData[gun - 1]->EvBatterytargetVoltage;
- _targetCurrent = (int)_chargingData[gun - 1]->EvBatterytargetCurrent;
- printf("Gun %d Set Voltage: %4d, Current: %d\r\n", gun, _targetVoltage, _targetCurrent);
- }
- break;
- case S_CHARGING:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_CHARGING\r\n", gun);
- if(PreviousSystemStatus == 0xFF)
- {
- _targetVoltage = (int)_chargingData[gun - 1]->EvBatterytargetVoltage;
- _targetCurrent = (int)_chargingData[gun - 1]->EvBatterytargetCurrent;
- printf("Gun %d Voltage: %4d, Current: %d\r\n", gun, _targetVoltage, _targetCurrent);
- if(ShmChargerInfo->Control.FCharging[gun - 1].FCtrl.bits.EnableForceCharging)
- {
- printf("Set Gun %d Force Charging > Voltage: %4d, Current: %d\r\n", gun, (int)_voltage, (int)_current);
- ShmChargerInfo->Control.FCharging[gun - 1].FTargetVoltage = _voltage * 10;
- ShmChargerInfo->Control.FCharging[gun - 1].FTargetCurrent = _current * 10;
- }
- }
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- GetClockTime(&_Wait_time);
- }
- if(_targetVoltage != (int)_chargingData[gun - 1]->EvBatterytargetVoltage ||
- _targetCurrent != (int)_chargingData[gun - 1]->EvBatterytargetCurrent)
- {
- _targetVoltage = (int)_chargingData[gun - 1]->EvBatterytargetVoltage;
- _targetCurrent = (int)_chargingData[gun - 1]->EvBatterytargetCurrent;
- printf("Gun %d Set Voltage: %4d, Current: %d\r\n", gun, _targetVoltage, _targetCurrent);
- }
- time = GetTimeoutValue(_Wait_time) / uSEC_VAL;
- if(time >= 1)
- {
- wait = false;
- printf("Done\r\n");
- }
- break;
- case S_TERMINATING:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_TERMINATING\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- wait = false;
- break;
- case S_COMPLETE:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_COMPLETE\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- wait = false;
- break;
- case S_ALARM:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_ALARM\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- wait = false;
- break;
- default:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun SystemStatus %d Unknown(%d)\r\n", gun, _chargingData[gun - 1]->SystemStatus);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- printf("Gun %d SystemStatus(%d) Is Not Available\r\n", gun, _chargingData[gun - 1]->SystemStatus);
- wait = false;
- break;
- }
- char word[128];
- char newString[7][10];
- int i,j,ctr;
- memset(word, 0x00, sizeof(word));
- get_char(word);
- if (strlen(word) == 0)
- {
- continue;
- }
- j=0; ctr=0;
- strcpy(newString[1], "-1");
- strcpy(newString[2], "-1");
- for (i = 0; i <= (strlen(word)); i++)
- {
- if (word[i] == ' ' || word[i] == '\0' || word[i] == 10)
- {
- newString[ctr][j] = '\0';
- ctr++;
- j = 0;
- }
- else
- {
- newString[ctr][j] = word[i];
- j++;
- }
- }
- if(strcmp(newString[0], "c") == 0)
- {
- printf("Stop\r\n");
- wait = false;
- }
- usleep(100000);
- }
- printf("\r\n");
- }
- void GenerateManualStop(int gunIndex, bool isAlarm, char *alarmCode)
- {
- if(isAlarm)
- {
- if(!_chargingData[gunIndex]->ChargingStopFlag.bits.AlarmStop)
- {
- if(strncmp((char *)_chargingData[gunIndex]->ConnectorAlarmCode, "", 6) == EQUAL)
- {
- memcpy((char *)_chargingData[gunIndex]->ConnectorAlarmCode, alarmCode, 6);
- }
- _chargingData[gunIndex]->ChargingStopFlag.bits.AlarmStop = true;
- printf("Set Gun %d Stop Charging(ManualAlarm)\r\n", gunIndex + 1);
- }
- }
- else
- {
- if(!_chargingData[gunIndex]->ChargingStopFlag.bits.ManualStop)
- {
- _chargingData[gunIndex]->ChargingStopFlag.bits.ManualStop = true;
- printf("Set Gun %d Stop Charging(ManualStop)\r\n", gunIndex + 1);
- }
- }
- }
- // v1: gun
- void SetGunStopCharging(char *inputCmd, unsigned int opt)
- {
- int totalCnt = 0, maxPara = 0;
- maxPara = 2;
- totalCnt = GetSubCommand(inputCmd);
- if(totalCnt > maxPara || totalCnt == 0)
- {
- printf("Input cmd fail ------ gunstp [gun 1-4] [status code]\r\n\r\n");
- return;
- }
- int gun = 0;
- gun = atoi(&MultiSubCmd[0][0]);
- if(gun <= 0 || gun > GENERAL_GUN_QUANTITY)
- {
- printf("\r\n");
- printf("Gun Stop Charging Input parameter %d over range\r\n", gun);
- printf("\r\n");
- return;
- }
- bool isAlarmStop = false;
- char manualAlarm[7];
- if(totalCnt == 2)
- {
- if((strlen(&MultiSubCmd[1][0]) == 6) && atoi(&MultiSubCmd[1][0]) != 0)
- {
- memset(manualAlarm, 0x00, sizeof(manualAlarm));
- memcpy(manualAlarm, &MultiSubCmd[1][0], 6);
- isAlarmStop = true;
- }
- }
- bool wait = true;
- int time = 0;
- struct timespec _Wait_time;
- unsigned char PreviousSystemStatus = 0xFF;
- printf("\r\n");
- while(wait)
- {
- switch(_chargingData[gun - 1]->SystemStatus)
- {
- case S_IDLE:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_IDLE\r\n", gun);
- if(PreviousSystemStatus == 0xFF)
- {
- if(ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].Role == _GROLE_SLAVE)
- {
- printf("Set Group [%02X] Stop\r\n", gun - 1);
- ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].GroupCtrl.bits.SlavePowerOffRequest = true;
- }
- }
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- GetClockTime(&_Wait_time);
- }
- time = GetTimeoutValue(_Wait_time) / uSEC_VAL;
- if(time >= 1)
- {
- wait = false;
- printf("Done\r\n");
- }
- break;
- case S_REASSIGN_CHECK:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_REASSIGN_CHECK, Wait For Request Charging\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
- }
- break;
- case S_REASSIGN:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_REASSIGN, Wait For Grouping\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
- }
- break;
- case S_PREPARNING:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_PREPARNING\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
- }
- break;
- case S_PREPARING_FOR_EV:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_PREPARING_FOR_EV\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
- }
- break;
- case S_PREPARING_FOR_EVSE:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_PREPARING_FOR_EVSE, Wait For EVSE\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
- }
- break;
- case S_CHARGING:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_CHARGING\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
- }
- break;
- case S_TERMINATING:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_TERMINATING\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- break;
- case S_COMPLETE:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_COMPLETE\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- break;
- case S_ALARM:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun %d S_ALARM\r\n", gun);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- break;
- default:
- if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
- {
- printf("Gun SystemStatus %d Unknown(%d)\r\n", gun, _chargingData[gun - 1]->SystemStatus);
- PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
- }
- printf("Gun %d SystemStatus(%d) Is Not Available\r\n", gun, _chargingData[gun - 1]->SystemStatus);
- wait = false;
- break;
- }
- char word[128];
- char newString[7][10];
- int i,j,ctr;
- memset(word, 0x00, sizeof(word));
- get_char(word);
- if (strlen(word) == 0)
- {
- continue;
- }
- j=0; ctr=0;
- strcpy(newString[1], "-1");
- strcpy(newString[2], "-1");
- for (i = 0; i <= (strlen(word)); i++)
- {
- if (word[i] == ' ' || word[i] == '\0' || word[i] == 10)
- {
- newString[ctr][j] = '\0';
- ctr++;
- j = 0;
- }
- else
- {
- newString[ctr][j] = word[i];
- j++;
- }
- }
- if(strcmp(newString[0], "c") == 0)
- {
- printf("Stop\r\n");
- wait = false;
- }
- usleep(100000);
- }
- printf("\r\n");
- }
- void SetGunExtend(char *v1)
- {
- int gun = 0;
- gun = atoi(v1);
- if(_chargingData[gun - 1]->SystemStatus == S_CHARGING && ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].Role == _GROLE_MASTER)
- {
- printf("\r\nSet Group [%02X] Extend Capability", gun - 1);
- ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].GroupCtrl.bits.MorePowerRequest = true;
- }
- else
- {
- printf("\r\nGun %d Extend Capability Is Not Available, SystemStatus(%d)", gun, _chargingData[gun - 1]->SystemStatus);
- }
- printf("\r\n\r\n");
- }
- // Gun TargetV TargetC GTargetV GTargetC OutputV OutputC G_Psu_V G_Psu_C Psu 0_V Psu 0_C Psu 1_V Psu 1_C Psu 2_V Psu 2_C ...
- // X XXXX.X V XXX.X A XXXX.X V XXX.X A XXXX.X V XXX.X A XXXX.X V XXX.X A XXXX.X V XXX.X A XXXX.X V XXX.X A XXXX.X V XXX.X A
- void ShowGunOutput(void)
- {
- byte target = 0;
- unsigned short voltage = 0, current = 0;
- printf("\r\n Gun TargetV TargetC GTargetV GTargetC OutputV OutputC G_Psu_V G_Psu_C Psu 0_V Psu 0_C Psu 1_V Psu 1_C Psu 2_V Psu 2_C ...");
- for(int i = 0; i < CONNECTOR_QUANTITY; i++)
- {
- target = ShmPsuGrouping->Layout[i];
- // "\r\n %d %4d.%d V %3d.%d A %4d.%d V %3d.%d A %4d.%d V %3d.%d A %4d.%d V %3d.%d A %4d.%d V %3d.%d A %4d.%d V %3d.%d A"
- voltage = (unsigned short)(_chargingData[target]->EvBatterytargetVoltage * 10);
- current = (unsigned short)(_chargingData[target]->EvBatterytargetCurrent * 10);
- printf("\r\n %d %4d.%d V %3d.%d A", target + 1, (voltage / 10), (voltage % 10), (current / 10), (current % 10));
- voltage = ShmPsuGrouping->GroupOutput[target].GTargetVoltage;
- current = ShmPsuGrouping->GroupOutput[target].GTargetCurrent;
- printf(" %4d.%d V %3d.%d A", (voltage / 10), (voltage % 10), (current / 10), (current % 10));
- voltage = (unsigned short)(_chargingData[target]->PresentChargingVoltage * 10);
- current = (unsigned short)(_chargingData[target]->PresentChargingCurrent * 10);
- printf(" %4d.%d V %3d.%d A", (voltage / 10), (voltage % 10), (current / 10), (current % 10));
- voltage = ShmPsuData->PsuGroup[target].GroupPresentOutputVoltage;
- current = ShmPsuData->PsuGroup[target].GroupPresentOutputCurrent;
- printf(" %4d.%d V %3d.%d A", (voltage / 10), (voltage % 10), (current / 10), (current % 10));
- /*
- for(int j = 0; j < ShmPsuData->PsuGroup[target].GroupPresentPsuQuantity; j++)
- {
- printf(" %4d.%d V %3d.%d A", (voltage / 10), (voltage % 10), (current / 10), (current % 10));
- }
- */
- }
- printf("\r\n\r\n");
- }
- void SetGpio(char *v1, char *v2)
- {
- int testItem = 0;
- int testItemLen = 1;
- int ioOutput = 0;
- char strTest[32][32] = {"4g"};
- char strItem[32][32] = {"4G Reset"};
- ioOutput = atoi(v2);
- if(ioOutput < 0)
- {
- return;
- }
- for(int i = 0; i < testItemLen; i++)
- {
- if(strcmp((char *)&strTest[i][0], v1) == 0)
- {
- testItem = i + 1;
- break;
- }
- }
- if(testItem != 0)
- {
- if(ioOutput)
- {
- system("echo 1 > /sys/class/gpio/gpio104/value");
- }
- else
- {
- system("echo 0 > /sys/class/gpio/gpio104/value");
- }
- printf("Set %s %s\n",
- strItem[testItem - 1], ioOutput > 0 ? "High" : "Low");
- }
- else
- {
- printf("Gpio Item %s Not Found\n", v1);
- }
- printf("\r\n");
- }
- void ShowStatus(void)
- {
- char *str_cabinet_role[] = {STR_CABINET_ROLE_NONE, STR_CABINET_ROLE_MASTER, STR_CABINET_ROLE_SLAVE};
- for(int i = 0; i < ShmChargerInfo->Control.MaxConnector; i++)
- {
- printf("\r\nGun %d Status = %d, IsAvailable = %d, GunEnable = %d",
- i + 1,
- _chargingData[i]->SystemStatus,
- _chargingData[i]->IsAvailable,
- ShmChargerInfo->Control.GunAvailable[i]);
- printf("\r\nAlarmCode");
- printf("\r\n Connector = %6s, EvConn = %6s, Remote = %6s, Vendor = %6s",
- strncmp((char *)_chargingData[i]->ConnectorAlarmCode, "", 6) != 0 ?
- (char *)_chargingData[i]->ConnectorAlarmCode : "No Err",
- strncmp((char *)_chargingData[i]->EvConnAlarmCode, "", 6) != 0 ?
- (char *)_chargingData[i]->ConnectorAlarmCode : "No Err",
- strncmp((char *)ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].RemotenAlarmCode, "", 6) != 0 ?
- (char *)ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].RemotenAlarmCode : "No Err",
- strncmp((char *)ShmOCPP16Data->StatusNotification[i].VendorErrorCode, "", 6) != 0 ?
- (char *)ShmOCPP16Data->StatusNotification[i].VendorErrorCode : "No Err");
- }
- printf("\r\n");
- printf("\r\nPower Cabinet Role: %s, Switch Value: %d, ",
- ShmChargerInfo->Control.CabinetSwitch <= _CROLE_SLAVE ? str_cabinet_role[ShmChargerInfo->Control.CabinetSwitch] : "Unknown",
- ShmChargerInfo->Control.CabinetSwitch);
- printf("\r\nStatus Code Len = %d", ShmSysConfigAndInfo->SysWarningInfo.WarningCount);
- if(ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 0)
- {
- printf("\r\n WarningCode:");
- for(int i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++)
- {
- printf(" %s", (char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0]);
- }
- }
- printf("\r\n\r\n");
- }
- void ShowWhiteCardList(void)
- {
- printf("\r\nWhite Card List");
- for(int i = 0; i < 10; i++)
- {
- printf("\r\n White Card [%2d]: %s", i + 1, (char *)ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[i]);
- }
- printf("\r\n\r\n");
- }
- void WriteWhiteCard(char *v1, char *v2)
- {
- int cardIndex = 0;
- cardIndex = atoi(v1);
- if(cardIndex < 1 || cardIndex > 10)
- {
- printf("\r\n White Card Index Fail\r\n\r\n");
- return;
- }
- if(strlen(v2) == 0 || strlen(v2) > 31)
- {
- printf("\r\n White Card Fail\r\n\r\n");
- return;
- }
- printf("\r\n Str Len = %d = %s", strlen(v2), v2);
- printf("\r\n Set White Card Index %d = %s", cardIndex, v2);
- memcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[cardIndex - 1][0], v2, strlen(v2));
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = true;
- printf("\r\n\r\n");
- }
- void EraseWhiteCard(char *v1)
- {
- int cardIndex = 0;
- cardIndex = atoi(v1);
- if(cardIndex < 1 || cardIndex > 10)
- {
- printf("\r\n White Card Index Fail\r\n\r\n");
- return;
- }
- printf("\r\n Erase White Card Index = %d", cardIndex);
- memset((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[cardIndex - 1][0], 0x00, 32);
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = true;
- printf("\r\n\r\n");
- }
- // MaxChargingProfile: %s
- // Offline MaxPower: %s
- // Max Total Power: XXXX kW, Total Current: XXXX A, MaxSoc: XXX %
- // Total Energy: XXXX kWh, Duration: XXXX Minute(s)
- void ShowMaxLimit(void)
- {
- char tempString[64];
- //************************************************************************************************
- memset(tempString, 0x00, sizeof(tempString));
- if(ShmSysConfigAndInfo->SysInfo.MaxChargingProfilePower == -1)
- {
- sprintf(tempString, " %s", "Unlimited");
- }
- else
- {
- sprintf(tempString, " %4d kW", (int)ShmSysConfigAndInfo->SysInfo.MaxChargingProfilePower / 1000);
- }
- printf(" MaxChargingProfile: %s\r\n", tempString);
- //************************************************************************************************
- memset(tempString, 0x00, sizeof(tempString));
- if(ShmChargerInfo->OutputLimit.Offline_MaxChargingPower <= 0)
- {
- sprintf(tempString, " %s", "Unlimited");
- }
- else
- {
- sprintf(tempString, " %4d kW", ShmChargerInfo->OutputLimit.Offline_MaxChargingPower / 1000);
- }
- printf(" Offline MaxPower: %s\r\n", tempString);
- //************************************************************************************************
- printf(" Max Total Power: %4d kW, Total Current: %4d A, MaxSoc: %3d %%\r\n",
- ShmSysConfigAndInfo->SysConfig.MaxChargingPower,
- ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent,
- ShmSysConfigAndInfo->SysConfig.MaxChargingSoc);
- //************************************************************************************************
- printf(" Total Energy: %4d kWh, Duration: %4d Minute(s)\r\n",
- ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy, ShmSysConfigAndInfo->SysConfig.MaxChargingDuration);
- }
- void ShowGunLimit(int gun_index)
- {
- char *str_gun_type[] = {STR_GUN_TYPE_CHADEMO, STR_GUN_TYPE_CCS, STR_GUN_TYPE_GBT};
- // Gun Enable Type Psu Phy_Vol Phy_Cur Config_Ocpp_MaxOcpp_Pow Config_Ocpp_MaxOcpp_Cur
- // 1 0 CHAdeMO 00 0000 V 0000 A 0000 / 0000 / 0000 kW 0000 / 0000 A
- // Gun 1 Enable, Type: CCS, Psu Cnt: 00, Max Physical Vol: 0000 V, Cur: 0000 A, Max Config Pow: 0000 kW, Cur: 0000 A
- printf(" %d %d ", gun_index + 1, ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Enable);
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Enable)
- {
- printf(" %7s %2d",
- _chargingData[gun_index]->Type <= _Type_GB ? str_gun_type[_chargingData[gun_index]->Type] : "???",
- ShmChargerInfo->PsuGrouping.GroupCollection[gun_index].GunPsuQuantity);
- printf(" %4d V %4d A",
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].RemoteMaxPhysicalVoltage / 10),
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].RemoteMaxPhysicalCurrent / 10));
- printf(" %4d / %4d / %4d kW",
- (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].MaxTotalChargingPower / 10),
- _chargingData[gun_index]->ChargingProfilePower == -1 ? (int)_chargingData[gun_index]->ChargingProfilePower : ((int)_chargingData[gun_index]->ChargingProfilePower / 1000),
- ShmChargerInfo->OutputLimit.GunMaxProfilePower[gun_index] == 0 ? (int)ShmSysConfigAndInfo->SysInfo.MaxChargingProfilePower : (ShmChargerInfo->OutputLimit.GunMaxProfilePower[gun_index] / 1000));
- printf(" %4d / %4d A",
- ((int)ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].MaxTotalChargingCurrent / 10),
- _chargingData[gun_index]->ChargingProfileCurrent == -1 ? (int)_chargingData[gun_index]->ChargingProfileCurrent : ((int)_chargingData[gun_index]->ChargingProfileCurrent / 10));
- }
- printf("\r\n");
- }
- void ShowChargerLimit(char *inputCmd, unsigned int opt)
- {
- bool keepRun = false;
- bool reflash = false;
- int time = 0;
- struct timespec _Loop_time;
- if((opt & OPTION_REFLASH) || (opt & OPTION_LOOP) > 0)
- {
- keepRun = true;
- }
- printf("\r\n");
- printf("Charger Limit\r\n");
- do
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(time >= 1000)
- {
- if(reflash)
- {
- ConsoleReflash(1, 6);
- ConsoleReflash(CONNECTOR_QUANTITY, 1);
- }
- ShowMaxLimit();
- printf("\r\n");
- printf(" Gun Enable Type Psu Phy_Vol Phy_Cur Config_Ocpp_MaxOcpp_Pow Config_Ocpp_MaxOcpp_Cur\r\n");
- for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
- {
- ShowGunLimit(i);
- }
- GetClockTime(&_Loop_time);
- if((opt & OPTION_REFLASH) > 0)
- {
- reflash = true;
- }
- }
- if(keepRun)
- {
- keepRun = IsLoopStopCmd() ? false : true;
- usleep(10000);
- }
- }while(keepRun);
- printf("\r\n");
- }
- void SetPsuCommand(char *inputCmd, unsigned int opt)
- {
- }
- void SetGunCommand(char *v1, char *v2, char *v3)
- {
- int cmdItem = 0;
- int cmdItemLen = 2;
- int gunID = 0;
- int enable = 0;
- char strGunCmd[32][32] = {"enable", "operative"};
- char strDescription[32][32] = {"Available", "Operative"};
- gunID = atoi(v2);
- enable = atoi(v3);
- if(gunID <= 0 || gunID > CONNECTOR_QUANTITY || enable < 0)
- {
- return;
- }
- for(int i = 0; i < cmdItemLen; i++)
- {
- if(strcmp((char *)&strGunCmd[i][0], v1) == 0)
- {
- cmdItem = i + 1;
- break;
- }
- }
- if(cmdItem != 0)
- {
- switch(cmdItem)
- {
- case 1:
- ShmChargerInfo->Control.GunAvailable[gunID - 1] = enable > 0 ? YES : NO;
- ShmChargerInfo->ConnectorMiscReq[gunID - 1].bits.Availability = true;
- break;
- case 2:
- _chargingData[gunID - 1]->IsAvailable = enable > 0 ? YES : NO;
- ShmChargerInfo->ConnectorMiscReq[gunID - 1].bits.Availability = true;
- break;
- }
- printf("Gun cmd [%s] [%s]\n", strDescription[cmdItem - 1], enable ? "Enable" : "Disable");
- }
- else
- {
- printf("Gun cmd %s not found\n", v1);
- for(int i = 0; i < cmdItemLen; i++)
- {
- printf(" [%s] -> %s Test\n", strGunCmd[i], strDescription[i]);
- }
- }
- printf("\r\n");
- }
- void ShowWebSystemInfo(void)
- {
- char *str_led_intensity[] = {STR_DARKEST, STR_MEDIUM, STR_BRIGHTEST};
- char *str_qr_code_made[] = {STR_QR_DEFAULT, STR_QR_CUSTOMIZED, STR_QR_CHARGEBOXID};
- char *str_rfid_endian[] = {STR_LITTLE_ENDIAN, STR_BIG_ENDIAN};
- printf("\r\n");
- printf("Web [System]\r\n");
- printf(" *System ID: %s\r\n", ShmSysConfigAndInfo->SysConfig.SystemId);
- printf(" *AuthorisationMode[%7s]\r\n",
- ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE ? "Enable" : "Disable");
- printf(" - APP [%7s]\r\n", ShmSysConfigAndInfo->SysConfig.isAPP > 0 ? "Enable" : "Disable");
- printf(" - QRCode [%7s]\r\n", ShmSysConfigAndInfo->SysConfig.isQRCode > 0 ? "Enable" : "Disable");
- printf(" - RFID [%7s]\r\n", ShmSysConfigAndInfo->SysConfig.isRFID > 0 ? "Enable" : "Disable");
- printf(" - EVCCID [%7s]\r\n", ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID > 0 ? "Enable" : "Disable");
- if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian <= RFID_ENDIAN_BIG)
- {
- printf(" *RfidCardNumEndian [%s]\r\n", str_rfid_endian[ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian]);
- }
- else
- {
- printf(" *RfidCardNumEndian: %d\r\n", ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian);
- }
- if(ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode <= _QR_MODE_Customized)
- {
- printf(" *QR Code Made [%s]\r\n", str_qr_code_made[ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode]);
- }
- else
- {
- printf(" *QR Code Made: %d\r\n", ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode);
- }
- if(ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode == _QR_MODE_Customized)
- {
- printf(" - QR Code Content: %s\r\n", ShmSysConfigAndInfo->SysConfig.QRCodeContent);
- }
- if(ShmChargerInfo->AuthInfo.QRCodeMode <= _QR_MODE_ChargeBoxId)
- {
- printf(" *QR Code Mode [%s]\r\n", str_qr_code_made[ShmChargerInfo->AuthInfo.QRCodeMode]);
- }
- else
- {
- printf(" *QR Code Mode: %d\r\n", ShmChargerInfo->AuthInfo.QRCodeMode);
- }
- if(ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity <= _LED_INTENSITY_BRIGHTEST)
- {
- printf(" *LED Intensity[%s]\r\n", str_led_intensity[ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity]);
- }
- else
- {
- printf(" *LED Intensity[%d]\r\n", ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity);
- }
- }
- void ShowWebChargingInfo(void)
- {
- printf("\r\n");
- printf("Web [Charging]\r\n");
- printf(" *Max Charging Energy : %4d kWh\r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy);
- printf(" *Max Charging Power : %4d kW\r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingPower);
- printf(" *Max Charging Current : %4d A\r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
- printf(" *Max Charging Duration: %4d Minutes\r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingDuration);
- printf(" *Max Charging Soc : %4d %%\r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingSoc);
- printf(" *StopCharging By Button[%7s]\r\n", ShmSysConfigAndInfo->SysConfig.StopChargingByButton > 0 ? "Enable" : "Disable");
- printf(" *Billing[%7s]\r\n", ShmSysConfigAndInfo->SysConfig.BillingData.isBilling > 0 ? "Enable" : "Disable");
- printf(" - Currency[%2d]\r\n", ShmSysConfigAndInfo->SysConfig.BillingData.Currency);
- }
- // *DHCP Client [Enable]
- // - MAC Add [%s]
- // - IP Add [%s]
- // - Submask [%s]
- // - Gateway [%s]
- void ShowEthernetInfo(void)
- {
- printf(" *DHCP Client [%s]\r\n", ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient == 0 ? "Enable" : "Disable");
- printf(" - MAC Add [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthMacAddress) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthMacAddress : "NULL");
- printf(" - IP Add [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress : "NULL");
- printf(" - SubMask [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress : "NULL");
- printf(" - Gateway [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress : "NULL");
- }
- // *WiFi Mode [Station]
- // - SSID [%s]
- // - PWD [%s]
- // - TargetMac [%s]
- // - RSSI [%s]
- // - DHCP [%s]
- // - MAC Add [%s]
- // - IP Add [%s]
- // - Submask [%s]
- // - Gateway [%s]
- // - ConnStatus [Connected]
- void ShowWiFiInfo(void)
- {
- char *str_wifi_mode[] = {"Disable", "Station", "AP Mode"};
- if(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode <= _SYS_WIFI_MODE_AP)
- {
- printf(" *WiFi Mode [%s]\r\n", str_wifi_mode[ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode]);
- }
- else
- {
- printf(" *WiFi Mode [%d]\r\n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode);
- }
- if(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == _SYS_WIFI_MODE_STATION)
- {
- printf(" - SSID [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid : "NULL");
- printf(" - PWD [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword : "NULL");
- printf(" - TargetMac [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiTargetBssidMac) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiTargetBssidMac : "NULL");
- printf(" - RSSI [%d dBm]\r\n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiRssi);
- printf(" - DHCP [%s]\r\n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient == 0 ? "Enable" : "Disable");
- printf(" - MAC Add [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress : "NULL");
- printf(" - IP Add [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress : "NULL");
- printf(" - SubMask [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSubmaskAddress) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSubmaskAddress : "NULL");
- printf(" - Gateway [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress : "NULL");
- printf(" - ConnStatus [%s]\r\n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn == YES ? "Connected" : "Disconnected");
- }
- }
- // *3G/4G Mode [%s]
- // - APN [%s]
- // - NetworkType[%s]
- // - RSSI [%d dBm]
- // - ChapPapId [%s]
- // - ChapPapPwd [%s]
- // - Modem IMEI [%s]
- // - SIM IMSI [%s]
- // - SIM ICCID [%s]
- // - SIM Status [%s]
- // - Modem Mode [%s]
- // - IP Add [%s]
- // - ConnStatus [%s]
- void Show3G4GInfo(void)
- {
- char *strNetworkType[] = {"Auto", "CDMA", "WCDMA", "LTE", "TD-SCDMA", "UMTS", "CDMA", "HDR", "CDMA/HDR"};
- char *strSimStatus[] = {"No SIM Card", "Valid SIM Card", "Invalid SIM Card"};
- char *strModemMode[] = {"No Services", "CDMA", "GSM/GPRS", "WCDMA", "GSM/WCDMA", "TD_SCDMA", "HSPA", "LTE", "Mode 8", "Unknown"};
- printf(" *3G/4G Mode [%s]\r\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == YES ? "Enable" : "Disable");
- if(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == YES)
- {
- printf(" - APN [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn : "NULL");
- if(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkType <= 8)
- {
- printf(" - NetworkType[%s]\r\n", strNetworkType[ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkType]);
- }
- else
- {
- printf(" - NetworkType[%d]\r\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkType);
- }
- printf(" - RSSI [%d dBm]\r\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi);
- printf(" - ChapPapId [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId : "NULL");
- printf(" - ChapPapPwd [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd : "NULL");
- printf(" - Modem IMEI [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei : "NULL");
- printf(" - SIM IMSI [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi : "NULL");
- printf(" - SIM ICCID [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid : "NULL");
- if(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimStatus <= 2)
- {
- printf(" - SIM Status [%s]\r\n", strSimStatus[ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimStatus]);
- }
- else
- {
- printf(" - SIM Status [%d]\r\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimStatus);
- }
- if(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode <= 9)
- {
- printf(" - Modem Mode [%s]\r\n", strModemMode[ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode]);
- }
- else
- {
- printf(" - Modem Mode [%d]\r\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode);
- }
- printf(" - IP Add [%s]\r\n", strlen((char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress) > 0 ? (char *)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress : "NULL");
- printf(" - ConnStatus [%s]\r\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == YES ? "Connected" : "Disconnected");
- }
- }
- void ShowWebNetworkInfo(void)
- {
- printf("\r\n");
- printf("Web [Network]\r\n");
- printf(" *NetworkStatus[%s]\r\n", ShmSysConfigAndInfo->SysInfo.InternetConn > 0 ? "Connected" : "Disconnected");
- ShowEthernetInfo();
- ShowWiFiInfo();
- Show3G4GInfo();
- }
- void ShowWebEthernetOnly(void)
- {
- printf("\r\n");
- printf("Web [Network]\r\n");
- printf(" *NetworkStatus[%s]\r\n", ShmSysConfigAndInfo->SysInfo.InternetConn > 0 ? "Connected" : "Disconnected");
- ShowEthernetInfo();
- }
- void ShowWebWiFiOnly(void)
- {
- printf("\r\n");
- printf("Web [Network]\r\n");
- printf(" *NetworkStatus[%s]\r\n", ShmSysConfigAndInfo->SysInfo.InternetConn > 0 ? "Connected" : "Disconnected");
- ShowWiFiInfo();
- }
- void ShowWeb3G4GOnly(void)
- {
- printf("\r\n");
- printf("Web [Network]\r\n");
- printf(" *NetworkStatus[%s]\r\n", ShmSysConfigAndInfo->SysInfo.InternetConn > 0 ? "Connected" : "Disconnected");
- Show3G4GInfo();
- }
- void ShowWebBackendInfo(void)
- {
- char *str_offline_policy[] = {"Local List", "Phihong RFID", "Free Charging", "No Charging"};
- char *str_security_profile[] = {
- "None security",
- "Unsecured Transport with Basic Atuentication",
- "TLS with Basic Authentication",
- "TLS with Client Side Certificates"
- };
- printf("\r\n");
- printf("Web [Backend]\r\n");
- printf(" *Common\r\n");
- printf(" - Backend Timeout : %d s\r\n", ShmSysConfigAndInfo->SysConfig.BackendConnTimeout);
- if(ShmSysConfigAndInfo->SysConfig.OfflinePolicy <= _OFFLINE_POLICY_NO_CHARGING)
- {
- printf(" - Offline Policy : %s\r\n", str_offline_policy[ShmSysConfigAndInfo->SysConfig.OfflinePolicy]);
- }
- else
- {
- printf(" - Offline Policy : %d\r\n", ShmSysConfigAndInfo->SysConfig.OfflinePolicy);
- }
- printf(" - OfflineMaxEnergy : %4d kWh\r\n", ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy);
- printf(" - OfflineMaxDuration: %4d Minutes\r\n", ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration);
- printf(" *OCPP\r\n");
- printf(" - OcppStatus[%s]\r\n", ShmSysConfigAndInfo->SysInfo.OcppConnStatus == YES ? "Connected" : "Disconnected");
- printf(" - OcppURL : %s\r\n", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
- printf(" - ChargeBoxId: %s\r\n", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
- printf(" - Vendor : %s\r\n", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
- if(ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile <= 3)
- {
- printf(" - Security : %s\r\n", str_security_profile[ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile]);
- }
- else
- {
- printf(" - Security : %d\r\n", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
- }
- printf(" - MaintainStatus[%s]\r\n", ShmSysConfigAndInfo->SysInfo.MaintainServerConnStatus == YES ? "Connected" : "Disconnected");
- printf(" - MaintainURL : %s\r\n", ShmSysConfigAndInfo->SysConfig.MaintainServerURL);
- if(ShmSysConfigAndInfo->SysConfig.MaintainServerSecurityProfile <= 3)
- {
- printf(" - MaintainSecurity: %s\r\n", str_security_profile[ShmSysConfigAndInfo->SysConfig.MaintainServerSecurityProfile]);
- }
- else
- {
- printf(" - MaintainSecurity: %d\r\n", ShmSysConfigAndInfo->SysConfig.MaintainServerSecurityProfile);
- }
- printf(" *TTIA[%7s]\r\n", ShmSysConfigAndInfo->SysConfig.TTIA_Info.isEnableTTIA == YES ? "Enable" : "Disable");
- if(ShmSysConfigAndInfo->SysConfig.TTIA_Info.isEnableTTIA == YES)
- {
- printf(" - ServerAddress: %s\r\n", ShmSysConfigAndInfo->SysConfig.TTIA_Info.server_addr);
- printf(" - ServerPort : %d\r\n", ShmSysConfigAndInfo->SysConfig.TTIA_Info.server_port);
- printf(" - BusVenderId : %d\r\n", ShmSysConfigAndInfo->SysConfig.TTIA_Info.busVenderId);
- printf(" - Provider : %s\r\n", ShmSysConfigAndInfo->SysConfig.TTIA_Info.EquipmentProvider);
- printf(" - CompanyNo : %d\r\n", ShmSysConfigAndInfo->SysConfig.TTIA_Info.TransportationCompanyNo);
- printf(" - ChargeBoxId : %d\r\n", ShmSysConfigAndInfo->SysConfig.TTIA_Info.ChargeBoxId);
- printf(" - EVSEStation : %s\r\n", ShmSysConfigAndInfo->SysConfig.TTIA_Info.evseStation);
- }
- }
- void ShowWebAllInfo(void)
- {
- ShowWebSystemInfo();
- ShowWebChargingInfo();
- ShowWebNetworkInfo();
- ShowWebBackendInfo();
- }
- void ShowWebInfo(char *inputCmd, unsigned int opt)
- {
- int totalCnt = 0, maxPara = 0;
- maxPara = 1;
- totalCnt = GetSubCommand(inputCmd);
- if(totalCnt > maxPara)
- {
- printf("Input cmd fail ------ web [cmd]\r\n\r\n");
- return;
- }
- bool find = false;
- int showItem = 0;
- int itemLen = 8;
- char strItem[32][32] = {"system", "charging", "network", "backend", "all", "eth", "wifi", "4g"};
- void *actionList[32] = {
- &ShowWebSystemInfo, &ShowWebChargingInfo, &ShowWebNetworkInfo, &ShowWebBackendInfo,
- &ShowWebAllInfo, &ShowWebEthernetOnly, &ShowWebWiFiOnly, &ShowWeb3G4GOnly};
- void (*ItemAction)();
- for(showItem = 0; showItem < itemLen; showItem++)
- {
- if(strcmp((char *)&strItem[showItem][0], &MultiSubCmd[0][0]) == 0)
- {
- find = true;
- break;
- }
- }
- if(find)
- {
- ItemAction = actionList[showItem];
- ItemAction();
- }
- else
- {
- printf("\r\n");
- printf ("Input cmd fail ------ web [cmd]\r\n");
- for(int i = 0; i < itemLen; i++)
- {
- printf(" [cmd] %s\r\n", (char *)&strItem[i][0]);
- }
- }
- printf("\r\n");
- }
- // Gun 1 ( CCS ) Soc: XXX %, Energy: XXXXXXX.XXX kWh, IdTag: [XXXXXXXXXX]
- // (XX) (X) Target: XXXX V, XXXX A, Cap: XXXX A, XXXX kW, TxId: [XXXXXXXXXX]
- // PSU: XXXX V, XXXX A, Limit: XXXX A, XXXX kW, Local: XXXXXXX.XXX kWh
- // Start: [0000-00-00 00:00:00] PSU: XXXX V, XXXX A, Limit: XXXX A, XXXX kW, Local: XXXXXXX.XXX kWh
- // Gun: XXXX V, XXXX A, Remote: XXXXXXX.XXX kWh, Meter: XXXXXXX.XXX kWh
- // Stop: [0000-00-00 00:00:00] Gun: XXXX V, XXXX A, Remote: XXXXXXX.XXX kWh, Meter: XXXXXXX.XXX kWh
- // Gun 1 ( CCS ) Soc: XXX %, Energy: XXXXXXX.XXX kWh, IdTag: [XXXXXXXXXX]
- // (XX) (X) Target: XXXX V, XXXX A, Cap: XXXX A, XXXX kW, TxId: [XXXXXXXXXX]
- // Start: [0000-00-00 00:00:00] PSU: XXXX V, XXXX A, Limit: XXXX A, XXXX kW, Ratio: X.XX %
- // Stop: [0000-00-00 00:00:00] Gun: XXXX V, XXXX A, Power: XXXX.X kW, FireV: XXXX.X V
- // Remote: XXXXXXX.XXX kWh, Local: XXXXXXX.XXX kWh, Meter: XXXXXXX.XXX kWh
- void ShowGunInfo(int gun)
- {
- char *str_gun_type[] = {"CHAdeMO", " CCS ", " GBT "};
- #if 0
- printf(" Gun %d (%s) Soc: %3d %s, Energy: %10.3f kWh, IdTag [%20s] Transaction [%d], TotalCost: %.2f\r\n",
- gun + 1,
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].Enable ? str_gun_type[_chargingData[gun]->Type] : "Disable",
- _chargingData[gun]->EvBatterySoc, "%",
- _chargingData[gun]->PresentChargedEnergy,
- _chargingData[gun]->StartUserId,
- ShmChargerInfo->UserTransaction[gun].TransactionId,
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].TotalCost);
- #endif
- //************************************************************************************************
- printf(" Gun %d (%s) Soc: %3d %s, Energy: %11.3f kWh",
- gun + 1,
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].Enable ? str_gun_type[_chargingData[gun]->Type] : "Disable",
- _chargingData[gun]->EvBatterySoc, "%",
- _chargingData[gun]->PresentChargedEnergy);
- if(strlen((char *)_chargingData[gun]->StartUserId) > 0)
- {
- printf(", IdTag: [%s]", _chargingData[gun]->StartUserId);
- }
- printf("\r\n");
- //************************************************************************************************
- printf(" (%2d) (%s) Target: %4d V, %4d A, Cap: %4d A, %4d kW",
- _chargingData[gun]->SystemStatus,
- _chargingData[gun]->ConnectorPlugIn ? "O" : "X",
- (int)_chargingData[gun]->EvBatterytargetVoltage,
- (int)_chargingData[gun]->EvBatterytargetCurrent,
- (int)(_chargingData[gun]->AvailableChargingCurrent / 10),
- (int)(_chargingData[gun]->AvailableChargingPower / 10));
- if(ShmChargerInfo->UserTransaction[gun].TransactionId > 0)
- {
- printf(", TxId: [%d]", ShmChargerInfo->UserTransaction[gun].TransactionId);
- }
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].TotalCost > 0)
- {
- printf(", $: %.2f", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].TotalCost);
- }
- printf("\r\n");
- //************************************************************************************************
- if(strlen(ShmChargerInfo->Timestamp[gun].StartCharging) > 0)
- {
- printf(" Start: [%s] ", ShmChargerInfo->Timestamp[gun].StartCharging);
- }
- else
- {
- printf(" ");
- }
- printf("PSU: %4d V, %4d A, Limit: %4d A, %4d kW, Ratio: %4.2f %%\r\n",
- (int)(_chargingData[gun]->PresentChargingVoltage),
- (int)(_chargingData[gun]->PresentChargingCurrent),
- (int)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].CapabilityCurrent / 10),
- (int)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].CapabilityPower / 10),
- ShmPsuGrouping->GroupCollection[gun].MaxOutputRatio);
- //************************************************************************************************
- if(strlen(ShmChargerInfo->Timestamp[gun].StopCharging) > 0)
- {
- printf(" Stop: [%s] ", ShmChargerInfo->Timestamp[gun].StopCharging);
- }
- else
- {
- printf(" ");
- }
- printf("Gun: %4d V, %4d A, Power: %6.1f kW, FireV: %6.1f V\r\n",
- (int)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].RemoteChargingVoltage / 10),
- (int)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].RemoteChargingCurrent / 10),
- _chargingData[gun]->PresentChargingPower,
- (_chargingData[gun]->FireChargingVoltage / 10));
- //************************************************************************************************
- printf(" Remote: %11.3f kWh, Local: %11.3f kWh, Meter: %11.3f kWh\r\n",
- ShmChargerInfo->MeterValue[gun].GunConsumption,
- ShmChargerInfo->MeterValue[gun].LocalConsumption,
- _chargingData[gun]->PowerConsumption);
- }
- void ShowInfo(char *inputCmd, unsigned int opt)
- {
- bool keepRun = false;
- bool reflash = false;
- int time = 0;
- struct timespec _Loop_time;
- if((opt & OPTION_REFLASH) || (opt & OPTION_LOOP) > 0)
- {
- keepRun = true;
- }
- do
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(time >= 1000)
- {
- if(reflash)
- {
- ConsoleReflash(CONNECTOR_QUANTITY, 6);
- }
- for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
- {
- printf("\r\n");
- ShowGunInfo(i);
- }
- GetClockTime(&_Loop_time);
- if((opt & OPTION_REFLASH) > 0)
- {
- reflash = true;
- }
- }
- if(keepRun)
- {
- keepRun = IsLoopStopCmd() ? false : true;
- usleep(10000);
- }
- }while(keepRun);
- printf("\r\n");
- }
- void RtcSyncCmd(char *inputCmd, unsigned int opt)
- {
- int totalCnt = 0, maxPara = 0;
- char hostAdd[32];
- int dispenser = 0, offset = 0;
- memset(hostAdd, 0x00, sizeof(hostAdd));
- maxPara = 2;
- totalCnt = GetSubCommand(inputCmd);
- if(totalCnt != maxPara)
- {
- printf("Input cmd fail ------ rtc [dispenser 1-4] [offset minute]\r\n\r\n");
- return;
- }
- printf("\r\n");
- dispenser = atoi(&MultiSubCmd[0][0]);
- offset = atoi(&MultiSubCmd[1][0]);
- if(dispenser <= 0 || dispenser > CONNECTOR_QUANTITY)
- {
- printf("dispenser %d over range\r\n\r\n", dispenser);
- return;
- }
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser - 1].LocalStatus == _DS_None ||
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser - 1].LocalStatus == _DS_Timeout)
- {
- printf("dispenser %d is not available\r\n\r\n", dispenser);
- return;
- }
- // find dispenser ip address
- for(int i = 0; i < CONNECTOR_QUANTITY; i++)
- {
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].Status == _CNS_DispenserMatched)
- {
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].DispenserIndex == (dispenser - 1))
- {
- sprintf(hostAdd, "%d.%d.%d.%d",
- ((ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress >> 0) &0xFF),
- ((ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress >> 8) &0xFF),
- ((ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress >> 16) &0xFF),
- ((ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress >> 24) &0xFF));
- }
- }
- }
- if(strlen(hostAdd) == 0)
- {
- printf("dispenser %d ip is not available\r\n\r\n", dispenser);
- return;
- }
- printf("try sycn dispenser %d [%s] rtc, offset: %d minutes\r\n", dispenser, hostAdd, offset);
- // get current time and create offset time
- time_t timep;
- struct tm *tm;
- time(&timep);
- tm = localtime(&timep);
- printf(" NowTime: %d/%02d/%02d %02d:%02d:%02d\r\n",
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
- if(offset != 0)
- {
- timep += (offset * 60);
- tm = localtime(&timep);
- printf("OffsetTime: %d/%02d/%02d %02d:%02d:%02d\r\n\r\n",
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
- }
- // create send socket
- int rtcfd = 0;
- struct sockaddr_in serverInfo;
- struct timeval tv;
- char rtcTxBuffer[64];
- char rtcRxBuffer[64];
- int txLen = 0, rxLen = 0;
- unsigned char chksum = 0x00;
- rtcfd = socket(AF_INET, SOCK_STREAM, 0);
- if (rtcfd < 0)
- {
- printf("create rtc socket fail\r\n\r\n");
- return;
- }
- memset(rtcTxBuffer, 0x00, sizeof(rtcTxBuffer));
- memset(rtcRxBuffer, 0x00, sizeof(rtcRxBuffer));
- tv.tv_sec = 3;
- tv.tv_usec = 0;
- setsockopt(rtcfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval)); //設定等待3s
- setsockopt(rtcfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(struct timeval)); //設定傳送3s
- bzero(&serverInfo,sizeof(serverInfo));
- serverInfo.sin_family = AF_INET;
- serverInfo.sin_addr.s_addr = inet_addr(hostAdd);
- serverInfo.sin_port = htons(8234);
- if(connect(rtcfd, (struct sockaddr *)&serverInfo, sizeof(serverInfo)) < 0)
- {
- printf("connect to host: %s fail\r\n\r\n", hostAdd);
- close(rtcfd);
- return;
- }
- // set tx header & data
- rtcTxBuffer[0] = 0xAA; // Frame ID
- rtcTxBuffer[1] = 0x00; // Master address
- rtcTxBuffer[2] = 0xFF; // Slave address
- rtcTxBuffer[3] = 0x87; // 0x87
- rtcTxBuffer[4] = 0x0E; // Length_Low
- rtcTxBuffer[5] = 0x00; // Length_High
- sprintf(&rtcTxBuffer[6], "%04d%02d%02d%02d%02d%02d",
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
- txLen = rtcTxBuffer[4] + (rtcTxBuffer[5] << 8);
- chksum = 0;
- for(int i = 0; i < txLen; i++)
- {
- chksum ^= rtcTxBuffer[6 + i];
- }
- rtcTxBuffer[6 + txLen] = chksum;
- send(rtcfd, rtcTxBuffer, txLen + 7, MSG_NOSIGNAL);
- // receive
- if(recv(rtcfd, &rtcRxBuffer[0], 6, MSG_WAITALL) < 0)
- {
- printf("read head fail\r\n\r\n");
- close(rtcfd);
- return;
- }
- rxLen = rtcRxBuffer[4] + (rtcRxBuffer[5] << 8);
- if(recv(rtcfd, &rtcRxBuffer[6], rxLen + 1, MSG_WAITALL) < 0)
- {
- printf("read data fail\r\n\r\n");
- close(rtcfd);
- return;
- }
- chksum = 0;
- for(int i = 0; i < rxLen; i++)
- {
- chksum ^= rtcRxBuffer[6 + i];
- }
- if(chksum == rtcRxBuffer[6 + rxLen])
- {
- printf("set %s rtc: ", hostAdd);
- for(int i = 0; i < txLen; i++)
- {
- printf("%c", rtcTxBuffer[6 + i]);
- }
- printf(" %s\r\n\r\n", rtcRxBuffer[6] == 0x01 ? "success" : "fail");
- }
- else
- {
- printf("receive rtc checksum fail\r\n\r\n");
- }
- close(rtcfd);
- }
- void ParsingModelName(char *modelName)
- {
- ParsingRatedCur parsingRatedCur = {0};
- RateCurInfo *pRatedCurInfo = NULL;
- if(RatedCurrentParsing(modelName, &parsingRatedCur) != PASS)
- {
- printf("Parsing [%s] failed\r\n", modelName);
- return;
- }
- printf("Model Name: [%s]\r\n", modelName);
- for(int i = 0; i < 2; i++)
- {
- pRatedCurInfo = (RateCurInfo *)&parsingRatedCur.ParsingInfo[i];
- printf(" Gun %d Type %d, MaxVol: %d, MaxCur: %d\r\n",
- i + 1, pRatedCurInfo->GunType, pRatedCurInfo->Voltage, pRatedCurInfo->Current);
- }
- }
- void ParsingModelNameCmd(char *inputCmd, unsigned int opt)
- {
- int totalCnt = 0, maxPara = 0;
- maxPara = 1;
- totalCnt = GetSubCommand(inputCmd);
- if(totalCnt > maxPara)
- {
- printf("Input cmd fail ------ pmodel [model_name]\r\n\r\n");
- return;
- }
- printf("\r\n");
- if(totalCnt != 0)
- {
- ParsingModelName(&MultiSubCmd[0][0]);
- }
- else
- {
- printf("Cabinet\r\n");
- ParsingModelName((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[0]);
- for(int i = 0; i < ShmSysConfigAndInfo->SysInfo.DispenserInfo.DispenserQuantity; i++)
- {
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].LocalStatus != _DS_None &&
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].LocalStatus != _DS_Timeout)
- {
- printf("\r\n");
- printf("Dispenser %d\r\n", i + 1);
- ParsingModelName((char *)&ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[i].ModelName[0]);
- }
- }
- }
- printf("\r\n");
- }
- void CustomerPriceTest(char *inputCmd, unsigned int opt)
- {
- #if 0
- char priceString[512];
- float price = 0;
- printf("\r\n");
- // running cost
- printf("Running Cost\r\n");
- strcpy(priceString, "Connection Fee: $0 NTD; Session Fee: $15.96 NTD; Occupancy Fee: $0 NTD; Total Cost: $15.96 NTD; Account Balance: $37693 NTD");
- price = PriceParsing((char *)priceString, "Connection Fee", _AUDI_PRICE_SPLIT_KEY);
- printf("Connection Fee: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Session Fee", _AUDI_PRICE_SPLIT_KEY);
- printf("Session Fee: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Occupancy Fee", _AUDI_PRICE_SPLIT_KEY);
- printf("Occupancy Fee: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Total Cost", _AUDI_PRICE_SPLIT_KEY);
- printf("Total Cost: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Account Balance", _AUDI_PRICE_SPLIT_KEY);
- printf("Account Balance: %.2f\r\n", price);
- // final cost
- printf("Final Cost\r\n");
- strcpy(priceString, "Connection Fee: $0 NTD; Session Fee: $283.68 NTD; Occupancy Fee: $0 NTD; Total Cost: $283.68 NTD; Account Balance: $37410 NTD");
- price = PriceParsing((char *)priceString, "Connection Fee", _AUDI_PRICE_SPLIT_KEY);
- printf("Connection Fee: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Session Fee", _AUDI_PRICE_SPLIT_KEY);
- printf("Session Fee: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Occupancy Fee", _AUDI_PRICE_SPLIT_KEY);
- printf("Occupancy Fee: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Total Cost", _AUDI_PRICE_SPLIT_KEY);
- printf("Total Cost: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Account Balance", _AUDI_PRICE_SPLIT_KEY);
- printf("Account Balance: %.2f\r\n", price);
- // user price
- printf("User Price\r\n");
- strcpy(priceString, "Connection Fee: $0 NTD/time; Current Rate: $12 NTD/kWh; Occupancy Fee: $0 NTD/hr; Account Balance: $17553 NTD");
- price = PriceParsing((char *)priceString, "Connection Fee", _AUDI_PRICE_SPLIT_KEY);
- printf("Connection Fee: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Current Rate", _AUDI_PRICE_SPLIT_KEY);
- printf("Current Rate: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Occupancy Fee", _AUDI_PRICE_SPLIT_KEY);
- printf("Occupancy Fee: %.2f\r\n", price);
- price = PriceParsing((char *)priceString, "Account Balance", _AUDI_PRICE_SPLIT_KEY);
- printf("Account Balance: %.2f\r\n", price);
- // default price
- printf("Default Price\r\n");
- strcpy(priceString, "Connection Fee: $0 NTD/time; Current Rate: $12 NTD/kWh; Occupancy Fee: $0 NTD/hr");
- price = PriceParsing(priceString, "Connection Fee", _AUDI_PRICE_SPLIT_KEY);
- printf("Connection Fee: %.2f\r\n", price);
- price = PriceParsing(priceString, "Current Rate", _AUDI_PRICE_SPLIT_KEY);
- printf("Current Rate: %.2f\r\n", price);
- price = PriceParsing(priceString, "Occupancy Fee", _AUDI_PRICE_SPLIT_KEY);
- printf("Occupancy Fee: %.2f\r\n", price);
- printf("\r\n");
- printf("TCC Default Price\r\n");
- strcpy(priceString, "$ 12/kWh");
- price = PriceParsing(priceString, "", "");
- printf("Default: %.2f\r\n", price);
- printf("\r\n");
- char userPrice[512];
- printf("Shell Default Price\r\n");
- strcpy(priceString, "100.0 kW\nPrice\nTransaction Fee: $0.6165/Flat\nIdle Fee: $0.5/Flat\n\n100.0 kW\nPrice\nTransaction Fee: $0.6165/Flat\nIdle Fee: $0.5/Flat\n\n");
- ShellPriceParsing(priceString, userPrice);
- printf("DefaultPrice: %s\r\n", userPrice);
- printf("\r\n");
- printf("Shell User Price\r\n");
- ShellPriceParsing(priceString, userPrice);
- printf("UserPrice: %s\r\n", userPrice);
- printf("\r\n");
- strcpy(priceString, "Current Period Price:$0.35/kWh\nCurrent Idle Fee: $5.0/hr\nCurrent Total: 2.70kWh $2.53 ConnectorId: 1\nLast update: 2021-06-28T11:22:31");
- price = ShellRunningCostParsing(priceString);
- printf("Shell Running Cost\r\n");
- printf("Cost: %.2f\r\n", price);
- printf("\r\n");
- strcpy(priceString, "2022-01-18 07:00:00-2022-01-18 08:15:30\n07:00 AM $1.00/kWh 4.30kWh Cost: $4.300\n07:30 AM $2.00/kWh 0.00kWh Cost: $4.300\n07:46 AM $0.00/Flat 10m Cost: $0.000\n07:56 AM $0.50/Flat 19m Cost: $0.500\nTotal\nSale: $4.80\nTax: $0.00\nTransaction Fee: $0.62\nDiscount: $0.00\nCost: $5.42\nEnergy: 4.3000kWh\nTime: 1 Hrs 15 Mins\nPayment: RFID\nReceipt: https://qa.qa.greenlotstest-qa.com/greenlots/receipt.jsf?session5658739 | Call 1 800 Greenlots or check app for more detailed receipt\nEV_DISCONNECTED");
- printf("Shell Final Cost\r\n");
- int urlLen = 0;
- char url[512];
- price = ShellFinalCostParsing(priceString);
- urlLen = GetShellReceiptInfo(priceString, url);
- printf("Cost: %.2f\r\n", price);
- if(urlLen > 0)
- {
- printf("Receipt: [%s]\r\n", url);
- }
- #endif
- }
- void EvCommMsgDebug(char *inputCmd, unsigned int opt)
- {
- int totalCnt = 0, maxPara = 0;
- maxPara = 2;
- totalCnt = GetSubCommand(inputCmd);
- printf("\r\n");
- if(totalCnt == 1)
- {
- if(strcmp(&MultiSubCmd[0][0], "clean") == 0)
- {
- ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[0] = 0;
- ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[1] = 0;
- ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[2] = 0;
- ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[3] = 0;
- ShmChargerInfo->Control.DebugCtrl.bits.MsgEvComm = false;
- printf("Clean All EvComm Msg Flag\r\n");
- printf("Disable MsgEvComm Flag Debug\r\n\r\n");
- return;
- }
- }
- if(totalCnt != maxPara)
- {
- printf("Input cmd fail ------ evmsg [reg] [enable 0-1]\r\n\r\n");
- return;
- }
- bool find = false;
- int reg = 0, enable = 0;
- reg = atoi(&MultiSubCmd[0][0]);
- enable = atoi(&MultiSubCmd[1][0]);
- if(enable > 1 || enable < 0)
- {
- printf("enable(%d) out of range\r\n\r\n", enable);
- return;
- }
- if(reg >= _Reg_Dispenser_Model_Name && reg < _Reg_None)
- {
- find = true;
- if(enable)
- {
- ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[reg / 32] |= (1 << (reg % 32));
- printf("Set EvComm Msg Flag: 0x%02X\r\n", reg);
- }
- else
- {
- ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[reg / 32] &= ~(1 << (reg % 32));
- printf("Clean EvComm Msg Flag: 0x%02X\r\n", reg);
- }
- }
- else
- {
- if(strcmp(&MultiSubCmd[0][0], "all") == 0)
- {
- find = true;
- ShmChargerInfo->Control.EvCommCtrl.MsgFlag.bits.RegDbg_All = enable;
- printf("%s EvComm All Msg Flag\r\n", enable ? "Enable" : "Disable");
- }
- }
- if(find)
- {
- printf("EvCommMsg[0]: %08X\r\n", ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[0]);
- printf("EvCommMsg[1]: %08X\r\n", ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[1]);
- printf("EvCommMsg[2]: %08X\r\n", ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[2]);
- printf("EvCommMsg[3]: %08X\r\n", ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[3]);
- printf("\r\n");
- if(ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[0] ||
- ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[1] ||
- ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[2] ||
- ShmChargerInfo->Control.EvCommCtrl.MsgFlag.DebugVal[3])
- {
- if(!ShmChargerInfo->Control.DebugCtrl.bits.MsgEvComm)
- {
- printf("Enable MsgEvComm Flag Debug\r\n\r\n");
- }
- ShmChargerInfo->Control.DebugCtrl.bits.MsgEvComm = true;
- }
- else
- {
- if(ShmChargerInfo->Control.DebugCtrl.bits.MsgEvComm)
- {
- printf("Disable MsgEvComm Flag Debug\r\n\r\n");
- }
- ShmChargerInfo->Control.DebugCtrl.bits.MsgEvComm = false;
- }
- }
- else
- {
- printf("reg: 0x%02X out of range\r\n", reg);
- printf("\r\n");
- }
- }
- void EvCommIdDebug(char *inputCmd, unsigned int opt)
- {
- int totalCnt = 0, maxPara = 0;
- maxPara = 2;
- totalCnt = GetSubCommand(inputCmd);
- printf("\r\n");
- if(totalCnt != maxPara)
- {
- printf("Input cmd fail ------ evid [id] [enable 0-1]\r\n\r\n");
- return;
- }
- int id = 0, enable = 0;
- id = atoi(&MultiSubCmd[0][0]);
- enable = atoi(&MultiSubCmd[1][0]);
- if(enable > 1 || enable < 0)
- {
- printf("enable(%d) out of range\r\n\r\n", enable);
- return;
- }
- if(id > 0 && id <= CONNECTOR_QUANTITY)
- {
- if(enable)
- {
- ShmChargerInfo->Control.EvCommCtrl.IdFlag.DebugVal |= (1 << id);
- printf("Set EvComm ID %d Enable\r\n", id);
- }
- else
- {
- ShmChargerInfo->Control.EvCommCtrl.IdFlag.DebugVal &= ~(1 << id);
- printf("Clean EvComm ID %d\r\n", id);
- }
- printf("EvComm ID: %08X\r\n", ShmChargerInfo->Control.EvCommCtrl.IdFlag.DebugVal);
- printf("\r\n");
- }
- else
- {
- printf("id(%d) out of range\r\n\r\n", id);
- }
- }
- bool SetModelName(char *modelName)
- {
- if(!IsCabinetModelNameLegal(modelName))
- {
- printf("Model Name: [%s] is Illegal\r\n", modelName);
- return false;
- }
- memcpy((char *)&ShmSysConfigAndInfo->SysConfig.ModelName, modelName, MODELNAME_LENGTH);
- printf("Set Model Name: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.ModelName);
- return true;
- }
- bool SetSerialNumber(char *serialNumber)
- {
- if(!IsSerialNumberLegal(serialNumber))
- {
- printf("Serial Number: [%s] is Illegal\r\n", serialNumber);
- return false;
- }
- memcpy((char *)&ShmSysConfigAndInfo->SysConfig.SerialNumber, serialNumber, SERIAL_NUMBER_LENGTH);
- printf("Set Serial Number: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.SerialNumber);
- return true;
- }
- bool SetSystemID(char *systemId)
- {
- if(!IsSystemIdLegal(systemId))
- {
- printf("System ID: [%s] is Illegal\r\n", systemId);
- return false;
- }
- memcpy((char *)&ShmSysConfigAndInfo->SysConfig.SystemId, systemId, strlen(systemId));
- printf("Set System ID: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.SystemId);
- return true;
- }
- bool CleanSystemID(void)
- {
- memset((char *)&ShmSysConfigAndInfo->SysConfig.SystemId, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.SystemId));
- printf("Clean System ID OK\r\n");
- return true;
- }
- bool SetAuthorisationMode(char *mode)
- {
- bool disable = false;
- if(strcmp(mode, "disable") == EQUAL)
- {
- disable = true;
- }
- else
- {
- if(strcmp(mode, "enable") != EQUAL)
- {
- printf("Authorisation Mode: [%s] is Illegal\r\n", mode);
- printf(" [value] enable | disable\r\n");
- return false;
- }
- }
- ShmSysConfigAndInfo->SysConfig.AuthorisationMode = disable;
- printf("Set Authorisation Mode: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.AuthorisationMode == 0 ? "Enable" : "Disable");
- if(disable && ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID)
- {
- printf("AuthorisationMode Is Disable, AuthrizeByEVCCID Need To Set Disable\r\n");
- ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID = false;
- }
- return true;
- }
- bool SetAuthrizeByEVCCID(char *isEVCCID)
- {
- bool enable = false;
- if(strcmp(isEVCCID, "enable") == EQUAL)
- {
- enable = true;
- }
- else
- {
- if(strcmp(isEVCCID, "disable") != EQUAL)
- {
- printf("Authrize By EVCCID: [%s] is Illegal\r\n", isEVCCID);
- printf(" [value] enable | disable\r\n");
- return false;
- }
- }
- if(enable && ShmSysConfigAndInfo->SysConfig.AuthorisationMode == 1)
- {
- printf("AuthorisationMode Is Disable, Reset AuthrizeByEVCCID To Disable\r\n");
- enable = false;
- }
- ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID = enable;
- printf("Set AuthrizeByEVCCID: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.isAuthrizeByEVCCID ? "Enable" : "Disable");
- return true;
- }
- bool SetQRCodeMadeMode(char *qrCodeMode)
- {
- bool customized = false;
- if(strcmp(qrCodeMode, "customized") == EQUAL)
- {
- customized = true;
- }
- else
- {
- if(strcmp(qrCodeMode, "default") != EQUAL)
- {
- printf("QR Code Made Mode: [%s] is Illegal\r\n", qrCodeMode);
- printf(" [value] default | customized\r\n");
- return false;
- }
- }
- ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode = customized;
- printf("Set QRCodeMadeMode: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode ? "Customized" : "Default");
- return true;
- }
- bool SetQRCodeContent(char *content)
- {
- if(strlen(content) >= sizeof(ShmSysConfigAndInfo->SysConfig.QRCodeContent))
- {
- printf("QR Code Content: [%s] is Out Of Length\r\n", content);
- return false;
- }
- memset((char *)&ShmSysConfigAndInfo->SysConfig.QRCodeContent, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.QRCodeContent));
- memcpy((char *)&ShmSysConfigAndInfo->SysConfig.QRCodeContent, content, strlen(content));
- printf("Set QRCodeContent: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.QRCodeContent);
- return true;
- }
- bool CleanQRCodeContent(void)
- {
- memset((char *)&ShmSysConfigAndInfo->SysConfig.QRCodeContent, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.QRCodeContent));
- printf("Clean QRCode Content OK\r\n");
- return true;
- }
- bool SetLEDIntensity(char *intensity)
- {
- int ledIntensity = _LED_INTENSITY_DARKEST;
- char *strIntensity[] = {STR_DARKEST, STR_MEDIUM, STR_BRIGHTEST};
- if(strcmp(intensity, "brightest") == EQUAL)
- {
- ledIntensity = _LED_INTENSITY_BRIGHTEST;
- }
- else if(strcmp(intensity, "medium") == EQUAL)
- {
- ledIntensity = _LED_INTENSITY_MEDIUM;
- }
- else if(strcmp(intensity, "darkest") != EQUAL)
- {
- printf("LED Intensity: [%s] is Illegal\r\n", intensity);
- printf(" [value] darkest | medium | brightest\r\n");
- return false;
- }
- ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = ledIntensity;
- printf("Set LED Intensity: [%s] OK\r\n", strIntensity[ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity]);
- return true;
- }
- bool SetMaxChargingEnergy(char *energy)
- {
- int _energy = 0;
- _energy = atoi(energy);
- if(_energy < 0)
- {
- printf("MaxChargingEnergy: [%s] is Illegal\r\n", energy);
- printf(" [value] > 0\r\n");
- return false;
- }
- ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy = _energy;
- printf("Set MaxChargingEnergy: [%d] OK\r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy);
- return true;
- }
- bool SetMaxChargingPower(char *power)
- {
- int _power = 0;
- _power = atoi(power);
- if(_power < 0)
- {
- printf("MaxChargingEnergy: [%s] is Illegal\r\n", power);
- printf(" [value] > 0\r\n");
- return false;
- }
- ShmSysConfigAndInfo->SysConfig.MaxChargingPower = _power;
- printf("Set MaxChargingPower: [%d] OK\r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingPower);
- return true;
- }
- bool SetMaxChargingCurrent(char *current)
- {
- int _current = 0;
- _current = atoi(current);
- if(_current < 0)
- {
- printf("MaxChargingEnergy: [%s] is Illegal\r\n", current);
- printf(" [value] > 0\r\n");
- return false;
- }
- ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent = _current;
- printf("Set MaxChargingCurrent: [%d] OK\r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
- return true;
- }
- bool SetMaxChargingDuration(char *duration)
- {
- int _duration = 0;
- _duration = atoi(duration);
- if(_duration < 0)
- {
- printf("MaxChargingDuration: [%s] is Illegal\r\n", duration);
- printf(" [value] > 0\r\n");
- return false;
- }
- ShmSysConfigAndInfo->SysConfig.MaxChargingDuration = _duration;
- printf("Set MaxChargingDuration: [%d] OK\r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingDuration);
- return true;
- }
- bool SetMaxChargingSoc(char *soc)
- {
- int _soc = 0;
- _soc = atoi(soc);
- if(_soc < 0 || _soc > 100)
- {
- printf("MaxChargingSoc: [%s] is Illegal\r\n", soc);
- printf(" [value] 0 ~ 100\r\n");
- return false;
- }
- ShmSysConfigAndInfo->SysConfig.MaxChargingSoc = _soc;
- printf("Set MaxChargingSoc: [%d] OK\r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingSoc);
- return true;
- }
- bool SetStopChargingByButton(char *btn)
- {
- bool enable = false;
- if(strcmp(btn, "enable") == EQUAL)
- {
- enable = true;
- }
- else
- {
- if(strcmp(btn, "disable") != EQUAL)
- {
- printf("Stop Charging By Button: [%s] is Illegal\r\n", btn);
- printf(" [value] enable | disable\r\n");
- return false;
- }
- }
- ShmSysConfigAndInfo->SysConfig.StopChargingByButton = enable;
- printf("Set Stop Charging By Button: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.StopChargingByButton ? "Enable" : "Disable");
- return true;
- }
- bool SetOfflinePolicy(char *policy)
- {
- int offlinePolicy = _OFFLINE_POLICY_LOCAL_LIST;
- char *str_offline_policy[] = {"Local List", "Phihong RFID", "Free Charging", "No Charging"};
- if(strcmp(policy, "free") == EQUAL)
- {
- offlinePolicy = _OFFLINE_POLICY_FREE_CHARGING;
- }
- else if(strcmp(policy, "nocharging") == EQUAL)
- {
- offlinePolicy = _OFFLINE_POLICY_NO_CHARGING;
- }
- else if(strcmp(policy, "local") != EQUAL)
- {
- printf("Offline Policy: [%s] is Illegal\r\n", policy);
- printf(" [value] local | rfid | free | nocharging\r\n");
- return false;
- }
- ShmSysConfigAndInfo->SysConfig.OfflinePolicy = offlinePolicy;
- printf("Set Offline Policy: [%s] OK\r\n", str_offline_policy[ShmSysConfigAndInfo->SysConfig.OfflinePolicy]);
- return true;
- }
- bool SetOcppServerURL(char *url)
- {
- if(strlen(url) >= sizeof(ShmSysConfigAndInfo->SysConfig.OcppServerURL))
- {
- printf("Ocpp Server URL: [%s] is Out Of Length\r\n", url);
- return false;
- }
- memset((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
- strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL, url);
- printf("Set Ocpp Server URL: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
- return true;
- }
- bool CleanOcppServerURL(void)
- {
- memset((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
- printf("Clean Ocpp Server URL OK\r\n");
- return true;
- }
- bool SetChargeBoxId(char *boxId)
- {
- if(strlen(boxId) >= sizeof(ShmSysConfigAndInfo->SysConfig.ChargeBoxId))
- {
- printf("Charge Box Id: [%s] is Out Of Length\r\n", boxId);
- return false;
- }
- memset((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.ChargeBoxId));
- strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId, boxId);
- printf("Set Charge Box Id: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
- return true;
- }
- bool CleanChargeBoxId(void)
- {
- memset((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.ChargeBoxId));
- printf("Clean Charge Box Id OK\r\n");
- return true;
- }
- bool SetChargePointVendor(char *vendor)
- {
- if(strlen(vendor) >= sizeof(ShmSysConfigAndInfo->SysConfig.chargePointVendor))
- {
- printf("Charge Point Vendor: [%s] is Out Of Length\r\n", vendor);
- return false;
- }
- memset((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.chargePointVendor));
- strcpy((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor, vendor);
- printf("Set Charge Point Vendor: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
- return true;
- }
- bool CleanChargePointVendor(void)
- {
- memset((char *)&ShmSysConfigAndInfo->SysConfig.chargePointVendor, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.chargePointVendor));
- printf("Clean Charge Point Vendor OK\r\n");
- return true;
- }
- bool SetOcppReceiptrURL(char *receipt)
- {
- if(strlen(receipt) >= sizeof(ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL))
- {
- printf("Ocpp Receiptr URL: [%s] is Out Of Length\r\n", receipt);
- return false;
- }
- memset((char *)&ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL));
- strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL, receipt);
- printf("Set Ocpp Receiptr URL: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL);
- return true;
- }
- bool CleanOcppReceiptrURL(void)
- {
- memset((char *)&ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.OcppReceiptrURL));
- printf("Clean Ocpp Receiptr URL OK\r\n");
- return true;
- }
- bool SetMaintainServerURL(char *url)
- {
- if(strlen(url) >= sizeof(ShmSysConfigAndInfo->SysConfig.MaintainServerURL))
- {
- printf("Maintain Server URL: [%s] is Out Of Length\r\n", url);
- return false;
- }
- memset((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.MaintainServerURL));
- strcpy((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL, url);
- printf("Set Maintain Server URL: [%s] OK\r\n", ShmSysConfigAndInfo->SysConfig.MaintainServerURL);
- return true;
- }
- bool CleanMaintainServerURL(void)
- {
- memset((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.MaintainServerURL));
- printf("Clean Maintain Server URL OK\r\n");
- return true;
- }
- void FlashSetCmd(char *inputCmd, unsigned int opt)
- {
- char subMain[MAX_SUB_CMD_LENGTH];
- char subSub[MAX_SUB_CMD_LENGTH];
- memset(subMain, 0x00, sizeof(subMain));
- memset(subSub, 0x00, sizeof(subSub));
- bool find = false;
- int actIndex = 0;
- int maxLen = 20;
- char strWriteItem[32][32] = {
- "model", "sn", "sysid", "auth", "evccid", "qrmode", "qrcode", "led",
- "energy", "power", "current", "time", "soc", "stopbtn", "policy", "backend",
- "boxid", "vendor", "receipt", "maintain"};
- bool (*writeFlashList[32])(char *) = {
- &SetModelName, &SetSerialNumber, &SetSystemID, &SetAuthorisationMode,
- &SetAuthrizeByEVCCID, &SetQRCodeMadeMode, &SetQRCodeContent, &SetLEDIntensity,
- &SetMaxChargingEnergy, &SetMaxChargingPower, &SetMaxChargingCurrent, &SetMaxChargingDuration,
- &SetMaxChargingSoc, &SetStopChargingByButton, &SetOfflinePolicy, &SetOcppServerURL,
- &SetChargeBoxId, &SetChargePointVendor, &SetOcppReceiptrURL, &SetMaintainServerURL};
- bool (*WriteFlashAct)(char *);
- if(MainAndSubCommandParsing(inputCmd, subMain, subSub) == 2)
- {
- for(actIndex = 0; actIndex < maxLen; actIndex++)
- {
- if(strcmp((char *)&strWriteItem[actIndex][0], subMain) == 0)
- {
- find = true;
- break;
- }
- }
- if(find)
- {
- printf("\r\n");
- WriteFlashAct = writeFlashList[actIndex];
- WriteFlashAct(subSub);
- printf("\r\n");
- return;
- }
- }
- printf("\r\n");
- printf("Input cmd fail ------ model [set] [cmd] [value]\r\n");
- printf(" [cmd]");
- for(actIndex = 0; actIndex < maxLen; actIndex++)
- {
- printf("%s%s", actIndex == 0 ? " " : " | ", &strWriteItem[actIndex][0]);
- }
- printf("\r\n\r\n");
- }
- void FlashCleanCmd(char *inputCmd, unsigned int opt)
- {
- char subMain[MAX_SUB_CMD_LENGTH];
- char subSub[MAX_SUB_CMD_LENGTH];
- memset(subMain, 0x00, sizeof(subMain));
- memset(subSub, 0x00, sizeof(subSub));
- bool find = false;
- int actIndex = 0;
- int maxLen = 7;
- char strCleanItem[32][32] = {
- "sysid", "qrcode", "backend", "boxid", "vendor", "receipt", "maintain"};
- bool (*cleanFlashList[32])() = {
- &CleanSystemID, &CleanQRCodeContent, &CleanOcppServerURL, &CleanChargeBoxId,
- &CleanChargePointVendor, &CleanOcppReceiptrURL, &CleanMaintainServerURL};
- bool (*CleanFlashAct)();
- if(MainAndSubCommandParsing(inputCmd, subMain, subSub) == 1)
- {
- for(actIndex = 0; actIndex < maxLen; actIndex++)
- {
- if(strcmp((char *)&strCleanItem[actIndex][0], subMain) == 0)
- {
- find = true;
- break;
- }
- }
- if(find)
- {
- printf("\r\n");
- CleanFlashAct = cleanFlashList[actIndex];
- CleanFlashAct();
- printf("\r\n");
- return;
- }
- }
- printf("\r\n");
- printf("Input cmd fail ------ model [clean] [cmd]\r\n");
- printf(" [cmd]");
- for(actIndex = 0; actIndex < maxLen; actIndex++)
- {
- printf("%s%s", actIndex == 0 ? " " : " | ", &strCleanItem[actIndex][0]);
- }
- printf("\r\n\r\n");
- }
- void FlashWriteCmd(char *inputCmd, unsigned int opt)
- {
- if(strcmp(inputCmd, "now") == EQUAL)
- {
- printf("\r\n");
- printf("Write Flash Immediately\r\n\r\n");
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashEnable = true;
- ShmChargerInfo->Control.SysCtrl.bits.WriteFlashImmediately = true;
- }
- else
- {
- printf("\r\n");
- printf("Write Flash Command Not Available\r\n\r\n");
- }
- }
- void FlashCmd(char *inputCmd, unsigned int opt)
- {
- char subMain[MAX_SUB_CMD_LENGTH];
- char subSub[MAX_SUB_CMD_LENGTH];
- memset(subMain, 0x00, sizeof(subMain));
- memset(subSub, 0x00, sizeof(subSub));
- if(MainAndSubCommandParsing(inputCmd, subMain, subSub) == 2)
- {
- if(strcmp(subMain, "set") == EQUAL)
- {
- FlashSetCmd(subSub, opt);
- return;
- }
- if(strcmp(subMain, "write") == EQUAL)
- {
- FlashWriteCmd(subSub, opt);
- return;
- }
- if(strcmp(subMain, "clean") == EQUAL)
- {
- FlashCleanCmd(subSub, opt);
- return;
- }
- }
- printf("\r\n");
- printf("Input cmd fail ------ flash [set | write | clean] [cmd] [...]\r\n\r\n");
- }
- void EnableAbnormalRelay(void)
- {
- ShmChargerInfo->Control.RelayCtrl.bits.AbnormalRelay = true;
- printf("\r\n");
- printf("Enable Abnormal Relay Cmd\r\n\r\n");
- }
- void DisableAbnormalRelay(void)
- {
- ShmChargerInfo->Control.RelayCtrl.bits.AbnormalRelay = NO;
- printf("\r\n");
- printf("Disable Abnormal Relay Cmd\r\n\r\n");
- }
- void RelayWriteOutputCmd(char *inputCmd)
- {
- char subMain[MAX_SUB_CMD_LENGTH];
- char subSub[MAX_SUB_CMD_LENGTH];
- memset(subMain, 0x00, sizeof(subMain));
- memset(subSub, 0x00, sizeof(subSub));
- if(MainAndSubCommandParsing(inputCmd, subMain, subSub) == 2)
- {
- int value = 0;
- value = atoi(&subMain[0]);
- if(value > 0 && value <= MAX_GUN_QUANTITY && (strcmp(subSub, "on") == 0 || strcmp(subSub, "off") == 0))
- {
- int OnOff = 0;
- if(!ShmChargerInfo->Control.RelayCtrl.bits.AbnormalRelay)
- {
- EnableAbnormalRelay();
- }
- OnOff = strcmp(subSub, "on") == 0 ? YES : NO;
- ShmChargerInfo->PsuGrouping.OutputRelayConfig[value - 1].bits.Output_N = OnOff;
- ShmChargerInfo->PsuGrouping.OutputRelayConfig[value - 1].bits.Output_P = OnOff;
- printf("\r\n");
- printf("Write Gun %d OutputRelay %s\r\n\r\n", value, subSub);
- return;
- }
- }
- printf("\r\n");
- printf("Input cmd fail ------ relay [write] [output] [value 1-4] [on | off]\r\n\r\n");
- }
- void RelayWriteParallelCmd(char *inputCmd)
- {
- char subMain[MAX_SUB_CMD_LENGTH];
- char subSub[MAX_SUB_CMD_LENGTH];
- memset(subMain, 0x00, sizeof(subMain));
- memset(subSub, 0x00, sizeof(subSub));
- if(MainAndSubCommandParsing(inputCmd, subMain, subSub) == 2)
- {
- int value = 0;
- value = atoi(&subMain[0]);
- if(value > 0 && value <= PARALLEL_RELAY_COUNT && (strcmp(subSub, "on") == 0 || strcmp(subSub, "off") == 0))
- {
- int OnOff = 0;
- if(!ShmChargerInfo->Control.RelayCtrl.bits.AbnormalRelay)
- {
- EnableAbnormalRelay();
- }
- OnOff = strcmp(subSub, "on") == 0 ? YES : NO;
- if(OnOff)
- {
- ShmChargerInfo->PsuGrouping.ParallelRelayConfig.CtrlValue |= 1 << (value - 1);
- }
- else
- {
- ShmChargerInfo->PsuGrouping.ParallelRelayConfig.CtrlValue &= ~(1 << (value - 1));
- }
- printf("\r\n");
- printf("Write ParallelRelay %d %s\r\n\r\n", value, subSub);
- return;
- }
- }
- printf("\r\n");
- printf("Input cmd fail ------ relay [write] [parallel] [value 1-6] [on | off]\r\n\r\n");
- }
- void AbnormalRelayCmd(char *inputCmd, unsigned int opt)
- {
- char subMain[MAX_SUB_CMD_LENGTH];
- char subSub[MAX_SUB_CMD_LENGTH];
- memset(subMain, 0x00, sizeof(subMain));
- memset(subSub, 0x00, sizeof(subSub));
- if(MainAndSubCommandParsing(inputCmd, subMain, subSub) == 1)
- {
- if(strcmp(subMain, "enable") == 0)
- {
- EnableAbnormalRelay();
- return;
- }
- if(strcmp(subMain, "disable") == 0)
- {
- DisableAbnormalRelay();
- return;
- }
- }
- printf("\r\n");
- printf("Input cmd fail ------ relay [abnormal] [enable | disable]\r\n\r\n");
- }
- void RelayWriteCmd(char *inputCmd, unsigned int opt)
- {
- char subMain[MAX_SUB_CMD_LENGTH];
- char subSub[MAX_SUB_CMD_LENGTH];
- memset(subMain, 0x00, sizeof(subMain));
- memset(subSub, 0x00, sizeof(subSub));
- if(MainAndSubCommandParsing(inputCmd, subMain, subSub) == 2)
- {
- if(strcmp(subMain, "output") == 0)
- {
- RelayWriteOutputCmd(subSub);
- return;
- }
- if(strcmp(subMain, "parallel") == 0)
- {
- RelayWriteParallelCmd(subSub);
- return;
- }
- }
- printf("\r\n");
- printf("Input cmd fail ------ relay [write] [output | parallel] [value] [on | off]\r\n\r\n");
- }
- void RelayReadCmd(char *inputCmd, unsigned int opt)
- {
- }
- void RelayStatusCmd(char *inputCmd, unsigned int opt)
- {
- }
- void OutputRelayAutoTest(void)
- {
- int MaxGunCount = 0;
- struct timespec _Loop_time;
- int time = 0;
- MaxGunCount = ShmChargerInfo->Control.MaxConnector;
- for(int i = 0; i < MaxGunCount; i++)
- {
- ShmChargerInfo->PsuGrouping.OutputRelayConfig[i].bits.Output_N = YES;
- GetClockTime(&_Loop_time);
- while(1)
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(ShmChargerInfo->PsuGrouping.OutputRelayConfig[i].bits.Output_N == ShmChargerInfo->PsuGrouping.OutputRelayConfirmed[i].bits.Output_N)
- {
- printf("Gun %d Output Relay N Driving Check OK\r\n", i + 1);
- break;
- }
- if(time >= 3000)
- {
- printf("Gun %d Output Relay N Driving Check Fault\r\n", i + 1);
- break;
- }
- usleep(10000);
- }
- ShmChargerInfo->PsuGrouping.OutputRelayConfig[i].bits.Output_P = YES;
- GetClockTime(&_Loop_time);
- while(1)
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(ShmChargerInfo->PsuGrouping.OutputRelayConfig[i].bits.Output_P == ShmChargerInfo->PsuGrouping.OutputRelayConfirmed[i].bits.Output_P)
- {
- printf("Gun %d Output Relay P Driving Check OK\r\n", i + 1);
- break;
- }
- if(time >= 3000)
- {
- printf("Gun %d Output Relay P Driving Check Fault\r\n", i + 1);
- break;
- }
- usleep(10000);
- }
- ShmChargerInfo->PsuGrouping.OutputRelayConfig[i].bits.Output_N = NO;
- GetClockTime(&_Loop_time);
- while(1)
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(ShmChargerInfo->PsuGrouping.OutputRelayConfig[i].bits.Output_N == ShmChargerInfo->PsuGrouping.OutputRelayConfirmed[i].bits.Output_N)
- {
- printf("Gun %d Output Relay N Welding Check OK\r\n", i + 1);
- break;
- }
- if(time >= 3000)
- {
- printf("Gun %d Output Relay N Welding Check Fault\r\n", i + 1);
- break;
- }
- usleep(10000);
- }
- ShmChargerInfo->PsuGrouping.OutputRelayConfig[i].bits.Output_P = NO;
- GetClockTime(&_Loop_time);
- while(1)
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(ShmChargerInfo->PsuGrouping.OutputRelayConfig[i].bits.Output_P == ShmChargerInfo->PsuGrouping.OutputRelayConfirmed[i].bits.Output_P)
- {
- printf("Gun %d Output Relay P Welding Check OK\r\n", i + 1);
- break;
- }
- if(time >= 3000)
- {
- printf("Gun %d Output Relay P Welding Check Fault\r\n", i + 1);
- break;
- }
- usleep(10000);
- }
- }
- }
- void ParallelRelayAutoTest(void)
- {
- int ParallelRelayCount = 0;
- struct timespec _Loop_time;
- int time = 0;
- if(ShmChargerInfo->Control.MaxConnector == GENERAL_GUN_QUANTITY)
- {
- ParallelRelayCount = ShmChargerInfo->Control.SysCtrl.bits.Enable6ParallelRelay == 1 ? PARALLEL_RELAY_COUNT : 3;
- }
- else
- {
- ParallelRelayCount = 1;
- }
- for(int i = 0; i < ParallelRelayCount; i++)
- {
- ShmChargerInfo->PsuGrouping.ParallelRelayConfig.CtrlValue |= 1 << i;
- GetClockTime(&_Loop_time);
- while(1)
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(ShmChargerInfo->PsuGrouping.ParallelRelayConfig.CtrlValue == ShmChargerInfo->PsuGrouping.ParallelRelayConfirmed.CtrlValue)
- {
- printf("Location %d Parallel Relay Driving Check OK\r\n", i + 1);
- break;
- }
- if(time >= 3000)
- {
- printf("Location %d Parallel Relay Driving Check Fault\r\n", i + 1);
- break;
- }
- usleep(10000);
- }
- ShmChargerInfo->PsuGrouping.ParallelRelayConfig.CtrlValue &= ~(1 << i);
- GetClockTime(&_Loop_time);
- while(1)
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(ShmChargerInfo->PsuGrouping.ParallelRelayConfig.CtrlValue == ShmChargerInfo->PsuGrouping.ParallelRelayConfirmed.CtrlValue)
- {
- printf("Location %d Parallel Relay Welding Check OK\r\n", i + 1);
- break;
- }
- if(time >= 3000)
- {
- printf("Location %d Parallel Relay Welding Check Fault\r\n", i + 1);
- break;
- }
- usleep(10000);
- }
- }
- }
- void RelayAutoTest(char *inputCmd)
- {
- if(strcmp(inputCmd, "now") != EQUAL)
- {
- printf("\r\n");
- printf("Input cmd fail ------ relay [autotest] [now]\r\n\r\n");
- return;
- }
- if(!ShmChargerInfo->Control.RelayCtrl.bits.AbnormalRelay)
- {
- EnableAbnormalRelay();
- }
- OutputRelayAutoTest();
- ParallelRelayAutoTest();
- printf("Relay Auto Test Completed\r\n");
- DisableAbnormalRelay();
- }
- void RelayCmd(char *inputCmd, unsigned int opt)
- {
- char subMain[MAX_SUB_CMD_LENGTH];
- char subSub[MAX_SUB_CMD_LENGTH];
- memset(subMain, 0x00, sizeof(subMain));
- memset(subSub, 0x00, sizeof(subSub));
- if(MainAndSubCommandParsing(inputCmd, subMain, subSub) >= 2)
- {
- if(strcmp(subMain, "abnormal") == EQUAL)
- {
- AbnormalRelayCmd(subSub, opt);
- return;
- }
- if(strcmp(subMain, "write") == EQUAL)
- {
- RelayWriteCmd(subSub, opt);
- return;
- }
- if(strcmp(subMain, "read") == EQUAL)
- {
- RelayReadCmd(subSub, opt);
- return;
- }
- if(strcmp(subMain, "status") == EQUAL)
- {
- RelayStatusCmd(subSub, opt);
- return;
- }
- if(strcmp(subMain, "autotest") == EQUAL)
- {
- RelayAutoTest(subSub);
- return;
- }
- }
- printf("\r\n");
- printf("Input cmd fail ------ relay [abnormal | write | read | autotest] [...]\r\n\r\n");
- }
- // Sys CurrentRate: [XX.XX]
- // TimeOfDayPrice: [00-01: XX.XX] [01-02: XX.XX] [02-03: XX.XX] [03-04: XX.XX] [04-05: XX.XX] [05-06: XX.XX]
- // : [06-07: XX.XX] [07-08: XX.XX] [08-09: XX.XX] [09-10: XX.XX] [10-11: XX.XX] [11-12: XX.XX]
- // : [12-13: XX.XX] [13-14: XX.XX] [14-15: XX.XX] [15-16: XX.XX] [16-17: XX.XX] [17-18: XX.XX]
- // : [18-19: XX.XX] [19-20: XX.XX] [20-21: XX.XX] [21-22: XX.XX] [22-23: XX.XX] [23-24: XX.XX]
- int ShowSysPriceInfo(void)
- {
- int showLine = 1;
- char priceString[1024];
- //************************************************************************************************
- printf(" Sys CurrentRate: [%5.2f]\r\n", ShmChargerInfo->PriceAndReceiptInfo.CurrentRate);
- if(ShmChargerInfo->Control.CustomerCode == _CUSTOMER_CODE_TCC)
- {
- //************************************************************************************************
- memset(priceString, 0x00, sizeof(priceString));
- for(int i = 0; i < 6; i++)
- {
- char strTemp[64];
- sprintf(strTemp, " [%02d-%02d: %5.2f]", i, i + 1, ShmChargerInfo->PriceAndReceiptInfo.TimeOfDayPricing[i]);
- strcat(priceString, strTemp);
- }
- printf(" TimeOfDayPrice:%s\r\n", priceString);
- //************************************************************************************************
- memset(priceString, 0x00, sizeof(priceString));
- for(int i = 6; i < 12; i++)
- {
- char strTemp[64];
- sprintf(strTemp, " [%02d-%02d: %5.2f]", i, i + 1, ShmChargerInfo->PriceAndReceiptInfo.TimeOfDayPricing[i]);
- strcat(priceString, strTemp);
- }
- printf(" :%s\r\n", priceString);
- //************************************************************************************************
- memset(priceString, 0x00, sizeof(priceString));
- for(int i = 12; i < 18; i++)
- {
- char strTemp[64];
- sprintf(strTemp, " [%02d-%02d: %5.2f]", i, i + 1, ShmChargerInfo->PriceAndReceiptInfo.TimeOfDayPricing[i]);
- strcat(priceString, strTemp);
- }
- printf(" :%s\r\n", priceString);
- //************************************************************************************************
- memset(priceString, 0x00, sizeof(priceString));
- for(int i = 18; i < 24; i++)
- {
- char strTemp[64];
- sprintf(strTemp, " [%02d-%02d: %5.2f]", i, i + 1, ShmChargerInfo->PriceAndReceiptInfo.TimeOfDayPricing[i]);
- strcat(priceString, strTemp);
- }
- printf(" :%s\r\n", priceString);
- showLine += 4;
- }
- return showLine;
- }
- // Gun X UserPrice: [%s]
- // Receipt: [%s]
- int ShowGunPriceInfo(int gun)
- {
- int showLine = 2;
- char priceString[1024];
- //************************************************************************************************
- memset(priceString, 0x00, sizeof(priceString));
- if(strlen(&ShmChargerInfo->PriceAndReceiptInfo.UserPriceString[gun][0]) > 0)
- {
- strcpy(priceString, &ShmChargerInfo->PriceAndReceiptInfo.UserPriceString[gun][0]);
- }
- else
- {
- strcpy(priceString, "NULL");
- }
- printf(" Gun %d UserPrice: [%s]\r\n", gun + 1, priceString);
- //************************************************************************************************
- memset(priceString, 0x00, sizeof(priceString));
- if(strlen(&ShmChargerInfo->PriceAndReceiptInfo.ReceiptUrl[gun][0]) > 0)
- {
- strcpy(priceString, &ShmChargerInfo->PriceAndReceiptInfo.ReceiptUrl[gun][0]);
- }
- else
- {
- strcpy(priceString, "NULL");
- }
- printf(" Receipt: [%s]\r\n", priceString);
- return showLine;
- }
- void ShowPrice(char *inputCmd, unsigned int opt)
- {
- int totalLine = 0;
- bool keepRun = false;
- bool reflash = false;
- int time = 0;
- struct timespec _Loop_time;
- if((opt & OPTION_REFLASH) || (opt & OPTION_LOOP) > 0)
- {
- keepRun = true;
- }
- do
- {
- time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
- if(time >= 1000)
- {
- if(reflash)
- {
- ConsoleReflash(1, totalLine);
- }
- totalLine = 0;
- printf("\r\n");
- totalLine += ShowSysPriceInfo() + 1;
- printf("\r\n");
- totalLine += 1;
- for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
- {
- totalLine += ShowGunPriceInfo(i);
- }
- GetClockTime(&_Loop_time);
- if((opt & OPTION_REFLASH) > 0)
- {
- reflash = true;
- }
- }
- if(keepRun)
- {
- keepRun = IsLoopStopCmd() ? false : true;
- usleep(10000);
- }
- }while(keepRun);
- printf("\r\n");
- }
- int main(void)
- {
- char newString[32][MAX_SUB_CMD_LENGTH];
- char inputString[MAX_SUB_CMD_LENGTH], normalCmd[MAX_SUB_CMD_LENGTH];
- char mainCmd[MAX_SUB_CMD_LENGTH], subCmd[MAX_SUB_CMD_LENGTH], multiCmd[MAX_SUB_CMD_LENGTH];
- int cmdCnt = 0, parseCnt = 0;
- unsigned int option = 0;
- if(InitShareMemory() == FAIL)
- {
- printf ("InitShareMemory = FAIL \n");
- if(ShmStatusCodeData != NULL)
- {
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
- }
- sleep(5);
- return 0;
- }
- for(int i = 0; i < CONNECTOR_QUANTITY; i++)
- {
- if (!FindChargingInfoData(i, &_chargingData[0]))
- {
- return 0;
- }
- }
- // clean command
- memset(mainCmd, 0x00, sizeof(mainCmd));
- memset(subCmd, 0x00, sizeof(subCmd));
- for(int i = 0; i < 32; i++)
- {
- memset(&newString[i], 0x00, 32);
- }
- for(;;)
- {
- memset(inputString, 0x00, sizeof(inputString));
- memset(normalCmd, 0x00, sizeof(normalCmd));
- get_char(inputString);
- cmdCnt = InputStringNormalize(inputString, normalCmd, &option);
- if(cmdCnt > 0)
- {
- // clean command
- memset(mainCmd, 0x00, sizeof(mainCmd));
- memset(subCmd, 0x00, sizeof(subCmd));
- for(int i = 0; i < 32; i++)
- {
- memset(&newString[i], 0x00, MAX_SUB_CMD_LENGTH);
- }
- //printf("CmdCnt: %d\r\n", cmdCnt);
- //printf("Input: %s", inputString);
- //printf("Normalize: %s\r\n", normalCmd);
- //printf("option: %08X\r\n", option);
- MainAndSubCommandParsing(normalCmd, mainCmd, subCmd);
- //printf("MainCmd: %s\r\n", mainCmd);
- //printf("SubCmd: %s\r\n", subCmd);
- parseCnt = 0;
- strcpy(multiCmd, normalCmd);
- do
- {
- MainAndSubCommandParsing(multiCmd, &newString[parseCnt][0], &newString[parseCnt + 1][0]);
- strcpy(multiCmd, &newString[parseCnt + 1][0]);
- //printf("MultiCmd Parse %d\r\n", parseCnt + 1);
- //printf("MainCmd: %s\r\n", &newString[parseCnt][0]);
- //printf("SubCmd: %s\r\n", &newString[parseCnt + 1][0]);
- parseCnt++;
- }while(parseCnt < cmdCnt - 1);
- //printf("\r\n");
- //for(int i = 0; i < cmdCnt; i++)
- //{
- // printf("MultiCmd %d: [%s]\r\n", i + 1, &newString[i][0]);
- //}
- }
- else
- {
- usleep(100000);
- continue;
- }
- if(strcmp(newString[0], "state") == 0)
- {
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- continue;
- // 槍狀態
- RunStatusProc(newString[1], newString[2]);
- }
- else if(strcmp(newString[0], "card") == 0)
- {
- // 刷卡狀態
- RunCardProc(newString[1], newString[2]);
- }
- else if(strcmp(newString[0], "gun") == 0)
- {
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- continue;
- // 插槍狀態
- RunGunPlugitProc(newString[1], newString[2]);
- }
- else if(strcmp(newString[0], "lock") == 0)
- {
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- continue;
- // 插槍狀態
- GetGunLockStatusProc(newString[1], newString[2]);
- }
- else if(strcmp(newString[0], "sysid") == 0)
- {
- // 測試 sys id
- SetSystemIDProc();
- }
- else if(strcmp(newString[0], "self") == 0)
- {
- // CSU 自我檢測狀態
- RunSelfProc(newString[1]);
- }
- else if(strcmp(newString[0], "ver") == 0)
- {
- //if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- // continue;
- // 取 FW 版號
- //GetFwVerProc(newString[1]);
- ShowFwVer();
- }
- else if (strcmp(newString[0], "update") == 0)
- {
- // 更新
- FwUpdateFlagProc(newString[1]);
- }
- else if (strcmp(newString[0], "ac") == 0)
- {
- // AC contactor 狀態
- CheckAcStatus(newString[1]);
- }
- else if (strcmp(newString[0], "cable") == 0)
- {
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- continue;
- // cable check pass
- SetCableChkStatus(newString[1], newString[2]);
- }
- else if (strcmp(newString[0], "pow") == 0)
- {
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- continue;
- // cable check pass
- SetPowerValue(newString[1], newString[2]);
- }
- else if(strcmp(mainCmd, "model") == 0)
- {
- ModelNameCmd(subCmd, option);
- }
- else if(strcmp(mainCmd, "sn") == 0)
- {
- SerialNumberCmd(subCmd, option);
- }
- else if(strcmp(newString[0], "fan") == 0)
- {
- // 設定風扇速度
- SetFanSpeed(newString[1]);
- }
- else if(strcmp(newString[0], "speed") == 0)
- {
- // 取得風扇速度
- GetFanSpeed();
- }
- else if(strcmp(newString[0], "debug") == 0)
- {
- // 設定 debug mode
- SetDebugMode(newString[1]);
- }
- else if (strcmp(newString[0], "gfd") == 0)
- {
- // 設定盲沖使用 GFD 功能
- SetGFDMode(newString[1]);
- }
- else if(strcmp(mainCmd, "temp") == 0)
- {
- // 取得溫度
- GetTemperature(subCmd, option);
- }
- else if(strcmp(mainCmd, "acin") == 0)
- {
- // 取得三向輸入電壓
- GetInputVol(subCmd, option);
- }
- else if(strcmp(newString[0], "psu") == 0)
- {
- //如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- {
- printf ("PSU : Param fail..Please retry again......\n");
- continue;
- }
- // 取得 PSU 資訊
- GetPsuInformation(newString[1], newString[2], newString[3]);
- }
- else if (strcmp(newString[0], "cap") == 0)
- {
- GetConnectorCapInfo(newString[1]);
- }
- else if(strcmp(newString[0], "error") == 0)
- {
- CreateOneError(newString[1]);
- }
- else if (strcmp(newString[0], "auth") == 0)
- {
- GetAuthorizeFlag(newString[1]);
- }
- else if (strcmp(newString[0], "id") == 0)
- {
- GetOrClearId(newString[1]);
- }
- else if(strcmp(newString[0], "wiring") == 0)
- {
- if(strcmp(newString[1], "-1") != 0 && strcmp(newString[1], "") != 0 &&
- strcmp(newString[2], "-1") != 0 && strcmp(newString[2], "") != 0)
- {
- SetWiringInfo(newString[1], newString[2]);
- }
- ShowWiringInfo();
- }
- else if(strcmp(newString[0], "cwiring") == 0)
- {
- CleanWiringInfo();
- }
- else if(strcmp(newString[0], "reset") == 0)
- {
- SetSystemSoftRest();
- }
- else if(strcmp(newString[0], "reboot") == 0)
- {
- SetSystemHardReboot();
- }
- else if(strcmp(newString[0], "sgroup") == 0)
- {
- if(strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- {
- ShowGroupingInfo();
- continue;
- }
- RunSimplePsuGrouping(newString[1], newString[2]);
- }
- else if(strcmp(mainCmd, "cabinet") == 0)
- {
- ShowCabinetInfo(subCmd, option);
- }
- else if(strcmp(newString[0], "tctl") == 0)
- {
- if(strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
- strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0)
- {
- printf("Test Control Value = %08X\n",ShmChargerInfo->Control.TestCtrl.CtrlValue);
- printf ("Input cmd fail ------ tctl [tcmd] [value]\n\n");
- continue;
- }
- SetTestControl(newString[1], newString[2]);
- }
- else if(strcmp(newString[0], "group") == 0)
- {
- if(strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- {
- ShowGroupingInfo();
- continue;
- }
- }
- else if(strcmp(newString[0], "gdmd") == 0)
- {
- ShowGroupingDemand();
- }
- else if(strcmp(mainCmd, "gunchg") == 0)
- {
- SetGunStartCharging(subCmd, option, NO);
- }
- else if(strcmp(mainCmd, "webchg") == 0)
- {
- SetGunStartCharging(subCmd, option, YES);
- }
- else if(strcmp(mainCmd, "gunstp") == 0)
- {
- SetGunStopCharging(subCmd, option);
- }
- else if(strcmp(newString[0], "gunext") == 0)
- {
- if(strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- {
- printf ("Input cmd fail ------ gunext [gun 1-4]\n\n");
- continue;
- }
- SetGunExtend(newString[1]);
- }
- else if(strcmp(newString[0], "output") == 0)
- {
- ShowGunOutput();
- }
- else if(strcmp(newString[0], "gio") == 0)
- {
- if(strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
- strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0)
- {
- printf ("Input cmd fail ------ gio [io] [on-off 0-1]\n\n");
- continue;
- }
- SetGpio(newString[1], newString[2]);
- }
- else if(strcmp(newString[0], "status") == 0)
- {
- ShowStatus();
- }
- else if(strcmp(newString[0], "whiteR") == 0)
- {
- ShowWhiteCardList();
- }
- else if(strcmp(newString[0], "whiteW") == 0)
- {
- if(strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
- strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0)
- {
- printf ("Input cmd fail ------ whiteW [index 1-10] [card id]\n\n");
- continue;
- }
- WriteWhiteCard(newString[1], newString[2]);
- }
- else if(strcmp(newString[0], "whiteE") == 0)
- {
- if(strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
- {
- printf ("Input cmd fail ------ whiteE [index 1-10]\n\n");
- continue;
- }
- EraseWhiteCard(newString[1]);
- }
- else if(strcmp(mainCmd, "limit") == 0)
- {
- ShowChargerLimit(subCmd, option);
- }
- else if(strcmp(mainCmd, "pcmd") == 0)
- {
- SetPsuCommand(subCmd, option);
- }
- else if(strcmp(newString[0], "gcmd") == 0)
- {
- if(strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
- strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0 ||
- strcmp(newString[3], "-1") == 0 || strcmp(newString[3], "") == 0)
- {
- printf ("Input cmd fail ------ gcmd [cmd] [gun] [value]\n\n");
- continue;
- }
- SetGunCommand(newString[1], newString[2], newString[3]);
- }
- else if(strcmp(mainCmd, "web") == 0)
- {
- ShowWebInfo(subCmd, option);
- }
- else if(strcmp(mainCmd, "info") == 0)
- {
- ShowInfo(subCmd, option);
- }
- else if(strcmp(mainCmd, "rtcsync") == 0)
- {
- RtcSyncCmd(subCmd, option);
- }
- else if(strcmp(mainCmd, "pmodel") == 0)
- {
- ParsingModelNameCmd(subCmd, option);
- }
- else if(strcmp(mainCmd, "pt") == 0)
- {
- CustomerPriceTest(subCmd, option);
- }
- else if(strcmp(mainCmd, "evmsg") == 0)
- {
- EvCommMsgDebug(subCmd, option);
- }
- else if(strcmp(mainCmd, "evid") == 0)
- {
- EvCommIdDebug(subCmd, option);
- }
- else if(strcmp(mainCmd, "flash") == 0)
- {
- FlashCmd(subCmd, option);
- }
- else if(strcmp(mainCmd, "relay") == 0)
- {
- RelayCmd(subCmd, option);
- }
- else if(strcmp(mainCmd, "price") == 0)
- {
- ShowPrice(subCmd, option);
- }
- else
- {
- printf ("%s\n", msg);
- }
- usleep(100000);
- }
- return 0;
- }
|