123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616 |
- using FControlFUSIONCF;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Xml;
- using System.Xml.Serialization;
- using Wayne.FDCPOSLibrary;
- using Wayne.FDCPOSLibrary.Configuration;
- using Wayne.ForecourtControl.OptBridge;
- using Wayne.Lib;
- using Wayne.Lib.Log;
- namespace Wayne.ForecourtControl.Fusion
- {
- public class Heartbeat : DisposableBase
- {
- private readonly Timer heartbeatTimer;
- private readonly Timer disconnectionTimer;
- public event EventHandler OnHeartbeatTimeout;
- public event EventHandler OnHeartbeatInterval;
- public long heartbeatTimeout;
- public long heartbeatInterval;
- public bool tryingConnect;
- private IFSFManager ifsfManager;
- private readonly DebugLogger debugLogger;
- public Heartbeat(IFSFManager _ifsfManager, long _heartbeatInterval, long _heartbeatTimeout)
- {
- ifsfManager = _ifsfManager;
- heartbeatInterval = _heartbeatInterval;
- heartbeatTimeout = _heartbeatTimeout;
- debugLogger = ifsfManager.DebugLogger;
- disconnectionTimer = new Timer(HeartbeatTimeout, null, Timeout.Infinite, Timeout.Infinite);
- heartbeatTimer = new Timer(HeartbeatInterval, null, Timeout.Infinite, Timeout.Infinite);
- }
- private void HeartbeatTimeout(Object state)
- {
- if (IsDisposed)
- {
- return;
- }
- if (debugLogger.IsActive())
- debugLogger.Add("Heartbeat Timeout");
- if (OnHeartbeatTimeout != null)
- OnHeartbeatTimeout.Invoke(this, null);
- if (heartbeatTimeout > 0)
- {
- disconnectionTimer.Change(heartbeatTimeout, Timeout.Infinite);
- }
- }
- private void HeartbeatInterval(Object state)
- {
- if (IsDisposed)
- {
- return;
- }
- if (OnHeartbeatInterval != null)
- OnHeartbeatInterval.Invoke(this, null);
- }
- public void ResetDisconnectionTimeout()
- {
- if (IsDisposed)
- {
- return;
- }
-
- string sValue = IniFile.IniReadValue(ConfigurationParams.inifile, "FUSION-Connection", "HeartbeatTimeout");
- try
- {
- if (sValue.Length > 0)
- heartbeatTimeout = Convert.ToInt32(sValue);
- }
- catch (Exception ex)
- {
- if (debugLogger.IsActive())
- debugLogger.Add(string.Format("Exception reading heartbeatTimeout: {0}", ex));
- }
- if (heartbeatTimeout > 0)
- {
- disconnectionTimer.Change(heartbeatTimeout, Timeout.Infinite);
- }
- }
- public void Restart()
- {
- if (IsDisposed)
- {
- return;
- }
-
- if (heartbeatInterval > 0)
- {
- heartbeatTimer.Change(heartbeatInterval, Timeout.Infinite);
- }
- }
- public void Stop()
- {
- if (IsDisposed)
- {
- return;
- }
- heartbeatTimer.Change(Timeout.Infinite, Timeout.Infinite);
- }
- public void NotifyDisconnection()
- {
- if (IsDisposed)
- {
- return;
- }
- heartbeatTimer.Change(Timeout.Infinite, Timeout.Infinite);
- tryingConnect = true;
- disconnectionTimer.Change(Timeout.Infinite, Timeout.Infinite);
- Restart();
- }
- public void SetReconnected()
- {
- if (IsDisposed)
- {
- return;
- }
- tryingConnect = false;
- }
- protected override void DoDispose()
- {
- heartbeatTimer.Dispose();
- disconnectionTimer.Dispose();
- }
- }
- #region Event Args
- public class DeviceStateChangedEventArgs : EventArgs
- {
- public string deviceType;
- public int deviceId;
- public LogicalDeviceState state;
- public LogicalDeviceState substate;
- public string lockingAS;
- public int nozzleUp;
- public DeviceStateChangedEventArgs(string _deviceType, int _deviceId, LogicalDeviceState _state, LogicalDeviceState _substate, string _lockingAS, int _nozzleUp)
- {
- deviceType = _deviceType;
- deviceId = _deviceId;
- state = _state;
- substate = _substate;
- lockingAS = _lockingAS;
- nozzleUp = _nozzleUp;
- }
- }
- public class VIRStateChangedEventArgs : EventArgs
- {
- public int deviceId;
- public string virId;
- public DeviceConnectionState state;
- public VIRStateChangedEventArgs(int _deviceId, string _virId, DeviceConnectionState _state)
- {
- deviceId = _deviceId;
- virId = _virId;
- state = _state;
- }
- }
- public class FuelModeChangedEventArgs : EventArgs
- {
- public string deviceType;
- public int deviceId;
- public int mode;
- public FuelModeChangedEventArgs(string _deviceType, int _deviceId, int _mode)
- {
- deviceType = _deviceType;
- deviceId = _deviceId;
- mode = _mode;
- }
- }
- public class OperationModeChangedEventArgs : EventArgs
- {
- public string deviceType;
- public int deviceId;
- public ushort mode;
- public OperationModeChangedEventArgs(string _deviceType, int _deviceId, ushort _mode)
- {
- deviceType = _deviceType;
- deviceId = _deviceId;
- mode = _mode;
- }
- }
- public class CurrentFuellingStatusEventArgs : EventArgs
- {
- public string deviceType;
- public int deviceId;
- public int nozzleId;
- public decimal volume;
- public decimal amount;
- public decimal price;
- public string authAS;
-
-
-
- public int FuelPeriodSequenceNo { get; set; }
-
-
-
- public int ReleaseId { get; set; }
-
-
-
- public int TransactionId { get; set; }
-
-
-
- public int ReservingDeviceId { get; set; }
- public CurrentFuellingStatusEventArgs(string _deviceType, int _deviceId, int _nozzleId, decimal _volume, decimal _amount, decimal _price, string _authAS)
- {
- deviceType = _deviceType;
- deviceId = _deviceId;
- nozzleId = _nozzleId;
- volume = _volume;
- amount = _amount;
- price = _price;
- authAS = _authAS;
- }
- }
- public class FuelPointTotalsEventArgs : EventArgs
- {
- public int requestId;
- public bool overallResult;
- public string deviceType;
- public int deviceId;
- public int nozzleId;
- public decimal volume;
- public decimal amount;
- public decimal price;
- public string originalTransactionData;
- public FuelPointTotalsEventArgs(int _requestId, bool _overallResult, string _deviceType, int _deviceId, int _nozzleId, decimal _volume, decimal _amount, decimal _price, string _originalTransactionData)
- {
- requestId = _requestId;
- overallResult = _overallResult;
- deviceType = _deviceType;
- deviceId = _deviceId;
- nozzleId = _nozzleId;
- volume = _volume;
- amount = _amount;
- price = _price;
- originalTransactionData = _originalTransactionData;
- }
- }
- public class FuelSaleTrxEventArgs : EventArgs
- {
- public int transactionId;
- public int fuellingSeqNo;
- public Wayne.FDCPOSLibrary.FuellingState transactionStatus;
- public int completionReason;
- public string deviceType;
- public int deviceId;
- public int nozzleId;
- public decimal volume;
- public decimal amount;
- public decimal price;
- public int fuelMode;
- public DateTime trxStartDateTime;
- public DateTime trxEndDateTime;
- public string lockingAS;
- public string authAS;
- public string DSPFields;
- public string CRCMode;
- public string MIDLinesNarrow;
- public string MIDLinesWide;
- public int releaseToken;
- public byte reservingDeviceId;
- public FuellingType fuellingType;
- public string origMessageXml;
-
-
-
- public int FuelPeriodSequenceNo { get; set; }
- public FuelSaleTrxEventArgs(int _transactionId, int _fuellingSeqNo, Wayne.FDCPOSLibrary.FuellingState _transactionStatus,
- int _completionReason, string _deviceType, int _deviceId, int _nozzleId, decimal _volume, decimal _amount,
- decimal _price, int _fuelMode, DateTime _trxStartDateTime, DateTime _trxEndDateTime, string _lockingAS,
- string _authAS, string _DSPFields, string _CRCMode, string _MIDLinesNarrow,
- string _MIDLinesWide, int _releaseToken, byte _reservingDeviceId, FuellingType _fuellingType,
- string _originalMessageXml = null)
- {
- transactionId = _transactionId;
- fuellingSeqNo = _fuellingSeqNo;
- transactionStatus = _transactionStatus;
- completionReason = _completionReason;
- deviceType = _deviceType;
- deviceId = _deviceId;
- nozzleId = _nozzleId;
- volume = _volume;
- amount = _amount;
- price = _price;
- fuelMode = _fuelMode;
- trxStartDateTime = _trxStartDateTime;
- trxEndDateTime = _trxEndDateTime;
- lockingAS = _lockingAS;
- authAS = _authAS;
- DSPFields = _DSPFields;
- CRCMode = _CRCMode;
- MIDLinesNarrow = _MIDLinesNarrow;
- MIDLinesWide = _MIDLinesWide;
- releaseToken = _releaseToken;
- reservingDeviceId = _reservingDeviceId;
- fuellingType = _fuellingType;
- origMessageXml = _originalMessageXml;
- }
- }
- public class ChangeFuelPriceEventArgs : EventArgs
- {
- public int productId;
- public int mode;
- public decimal oldPrice;
- public decimal newPrice;
- public ChangeFuelPriceEventArgs(int _productId, int _mode, decimal _oldPrice, decimal _newPrice)
- {
- productId = _productId;
- mode = _mode;
- oldPrice = _oldPrice;
- newPrice = _newPrice;
- }
- }
- public class DeviceAlarmEventArgs : EventArgs
- {
- public string deviceType;
- public int deviceId;
- public int alarmId;
- public string alarmDescr;
- public DeviceAlarmEventArgs(string _deviceType, int _deviceId, int _alarmId, string _alarmDescr)
- {
- deviceType = _deviceType;
- deviceId = _deviceId;
- alarmId = _alarmId;
- alarmDescr = _alarmDescr;
- }
- }
- public class VersionInfoEventArgs : EventArgs
- {
- public string release;
- public string version;
- public string hotfix;
- public VersionInfoEventArgs(string _release, string _version, string _hotfix)
- {
- version = _version;
- release = _release;
- hotfix = _hotfix;
- }
- }
- public class TankDataEventArgs : EventArgs
- {
- int DeviceID;
- int TankNo;
- string Type;
- int ManualMode;
- decimal AverageTemp;
- decimal GrossStandardVolume;
- decimal ObservedDensity;
- decimal ProductLevel;
- decimal TotalObservedVolume;
- decimal WaterLevel;
- int TPStatus;
- public TankDataEventArgs(int _DeviceID, int _TankNo, string _Type, int _ManualMode,
- decimal _AverageTemp, decimal _GrossStandardVolume, decimal _ObservedDensity,
- decimal _ProductLevel, decimal _TotalObservedVolume, decimal _WaterLevel, int _TPStatus)
- {
- DeviceID = _DeviceID;
- TankNo = _TankNo;
- Type = _Type;
- ManualMode = _ManualMode;
- AverageTemp = _AverageTemp;
- GrossStandardVolume = _GrossStandardVolume;
- ObservedDensity = _ObservedDensity;
- ProductLevel = _ProductLevel;
- TotalObservedVolume = _TotalObservedVolume;
- WaterLevel = _WaterLevel;
- TPStatus = _TPStatus;
- }
- }
- public class OptReadEventArgs : EventArgs
- {
- public string deviceType;
- public int deviceId;
- public byte[] message;
- public OptReadEventArgs(string _deviceType, int _deviceId, byte[] _message)
- {
- deviceType = _deviceType;
- deviceId = _deviceId;
- message = _message;
- }
- }
- #endregion
- public class IFSFManager : DisposableBase
- {
- public ServiceRequest serviceRequestLogOn;
- private IFSFSockets _clientSocket;
- public IFSFSockets clientSocket
- {
- get { return _clientSocket; }
- }
- private Heartbeat _heartbeat;
- public Heartbeat heartbeat
- {
- get { return _heartbeat; }
- }
- private FUSIONManager manager;
- public bool authentificationErrorRetry;
- public event EventHandler<DeviceStateChangedEventArgs> OnDeviceStateChange;
- public event EventHandler<VIRStateChangedEventArgs> OnVirStateChange;
- public event EventHandler<FuelModeChangedEventArgs> OnFuelModeChange;
- public event EventHandler<OperationModeChangedEventArgs> OnOperationModeChange;
- public event EventHandler<CurrentFuellingStatusEventArgs> OnCurrentFuellingStatus;
- public event EventHandler<FuelPointTotalsEventArgs> OnFuelPointTotals;
- public event EventHandler<FuelSaleTrxEventArgs> OnFuelSaleTrx;
- public event EventHandler<DeviceAlarmEventArgs> OnDeviceAlarm;
- public event EventHandler<VersionInfoEventArgs> OnVersionInfo;
- public event EventHandler<ChangeFuelPriceEventArgs> OnChangeFuelPrice;
- public event EventHandler<FuelSaleTrxEventArgs> OnLockFuelSaleTrx;
- public event EventHandler<FuelSaleTrxEventArgs> OnUnlockFuelSaleTrx;
- public event EventHandler<FuelSaleTrxEventArgs> OnClearFuelSaleTrx;
- public event EventHandler<FuelSaleTrxEventArgs> OnGetAvailableFuelSaleTrx;
- public event EventHandler<FuelSaleTrxEventArgs> OnGetFuelSaleTrxDetails;
- public event EventHandler<OptReadEventArgs> OnOptRead;
- public event EventHandler<TankDataEventArgs> OnTankData;
- public event EventHandler<EventArgs> OnConfigurationChange;
- public event EventHandler<EventArgs> OnTwinMasterReady;
- private readonly Dictionary<int, int> unsolicitedFPStateChangeDictionary = new Dictionary<int, int>();
- private readonly DebugLogger debugLogger;
- public DebugLogger DebugLogger { get { return debugLogger; } }
- public IFSFManager(FUSIONManager manager, int id)
- {
- debugLogger = manager.DebugLogger;
- this._clientSocket = new IFSFSockets(id, this);
- this._clientSocket.OnResponseTimeout += new EventHandler(_clientSocket_OnResponseTimeout);
- this.manager = manager;
- this._heartbeat = new Heartbeat(this, this._clientSocket.heartbeatInterval, this._clientSocket.heartbeatTimeout);
- heartbeat.OnHeartbeatInterval += new EventHandler(heartbeat_OnHeartbeatInterval);
- heartbeat.OnHeartbeatTimeout += new EventHandler(heartbeat_OnHeartbeatTimeout);
- authentificationErrorRetry = true;
- }
- private void DebugLog(string s)
- {
- if (debugLogger.IsActive())
- debugLogger.Add(s);
- }
- public static void ArrayResize<T>(ref T[] array, int newSize)
- {
- int oldSize = (array == null) ? 0 : array.Length;
- T[] newArray = new T[newSize];
- int preserveLength = System.Math.Min(oldSize, newSize);
- for (int i = 0; i < preserveLength; i++)
- newArray[i] = array[i];
- array = newArray;
- }
- public LogicalDeviceState convertLogicalDeviceState(string state)
- {
- if (state == LogicalDeviceState.FDC_CALLING.ToString())
- return LogicalDeviceState.FDC_CALLING;
- else if (state == LogicalDeviceState.FDC_CONFIGURE.ToString())
- return LogicalDeviceState.FDC_CONFIGURE;
- else if (state == LogicalDeviceState.FDC_DISABLED.ToString())
- return LogicalDeviceState.FDC_DISABLED;
- else if (state == LogicalDeviceState.FDC_ERRORSTATE.ToString())
- return LogicalDeviceState.FDC_ERRORSTATE;
- else if (state == LogicalDeviceState.FDC_FUELLING.ToString())
- return LogicalDeviceState.FDC_FUELLING;
- else if (state == LogicalDeviceState.FDC_INVALIDSTATE.ToString())
- return LogicalDeviceState.FDC_INVALIDSTATE;
- else if (state == LogicalDeviceState.FDC_LOCKED.ToString())
- return LogicalDeviceState.FDC_LOCKED;
- else if (state == LogicalDeviceState.FDC_OFFLINE.ToString())
- return LogicalDeviceState.FDC_OFFLINE;
- else if (state == LogicalDeviceState.FDC_OUTOFORDER.ToString())
- return LogicalDeviceState.FDC_OUTOFORDER;
- else if (state == LogicalDeviceState.FDC_READY.ToString())
- return LogicalDeviceState.FDC_READY;
- else if (state == LogicalDeviceState.FDC_REQUESTED.ToString())
- return LogicalDeviceState.FDC_REQUESTED;
- else if (state == LogicalDeviceState.FDC_STARTED.ToString())
- return LogicalDeviceState.FDC_STARTED;
- else if (state == LogicalDeviceState.FDC_SUSPENDED.ToString())
- return LogicalDeviceState.FDC_SUSPENDED;
- else if (state == LogicalDeviceState.FDC_TEST.ToString())
- return LogicalDeviceState.FDC_TEST;
- else if (state == LogicalDeviceState.FDC_SUSPENDED_STARTED.ToString())
- return LogicalDeviceState.FDC_SUSPENDED_STARTED;
- else if (state == LogicalDeviceState.FDC_SUSPENDED_FUELLING.ToString())
- return LogicalDeviceState.FDC_SUSPENDED_FUELLING;
- else if (state == LogicalDeviceState.FDC_CLOSED.ToString())
- return LogicalDeviceState.FDC_CLOSED;
- else if (state == LogicalDeviceState.FDC_AUTHORISED.ToString())
- return LogicalDeviceState.FDC_AUTHORISED;
- else if (state == LogicalDeviceState.FDC_FUELLING_TERMINATED.ToString())
- return LogicalDeviceState.FDC_FUELLING_TERMINATED;
- return 0;
- }
- private Wayne.FDCPOSLibrary.FuellingState convertFuellingState(string state)
- {
- if (state == Wayne.FDCPOSLibrary.FuellingState.Locked.ToString())
- return Wayne.FDCPOSLibrary.FuellingState.Locked;
- else if (state == Wayne.FDCPOSLibrary.FuellingState.Payable.ToString())
- return Wayne.FDCPOSLibrary.FuellingState.Payable;
- else if (state == Wayne.FDCPOSLibrary.FuellingState.Paid.ToString() || state == Wayne.FDCPOSLibrary.FuellingState.Cleared.ToString())
- return Wayne.FDCPOSLibrary.FuellingState.Paid;
- return 0;
- }
- private int convertCompletionReason(string reason)
- {
-
- if (reason == Wayne.FDCPOSLibrary.CompletionReason.NormalCompletion.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.NormalCompletion;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.AuthorizationTimeout.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.AuthorizationTimeout;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.FuellingTimeout.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.FuellingTimeout;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.NoFlowTimeout.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.NoFlowTimeout;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PumpDisconnected.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PumpDisconnected;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PumpStopped.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PumpStopped;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PumpGenericError.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PumpGenericError;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PumpPulserError.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PumpPulserError;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PumpLowLevelError.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PumpLowLevelError;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PumpDisplayError.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PumpDisplayError;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PumpCalculationError.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PumpCalculationError;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PumpAntiSpillError.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PumpAntiSpillError;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PumpBlenderError.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PumpBlenderError;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PumpVaporRecoveryError.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PumpVaporRecoveryError;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.ZeroFilling.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.ZeroFilling;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.PresetOverrun.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.PresetOverrun;
- else if (reason == Wayne.FDCPOSLibrary.CompletionReason.ReadFromTotalizers.ToString())
- return (int)Wayne.FDCPOSLibrary.CompletionReason.ReadFromTotalizers;
-
- return Convert.ToInt32(reason);
- }
- public static string getClientID(string workstationID, string applicationSender)
- {
- return workstationID + "-" + applicationSender;
- }
- public void Disconnect()
- {
- clientSocket.Disconnect();
- clientSocket.mainConnectionState = DeviceConnectionState.Disconnected;
- if (heartbeat != null)
- heartbeat.NotifyDisconnection();
- }
- private void _clientSocket_OnResponseTimeout(object sender, EventArgs e)
- {
- }
- private void heartbeat_OnHeartbeatTimeout(object sender, EventArgs e)
- {
- DebugLog("Heartbeat Timeout - disconnecting");
- Disconnect();
- clientSocket.mainConnectionState = DeviceConnectionState.Disconnected;
- }
- private void heartbeat_OnHeartbeatInterval(object sender, EventArgs e)
- {
- Heartbeat();
- }
- public string ReadResponse(string myString, int msglength, ref OverallResult result)
- {
- string requestType = "";
- int requestId = 0;
- try
- {
- requestType = GetRequestType("RequestType", myString);
- requestId = GetRequestID("RequestID", myString);
- }
- catch (Exception ex)
- {
- DebugLog(string.Format("Unable to get request type or id - Exception! {0}", ex));
-
- }
- if (result != OverallResult.Success)
- {
- DebugLog(string.Format("ReadResponse ERROR result='{0}'", result));
- }
- else
- {
- if (requestType == "")
- {
- DebugLog(string.Format("ReadResponse INVALID requestType='{0}', requestId={1}", requestType, requestId));
- result = OverallResult.FormatError;
- }
- int UTFlength = System.Text.Encoding.UTF8.GetBytes(myString).Length;
- if (result == OverallResult.Success && UTFlength != msglength)
- {
- DebugLog(string.Format("ReadResponse header='{0}' != msgLength={1}, requestType='{2}', requestId={3}", msglength, UTFlength, requestType, requestId));
- result = OverallResult.FormatError;
- }
- else
- {
- try
- {
- DebugLog(string.Format("ReadResponse init: requestType='{0}', requestId={1}", requestType, requestId));
- if (requestType == "LogOn")
- {
- ServiceResponseLogOn sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseLogOn>(myString, ref result);
- LogOnResp(sr.RequestIDNumber, sr.OverallResult, sr.Value, sr.FDCdata[0].FDCTimeStamp);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "LogOff")
- {
- ServiceResponseLogOff sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseLogOff>(myString, ref result);
- LogOffResp(sr.RequestIDNumber, sr.OverallResult);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "VersionInfo")
- {
- ServiceResponseVersionInfo sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseVersionInfo>(myString, ref result);
- VersionInfoResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "StartForecourt")
- {
- ServiceResponseStartForecourt sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseStartForecourt>(myString, ref result);
- string errorCode = (sr.FDCdata[0].FDCStatus != null) ? sr.FDCdata[0].FDCStatus : sr.FDCdata[0].ErrorCode;
- StartForecourtResp(sr.RequestIDNumber, sr.OverallResult, errorCode);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "TwinOpenMaster")
- {
- ServiceResponseTwinOpenMaster sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseTwinOpenMaster>(myString, ref result);
- string errorCode = (sr.FDCdata[0].FDCStatus != null) ? sr.FDCdata[0].FDCStatus : sr.FDCdata[0].ErrorCode;
- TwinOpenMasterResp(sr.RequestIDNumber, sr.OverallResult, errorCode);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "StopForecourt")
- {
- ServiceResponseStopForecourt sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseStopForecourt>(myString, ref result);
- string errorCode = (sr.FDCdata[0].FDCStatus != null) ? sr.FDCdata[0].FDCStatus : sr.FDCdata[0].ErrorCode;
- StopForecourtResp(sr.RequestIDNumber, sr.OverallResult, errorCode);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetCurrentFuellingStatus")
- {
- ServiceResponseGetCurrentFuellingStatus sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetCurrentFuellingStatus>(myString, ref result);
- GetCurrentFuellingStatusResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetTotals")
- {
- ServiceResponseGetFuelPointTotals sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetFuelPointTotals>(myString, ref result);
- GetFuelPointTotalsResp(sr.RequestIDNumber, sr.OverallResult, sr, myString);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetDeviceState")
- {
- ServiceResponseGetDeviceState sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetDeviceState>(myString, ref result);
- GetDeviceStateResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetFPState")
- {
- ServiceResponseGetFPState sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetFPState>(myString, ref result);
- GetFPStateResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetTPState")
- {
- ServiceResponseGetTPState sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetTPState>(myString, ref result);
- GetTPStateResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetPPState")
- {
- ServiceResponseGetPPState sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetPPState>(myString, ref result);
- GetPPStateResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetVIRState")
- {
- ServiceResponseGetVIRState sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetVIRState>(myString, ref result);
- GetVIRStateResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "TerminateFuelling")
- {
- ServiceResponseTerminateFuelling sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseTerminateFuelling>(myString, ref result);
- TerminateFuellingResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "AuthoriseFuelPoint")
- {
- ServiceResponseAuthoriseFuelPoint sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseAuthoriseFuelPoint>(myString, ref result);
- AuthoriseFuelPointResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "ChangeFuelMode")
- {
- ServiceResponseChangeFuelMode sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseChangeFuelMode>(myString, ref result);
- ChangeFuelModeResp(sr.RequestIDNumber, sr.OverallResult, sr.FDCdata);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "ChangeFPFuelMode")
- {
- ServiceResponseChangeFPFuelMode sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseChangeFPFuelMode>(myString, ref result);
- ChangeFuelModeResp(sr.RequestIDNumber, sr.OverallResult, sr.FDCdata);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "ChangeFuelPrice")
- {
- ServiceResponseChangeFuelPrice sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseChangeFuelPrice>(myString, ref result);
- ChangeFuelPriceResp(sr.RequestIDNumber, sr.OverallResult, sr.FDCdata);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "LockFuelSaleTrx")
- {
- ServiceResponseLockFuelSaleTrx sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseLockFuelSaleTrx>(myString, ref result);
- LockFuelSaleTrxResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "UnlockFuelSaleTrx")
- {
- ServiceResponseUnlockFuelSaleTrx sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseUnlockFuelSaleTrx>(myString, ref result);
- UnlockFuelSaleTrxResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "ClearFuelSaleTrx")
- {
- ServiceResponseClearFuelSaleTrx sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseClearFuelSaleTrx>(myString, ref result);
- ClearFuelSaleTrxResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetAvailableFuelSaleTrxs")
- {
- ServiceResponseGetAvailableFuelSaleTrxs sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetAvailableFuelSaleTrxs>(myString, ref result);
- GetAvailableFuelSaleTrxsResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetFuelSaleTrxDetails")
- {
- string res = "";
- if (FDCGlobal.ProtocolVersion == FDCVersion.V0003)
- {
- ServiceResponseGetFuelSaleTrxDetailsV03 sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetFuelSaleTrxDetailsV03>(myString, ref result);
- GetFuelSaleTrxDetailsResp(sr.RequestIDNumber, sr.OverallResult, sr);
- res = sr.OverallResult;
- }
- else
- {
- ServiceResponseGetFuelSaleTrxDetails sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetFuelSaleTrxDetails>(myString, ref result);
- GetFuelSaleTrxDetailsResp(sr.RequestIDNumber, sr.OverallResult, sr);
- res = sr.OverallResult;
- }
- result = FDCConvert.OverallResultToInt(res);
- }
- else if (requestType == "GetProductTable")
- {
- ServiceResponseGetProductTable sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetProductTable>(myString, ref result);
- GetProductTableResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetModeTable")
- {
- ServiceResponseGetModeTable sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetModeTable>(myString, ref result);
- GetModeTableResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetFuelMode")
- {
- ServiceResponseGetFuelMode sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetFuelMode>(myString, ref result);
- GetFuelModeResp(sr.RequestIDNumber, sr.OverallResult, sr.FDCdata);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetFPFuelMode")
- {
- ServiceResponseGetFPFuelMode sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetFPFuelMode>(myString, ref result);
- GetFuelModeResp(sr.RequestIDNumber, sr.OverallResult, sr.FDCdata);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetConfiguration")
- {
- ServiceResponseGetConfiguration sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetConfiguration>(myString, ref result);
- GetConfigurationResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetDSPConfiguration")
- {
- ServiceResponseGetDSPConfiguration sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetDSPConfiguration>(myString, ref result);
- GetDSPConfigurationResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetTLGConfiguration")
- {
- ServiceResponseGetTLGConfiguration sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetTLGConfiguration>(myString, ref result);
- GetTLGConfigurationResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetPPConfiguration")
- {
- ServiceResponseGetPPConfiguration sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetPPConfiguration>(myString, ref result);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "SetConfiguration")
- {
- ServiceResponseSetConfiguration sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseSetConfiguration>(myString, ref result);
- SetConfigurationResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "LockNozzle")
- {
- ServiceResponseLockNozzle sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseLockNozzle>(myString, ref result);
- LockNozzleResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "UnlockNozzle")
- {
- ServiceResponseUnlockNozzle sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseUnlockNozzle>(myString, ref result);
- UnlockNozzleResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetCountrySettings")
- {
- ServiceResponseGetCountrySettings sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetCountrySettings>(myString, ref result);
- GetCountrySettingsResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetDSPLimits")
- {
- ServiceResponseGetDSPLimits sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetDSPLimits>(myString, ref result);
- GetDSPLimitsResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "ChangeDSPLimits")
- {
- ServiceResponseChangeDSPLimits sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseChangeDSPLimits>(myString, ref result);
- ChangeDSPLimitsResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "SuspendFuelling")
- {
- ServiceResponseSuspendFuelling sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseSuspendFuelling>(myString, ref result);
- SuspendFuellingResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "ResumeFuelling")
- {
- ServiceResponseResumeFuelling sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseResumeFuelling>(myString, ref result);
- ResumeFuellingResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "LockTank")
- {
- ServiceResponseLockTank sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseLockTank>(myString, ref result);
- LockTankResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "UnlockTank")
- {
- ServiceResponseUnlockTank sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseUnlockTank>(myString, ref result);
- UnlockTankResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetTankData")
- {
- ServiceResponseGetTankData sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetTankData>(myString, ref result);
- GetTankDataResp(sr.RequestIDNumber, sr.OverallResult, sr, myString);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetTankReconciliation")
- {
- ServiceResponseGetTankReconciliation sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetTankReconciliation>(myString, ref result);
- GetTankReconciliationResp(sr.RequestIDNumber, sr.OverallResult, sr, myString);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetTankDelivery")
- {
- ServiceResponseGetTankDelivery sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetTankDelivery>(myString, ref result);
- GetTankDeliveryResp(sr.RequestIDNumber, sr.OverallResult, sr, myString);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "ReserveFuelPoint")
- {
- ServiceResponseReserveFuelPoint sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseReserveFuelPoint>(myString, ref result);
- ReserveFuelPointResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "FreeFuelPoint")
- {
- ServiceResponseFreeFuelPoint sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseFreeFuelPoint>(myString, ref result);
- FreeFuelPointResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "StartFuelPointTest")
- {
- ServiceResponseStartFuelPointTest sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseStartFuelPointTest>(myString, ref result);
- StartFuelPointTestResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "EndFuelPointTest")
- {
- ServiceResponseEndFuelPointTest sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseEndFuelPointTest>(myString, ref result);
- EndFuelPointTestResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "OpenFuelPoint")
- {
- ServiceResponseOpenFuelPoint sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseOpenFuelPoint>(myString, ref result);
- OpenFuelPointResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "CloseFuelPoint")
- {
- ServiceResponseCloseFuelPoint sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseCloseFuelPoint>(myString, ref result);
- CloseFuelPointResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "OpenDevice")
- {
- ServiceResponseOpenDevice sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseOpenDevice>(myString, ref result);
- OpenDeviceResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "CloseDevice")
- {
- ServiceResponseCloseDevice sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseCloseDevice>(myString, ref result);
- CloseDeviceResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "SetDeviceAlarm")
- {
- ServiceResponseSetDeviceAlarm sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseSetDeviceAlarm>(myString, ref result);
- SetDeviceAlarmResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "OPTAdd")
- {
- ServiceResponseOPTAdd sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseOPTAdd>(myString, ref result);
- OptAddResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "OPTRemove")
- {
- ServiceResponseOPTRemove sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseOPTRemove>(myString, ref result);
- OptRemoveResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "OPTWrite")
- {
- ServiceResponseOPTWrite sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseOPTWrite>(myString, ref result);
- OptWriteResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "ConfigStart")
- {
- ServiceResponseConfigStart sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseConfigStart>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().ConfigStartResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "DefProducts")
- {
- ServiceResponseDefProducts sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseDefProducts>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().DefProductsResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "DefGrades")
- {
- ServiceResponseDefGrades sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseDefGrades>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().DefGradesResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "DefTanks")
- {
- ServiceResponseDefTanks sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseDefTanks>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().DefTanksResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "DefTankSuctions")
- {
- ServiceResponseDefTankSuctions sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseDefTankSuctions>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().DefTankSuctionsResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "DefFPFuelModes")
- {
- ServiceResponseDefFuelMode sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseDefFuelMode>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().DefFuelModeResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "DefFCFuelMode")
- {
- ServiceResponseDefFuellingMode sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseDefFuellingMode>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().DefFuellingModeResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "DefFuelPoints")
- {
- ServiceResponseDefFuelPoints sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseDefFuelPoints>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().DefFuelPointsResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "DefPricePoles")
- {
- ServiceResponseDefPricePole sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseDefPricePole>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().DefPricePoleResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "DefTankMonitors")
- {
- ServiceResponseDefTankMonitor sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseDefTankMonitor>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().DefTankMonitorResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "DefFPOperationModes")
- {
- ServiceResponseDefFPOperationModes sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseDefFPOperationModes>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().DefFPOperationModesResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "ConfigEnd")
- {
- ServiceResponseConfigEnd sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseConfigEnd>(myString, ref result);
- if (FUSIONConfigFactory.getConfigurator() != null)
- FUSIONConfigFactory.getConfigurator().ConfigEndResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "GetFuelPrice")
- {
- ServiceResponseGetFuelPrices sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseGetFuelPrices>(myString, ref result);
- GetFuelPricesResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "CloseReconciliationPeriod")
- {
- ServiceResponseCloseReconciliationPeriod sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseCloseReconciliationPeriod>(myString, ref result);
- CloseReconciliationPeriodResp(sr.RequestIDNumber, sr.OverallResult, sr.FDCdata);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "StopFuelPoint")
- {
- ServiceResponseStopFuelPoint sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseStopFuelPoint>(myString, ref result);
- StopFuelPointResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else if (requestType == "StartFuelPoint")
- {
- ServiceResponseStartFuelPoint sr = clientSocket.ifsfMessages.Deserialize<ServiceResponseStartFuelPoint>(myString, ref result);
- StartFuelPointResp(sr.RequestIDNumber, sr.OverallResult, sr);
- result = FDCConvert.OverallResultToInt(sr.OverallResult);
- }
- else
- {
- }
- DebugLog(string.Format("ReadResponse end: requestType={0}, requestId={1}", requestType, requestId));
- }
- catch (Exception ex)
- {
- DebugLog(string.Format("ReadResponse RequestType='{0}', requestId={1} Exception! {2}", requestType, requestId, ex));
- result = OverallResult.Failure;
- }
- }
- }
- if (result != OverallResult.Success)
- {
- if (result != OverallResult.NoData)
- {
- string deviceType = "";
- int deviceId = 0;
- int alarmId = 0;
- string alarmmsg = string.Format("Error '{0}' receiving Response for requestId:'{1}', requestType:'{2}'", result.ToString(), requestId, requestType);
- OnDeviceAlarm(this, new DeviceAlarmEventArgs(deviceType, deviceId, alarmId, alarmmsg));
- }
- }
- return requestType;
- }
- public string ReadMessage(string myString, int msglength, ref OverallResult result)
- {
- if (result != OverallResult.Success)
- {
- DebugLog(string.Format("ReadMessage ERROR result='{0}'", result));
- }
- string requestType = GetRequestType("MessageType", myString);
- int requestId = GetRequestID("MessageID", myString);
- DebugLog(string.Format("ReadMessage init: MessageType='{0}', requestId={1}", requestType, requestId));
- if (requestType == "")
- {
- DebugLog(string.Format("ReadMessage INVALID requestType='{0}', requestId={1}", requestType, requestId));
- return requestType;
- }
- int UTFlength = System.Text.Encoding.UTF8.GetBytes(myString).Length;
- if (UTFlength != msglength)
- {
- DebugLog(string.Format("ReadMessage header='{0}' != msgLength={1}", msglength, UTFlength));
- result = OverallResult.FormatError;
- return requestType;
- }
- try
- {
- switch (requestType)
- {
- case "FDCHeartBeat":
- {
- HeartbeatMsg();
- }
- break;
- case "FDCReady":
- case "FDC_Ready":
- {
- HeartbeatMsg();
- }
- break;
- case "FDCStarted":
- {
- FDCMessageStarted msg = clientSocket.ifsfMessages.Deserialize<FDCMessageStarted>(myString, ref result);
- FDCStartedMsg(msg);
- }
- break;
- case "TwinMasterIsOn":
- {
- FDCMessageTwinMasterIsOn msg = clientSocket.ifsfMessages.Deserialize<FDCMessageTwinMasterIsOn>(myString, ref result);
- TwinMasterReadyMsg(msg);
- }
- break;
- case "FDCStopped":
- {
- FDCMessageStopped msg = clientSocket.ifsfMessages.Deserialize<FDCMessageStopped>(myString, ref result);
- FDCStoppedMsg(msg);
- }
- break;
- case "DeviceStateChange":
- {
- FDCMessageDeviceStateChange msg = clientSocket.ifsfMessages.Deserialize<FDCMessageDeviceStateChange>(myString, ref result);
- DeviceStateChangeMsg(msg);
- }
- break;
- case "FPStateChange":
- {
- FDCMessageFPStateChange msg = clientSocket.ifsfMessages.Deserialize<FDCMessageFPStateChange>(myString, ref result);
- FPStateChangeMsg(msg);
- }
- break;
- case "TPStateChange":
- {
- FDCMessageTPStateChange msg = clientSocket.ifsfMessages.Deserialize<FDCMessageTPStateChange>(myString, ref result);
- TPStateChangeMsg(msg);
- }
- break;
- case "VIRStateChange":
- {
- FDCMessageVIRStateChange msg = clientSocket.ifsfMessages.Deserialize<FDCMessageVIRStateChange>(myString, ref result);
- VIRStateChangeMsg(msg);
- }
- break;
- case "FuelPointCurrentFuellingStatus":
- {
- FDCMessageCurrentFuellingStatus msg = clientSocket.ifsfMessages.Deserialize<FDCMessageCurrentFuellingStatus>(myString, ref result);
- CurrentFuellingStatusMsg(msg);
- }
- break;
- case "DeviceAlarm":
- {
- FDCMessageDeviceAlarm msg = clientSocket.ifsfMessages.Deserialize<FDCMessageDeviceAlarm>(myString, ref result);
- DeviceAlarmMsg(msg);
- }
- break;
- case "FuelSaleTrx":
- {
- FDCMessageFuelSaleTrx msg = clientSocket.ifsfMessages.Deserialize<FDCMessageFuelSaleTrx>(myString, ref result);
- FuelSaleTrxMsg(msg, myString);
- }
- break;
- case "FuelPriceChange":
- {
- FDCMessageFuelPriceChange msg = clientSocket.ifsfMessages.Deserialize<FDCMessageFuelPriceChange>(myString, ref result);
- FuelPriceChangeMsg(msg);
- }
- break;
- case "FuelModeChange":
- {
- FDCMessageFuelModeChange msg = clientSocket.ifsfMessages.Deserialize<FDCMessageFuelModeChange>(myString, ref result);
- FuelModeChangeMsg(msg.FDCdata[0]);
- }
- break;
- case "FPModeChange":
- {
- FDCMessageFPModeChange msg = clientSocket.ifsfMessages.Deserialize<FDCMessageFPModeChange>(myString, ref result);
- FuelModeChangeMsg(msg.FDCdata[0]);
- }
- break;
- case "FDCExceptionMsg":
- {
- FDCMessageFDCExceptionMsg msg = clientSocket.ifsfMessages.Deserialize<FDCMessageFDCExceptionMsg>(myString, ref result);
- FDCExceptionMsg(msg);
- }
- break;
- case "ConfigurationChange":
- {
- FDCMessageConfigurationChange msg = clientSocket.ifsfMessages.Deserialize<FDCMessageConfigurationChange>(myString, ref result);
- FDCMessageConfigurationChangeMsg(msg);
- }
- break;
- case "OPTRead":
- if (FDCGlobal.ProtocolVersion <= FDCVersion.V0007)
- {
- FDCMessageOPTReadV07 msg = clientSocket.ifsfMessages.Deserialize<FDCMessageOPTReadV07>(myString, ref result);
- OptReadMsg(msg);
- }
- else
- {
- FDCMessageOPTRead msg = clientSocket.ifsfMessages.Deserialize<FDCMessageOPTRead>(myString, ref result);
- OptReadMsg(msg);
- }
- break;
- }
- DebugLog("ReadMessage end");
- }
- catch (Exception ex)
- {
- DebugLog(string.Format("ReadMessage MessageType='{0}', requestId={1} Exception! {2}", requestType, requestId, ex));
- }
- return requestType;
- }
- private string GetRequestType(string typeField, string myString)
- {
- string requestType = "";
- try
- {
- int pos;
- if ((pos = myString.IndexOf(typeField)) >= 0)
- {
- int si = myString.IndexOf('\"', pos) + 1;
- int ei = myString.IndexOf('\"', si);
- requestType = myString.Substring(si, ei - si);
- }
- }
- catch (Exception ex)
- {
- DebugLog("Exception! " + ex);
- }
- return requestType;
- }
- private int GetRequestID(string typeField, string myString)
- {
- int requestID = 0;
- try
- {
- int pos;
- if ((pos = myString.IndexOf(typeField)) >= 0)
- {
- int si = myString.IndexOf('\"', pos) + 1;
- int ei = myString.IndexOf('\"', si);
- requestID = Convert.ToInt32(myString.Substring(si, ei - si));
- }
- }
- catch (Exception ex)
- {
- DebugLog("Exception! " + ex);
- }
- return requestID;
- }
- public void LogOn(string posInfo, string sFDCDateTime)
- {
-
-
- LogOn(null, posInfo, sFDCDateTime);
- }
- public void LogOn(byte[][] validationInfoArray, string posInfo, string sFDCDateTime)
- {
-
-
- try
- {
- DebugLog(string.Format("LogOn init, version={0}", FDCGlobal.ProtocolVersion));
- ServiceRequest logOn;
- if (FDCGlobal.ProtocolVersion <= FDCVersion.V0007)
- {
-
- logOn = new ServiceRequestLogOnV07();
- logOn.ApplicationSender = clientSocket.applicationSender;
- logOn.WorkstationID = clientSocket.workstationID;
- ServiceRequestPOSdataLogOnV07 posDataElem = new ServiceRequestPOSdataLogOnV07();
- posDataElem.POSName = "";
- if (sFDCDateTime == "")
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- else
- posDataElem.POSTimeStamp = sFDCDateTime;
- posDataElem.ResponsePort = clientSocket.iIPPortB.ToString();
- posDataElem.UnsolicitedPort = clientSocket.iIPPortC.ToString();
- posDataElem.interfaceVersion = FDCGlobal.VersionToString();
- posDataElem.InterfaceVersion = FDCGlobal.VersionToString();
- if (posInfo != "")
- {
- posDataElem.posInfo = UTF8Encoding.UTF8.GetBytes(posInfo);
- }
- if (validationInfoArray != null)
- posDataElem.ValidationInfo = validationInfoArray;
- ServiceRequestPOSdataLogOnV07[] posDataArray = { posDataElem };
- ((ServiceRequestLogOnV07)logOn).POSdata = posDataArray;
- }
- else
- {
-
- logOn = new ServiceRequestLogOn();
- logOn.ApplicationSender = clientSocket.applicationSender;
- logOn.WorkstationID = clientSocket.workstationID;
- ServiceRequestPOSdataLogOn posDataElem = new ServiceRequestPOSdataLogOn();
- posDataElem.POSName = "";
- if (sFDCDateTime == "")
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- else
- posDataElem.POSTimeStamp = sFDCDateTime;
- posDataElem.ResponsePort = clientSocket.iIPPortB.ToString();
- posDataElem.UnsolicitedPort = clientSocket.iIPPortC.ToString();
- posDataElem.InterfaceVersion = FDCGlobal.VersionToString();
- if (posInfo != "")
- {
-
- DebugLog(string.Format("EnqueueMessage logOn posInfo='{0}'", posInfo));
- posDataElem.posInfo = posInfo;
- }
- if (validationInfoArray != null)
- {
- posDataElem.ValidationInfo = validationInfoArray;
- }
-
- string posValidationSourceString = logOn.ApplicationSender + logOn.WorkstationID + posDataElem.POSTimeStamp;
- MD5Crypter crypter = new MD5Crypter();
- byte[] posValidationSource = new byte[posValidationSourceString.Length + crypter.getPassphrase().GetLength(0)];
- Array.Copy(System.Text.Encoding.ASCII.GetBytes(posValidationSourceString), posValidationSource, (int)posValidationSourceString.Length);
- Array.Copy(crypter.getPassphrase(), 0, posValidationSource, (int)posValidationSourceString.Length, (int)crypter.getPassphrase().Length);
- byte[] posValidation = crypter.ComputeHash(posValidationSource);
- posDataElem.posValidation = "";
- StringBuilder sb = new StringBuilder(posValidation.Length * 2);
- foreach (byte b in posValidation)
- sb.Append(Convert.ToString(b, 16).PadLeft(2, '0'));
- posDataElem.posValidation = sb.ToString().ToUpper();
- DebugLog(string.Format("EnqueueMessage logOn posValidationSource='{0}', posValidation='{1}'", System.Text.Encoding.ASCII.GetString(posValidationSource, 0, posValidationSource.Length), posDataElem.posValidation));
- ServiceRequestPOSdataLogOn[] posDataArray = { posDataElem };
- ((ServiceRequestLogOn)logOn).POSdata = posDataArray;
- }
- DebugLog("EnqueueMessage logOn");
- clientSocket.ifsfMessages.EnqueueMessage(logOn, (EventHandler<AsyncCompletedEventArgs>)null, null, null, true, 30000);
- DebugLog("LogOn2 end");
- }
- catch (Exception ex)
- {
- DebugLog("LogOn Exception! " + ex);
- }
- }
- public void LogOnAddValidationInfo(byte[] validationInfo)
- {
-
-
- try
- {
- if (validationInfo == null)
- {
- DebugLog("LogOnAddValidationInfo: null validationInfo");
- return;
- }
- DebugLog("LogOnAddValidationInfo init");
- if (this._clientSocket.logOnSendCalled && this._clientSocket.validationInfo != null)
- {
- this._clientSocket.validationInfo = null;
- this._clientSocket.logOnSendCalled = false;
- DebugLog("LogOnAddValidationInfo logOnSendCalled=false");
- }
- byte[][] ValidationInfo = this._clientSocket.validationInfo;
- IFSFManager.ArrayResize<byte[]>(ref ValidationInfo, (ValidationInfo != null) ? ValidationInfo.Length + 1 : 1);
- this._clientSocket.validationInfo = ValidationInfo;
- this._clientSocket.validationInfo[this._clientSocket.validationInfo.Length - 1] = new byte[validationInfo.Length];
- this._clientSocket.validationInfo[this._clientSocket.validationInfo.Length - 1] = validationInfo;
- DebugLog("LogOnAddValidationInfo end");
- }
- catch (Exception ex)
- {
- DebugLog("LogOnAddValidationInfo Exception! " + ex);
- }
- }
- public void LogOnSend(string posInfo)
- {
-
-
- try
- {
- DebugLog("LogOnSend init");
-
- if (serviceRequestLogOn == null)
- {
- LogOn(posInfo, "");
- }
- else
- {
- DebugLog("EnqueueMessage logOn");
- var logOn = serviceRequestLogOn;
- serviceRequestLogOn = null;
- clientSocket.ifsfMessages.EnqueueMessage(logOn, null, null, null, true, 30000);
- }
- this._clientSocket.logOnSendCalled = true;
- DebugLog("LogOnSend end");
- }
- catch (Exception ex)
- {
- DebugLog("LogOnSend Exception! " + ex);
- }
- }
- private void LogOnResp(int requestId, string sOverallResult, string seal, string sFDCTimeStamp)
- {
- try
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == FDCPOSLibrary.OverallResult.Success.ToString());
- if (sOverallResult == OverallResult.Success.ToString())
- {
-
- DebugLog(string.Format("Restarting HeartBeat next in {0}", heartbeat.heartbeatInterval));
- heartbeat.SetReconnected();
- heartbeat.Restart();
- GetCountrySettings(null, null, null);
-
- if (clientSocket.mainConnectionState != DeviceConnectionState.Connected)
- clientSocket.mainConnectionState = DeviceConnectionState.Connecting;
- if (seal != "" && OnDeviceAlarm != null)
- {
- string deviceType = "";
- int deviceId = 0;
- int alarmId = 2020;
- string alarmmsg = seal;
- OnDeviceAlarm(this, new DeviceAlarmEventArgs(deviceType, deviceId, alarmId, alarmmsg));
- }
- }
- else if (sOverallResult == OverallResult.AuthentificationError.ToString())
- {
- DebugLog(string.Format("authentificationErrorRetry={0}, sFDCTimeStamp={1}", authentificationErrorRetry, sFDCTimeStamp));
- if (authentificationErrorRetry)
- {
- authentificationErrorRetry = false;
- this.LogOn(clientSocket.validationInfo, clientSocket.posInfo, sFDCTimeStamp);
- }
- else if (OnDeviceAlarm != null)
- {
- authentificationErrorRetry = true;
- string deviceType = "";
- int deviceId = 0;
- int alarmId = 1001;
- string alarmmsg = "";
- OnDeviceAlarm(this, new DeviceAlarmEventArgs(deviceType, deviceId, alarmId, alarmmsg));
- }
- }
- }
- catch (Exception ex)
- {
- DebugLog("LogOnResp Exception! " + ex);
- }
- }
- public void LogOff()
- {
-
-
- try
- {
- DebugLog("LogOff init");
-
- ServiceRequestLogOff logOff = new ServiceRequestLogOff();
- logOff.ApplicationSender = clientSocket.applicationSender;
- logOff.WorkstationID = clientSocket.workstationID;
- ServiceRequestPOSdataLogOff posDataElem = new ServiceRequestPOSdataLogOff();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataLogOff[] posDataArray = { posDataElem };
- logOff.POSdata = posDataArray;
- DebugLog("EnqueueMessage logOff");
- clientSocket.ifsfMessages.EnqueueMessage(logOff, null, null, null, true, 30000);
- DebugLog("LogOff end");
- }
- catch (Exception ex)
- {
- DebugLog("LogOff Exception! " + ex);
- }
- }
- private void LogOffResp(int requestId, string sOverallResult)
- {
- try
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString());
- if (sOverallResult == OverallResult.Success.ToString())
- {
- if (clientSocket.mainConnectionState != DeviceConnectionState.Connected || clientSocket.mainConnectionState != DeviceConnectionState.Connecting)
- clientSocket.mainConnectionState = DeviceConnectionState.Disconnecting;
- }
- }
- catch (Exception ex)
- {
- DebugLog("LogOffResp Exception! " + ex);
- }
- }
- private void Heartbeat()
- {
- try
- {
- if (!heartbeat.tryingConnect)
- {
- ServiceRequestHeartbeat heartbeatmsg = new ServiceRequestHeartbeat();
- heartbeatmsg.ApplicationSender = this.clientSocket.applicationSender;
- heartbeatmsg.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSReady srPosready = new ServiceRequestPOSReady();
- srPosready.ApplicationSender = this.clientSocket.applicationSender;
- srPosready.WorkstationID = this.clientSocket.workstationID;
- POSMessagePOSReady msgPOSReady = new POSMessagePOSReady();
- msgPOSReady.ApplicationSender = this.clientSocket.applicationSender;
- msgPOSReady.WorkstationID = this.clientSocket.workstationID;
- DebugLog(string.Format("new POSReady: type={0},id={1}, counter={2}", msgPOSReady.MessageType, msgPOSReady.MessageID, FDCMessage.requestIDConter));
- ServiceRequestPOSdataHeartbeat posDataElem = new ServiceRequestPOSdataHeartbeat();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataHeartbeat[] posDataArray = { posDataElem };
- heartbeatmsg.POSdata = posDataArray;
- srPosready.POSdata = posDataArray;
- msgPOSReady.POSdata = posDataArray;
- heartbeat.Restart();
- if (FDCGlobal.ProtocolVersion <= FDCVersion.V0007)
- clientSocket.ifsfMessages.EnqueueMessage(heartbeatmsg, null, null, null, false, 0);
- else
- clientSocket.ifsfMessages.EnqueueMessage(msgPOSReady, null, null, null, false, 0);
- }
- else
- {
- DebugLog("HeartBeat tryingToConnect");
- var clientSocketRespChannelBThreadObj = this.clientSocket.respChannelBThreadObj;
- if (clientSocketRespChannelBThreadObj != null)
- {
- DebugLog(string.Format("HeartBeat true && {0}", !clientSocketRespChannelBThreadObj.bRunning));
- }
- else
- {
- DebugLog("HeartBeat false ");
- }
- if (clientSocketRespChannelBThreadObj != null && !clientSocketRespChannelBThreadObj.bRunning)
- {
- DebugLog("HeartBeat reconnecting");
- if (this.clientSocket.Connect(""))
- {
- heartbeat.tryingConnect = false;
- DebugLog("HeartBeat Restarting");
- heartbeat.Restart();
- }
- }
- }
- }
- catch (Exception ex)
- {
- DebugLog("HeartBeat Exception! " + ex);
- }
- }
- public void VersionInfo(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestVersionInfo sr = new ServiceRequestVersionInfo();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataVersionInfo posDataElem = new ServiceRequestPOSdataVersionInfo();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataVersionInfo[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("VersionInfo Exception! " + ex);
- }
- }
- private void VersionInfoResp(int requestId, string sOverallResult, ServiceResponseVersionInfo sr)
- {
- try
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString());
- if (OnVersionInfo != null)
- {
- OnVersionInfo(this, new VersionInfoEventArgs(sr.FDCdata[0].FDCversion, sr.FDCdata[0].FDCrelease, sr.FDCdata[0].FDChotfix));
- }
- }
- catch (Exception ex)
- {
- DebugLog("VersionInfoResp Exception! " + ex);
- }
- }
- public void StartForecourt(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestStartForecourt sr = new ServiceRequestStartForecourt();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataStartForecourt posDataElem = new ServiceRequestPOSdataStartForecourt();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataStartForecourt[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("StartForecourt Exception! " + ex);
- }
- }
- public void TwinOpenMaster(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestTwinOpenMaster sr = new ServiceRequestTwinOpenMaster();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataTwinOpenMaster posDataElem = new ServiceRequestPOSdataTwinOpenMaster();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataTwinOpenMaster[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("TwinOpenMaster Exception! " + ex);
- }
- }
- private void StartForecourtResp(int requestId, string sOverallResult, string errorCode)
- {
- try
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- }
- catch (Exception ex)
- {
- DebugLog("StartForecourtResp Exception! " + ex);
- }
- }
- private void TwinOpenMasterResp(int requestId, string sOverallResult, string errorCode)
- {
- try
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == FDCPOSLibrary.OverallResult.Success.ToString());
- }
- catch (Exception ex)
- {
- DebugLog("TwinOpenMasterResp Exception! " + ex);
- }
- }
- public void StopForecourt(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestStopForecourt sr = new ServiceRequestStopForecourt();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataStopForecourt posDataElem = new ServiceRequestPOSdataStopForecourt();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- posDataElem.Emergencystop = "false";
- ServiceRequestPOSdataStopForecourt[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("StopForecourt Exception! " + ex);
- }
- }
- private void StopForecourtResp(int requestId, string sOverallResult, string errorCode)
- {
- try
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == FDCPOSLibrary.OverallResult.Success.ToString());
- }
- catch (Exception ex)
- {
- DebugLog("StopForecourtResp Exception! " + ex);
- }
- }
- public void GetCurrentFuellingStatus(int pumpId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetCurrentFuellingStatus sr = new ServiceRequestGetCurrentFuellingStatus();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetCurrentFuellingStatus posDataElem = new ServiceRequestPOSdataGetCurrentFuellingStatus();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetCurrentFuellingStatus[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetCurrentFuellingStatus Exception! " + ex);
- }
- }
- public void GetFuelPointTotals(int pumpId, int nozzleId, EventHandler<AsyncCompletedEventArgs<PumpAccumulatorReading>> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetFuelPointTotals sr = new ServiceRequestGetFuelPointTotals();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetFuelPointTotals posDataElem = new ServiceRequestPOSdataGetFuelPointTotals();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassGetFuelPointTotals deviceClass = new ServiceRequestDeviceClassGetFuelPointTotals();
- deviceClass.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- deviceClass.NozzleNo = (nozzleId == -1) ? "*" : Convert.ToString(nozzleId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetFuelPointTotals[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- EventHandler<AsyncCompletedEventArgs> proxy = (sender, e) => requestCompleted(sender, (AsyncCompletedEventArgs<PumpAccumulatorReading>)e);
- clientSocket.ifsfMessages.EnqueueMessage(sr, proxy, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetFuelPointTotals Exception! " + ex);
- }
- }
- private void GetCurrentFuellingStatusResp(int requestId, string sOverallResult, ServiceResponseGetCurrentFuellingStatus sr)
- {
- try
- {
- DebugLog("GetCurrentFuellingStatusResp init");
- if (OnCurrentFuellingStatus != null && sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- {
- for (int i = 0; i < sr.FDCdata[0].DeviceClass.Length; i++)
- {
- var deviceClass = sr.FDCdata[0].DeviceClass[i];
- if (!string.IsNullOrEmpty(deviceClass.ReleaseToken) &&
- !string.IsNullOrEmpty(deviceClass.CurrentAmount) &&
- !string.IsNullOrEmpty(deviceClass.CurrentVolume))
- {
- DebugLog(string.Format("type={0}, id={1}, volume={2}, amount={3}", deviceClass.Type,
- deviceClass.DeviceID, deviceClass.CurrentVolume,
- deviceClass.CurrentAmount));
- string deviceType = deviceClass.Type;
- int deviceId = Convert.ToInt16(deviceClass.DeviceID);
- int nozzleId = Convert.ToInt16(deviceClass.CurrentNozzle);
- Decimal volume = FDCConvert.ToDecimal(deviceClass.CurrentVolume);
- Decimal amount = FDCConvert.ToDecimal(deviceClass.CurrentAmount);
- Decimal price = FDCConvert.ToDecimal(deviceClass.CurrentUnitPrice);
- string authAS = deviceClass.AuthorisationApplicationSender;
- var token = AuthReleaseTokenFactory.GenerateToken(deviceClass.ReleaseToken);
-
- var eventArgs = new CurrentFuellingStatusEventArgs(deviceType, deviceId, nozzleId, volume,
- amount, price, authAS)
- {
- ReleaseId = token.AuthorizationId,
- ReservingDeviceId = token.TerminalId,
- TransactionId = Convert.ToInt32(deviceClass.TransactionSeqNo),
- FuelPeriodSequenceNo = Convert.ToInt32(deviceClass.FuelPeriodSequenceNo)
- };
- OnCurrentFuellingStatus(this, eventArgs);
- }
- else
- {
- DebugLog("fuelling status data empty");
- }
- }
- }
- DebugLog("GetCurrentFuellingStatusResp end");
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == FDCPOSLibrary.OverallResult.Success.ToString());
- }
- catch (Exception ex)
- {
- DebugLog("GetCurrentFuellingStatusResp Exception! " + ex);
- }
- }
- private void GetFuelPointTotalsResp(int requestId, string sOverallResult, ServiceResponseGetFuelPointTotals sr, string originalXml)
- {
- try
- {
- DebugLog("GetFuelPointTotalsResp init");
- if (OnFuelPointTotals != null && sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- for (int i = 0; i < sr.FDCdata[0].DeviceClass.Length; i++)
- {
- DebugLog(string.Format("type={0}, id={1}, volume={2}, amount={3}", sr.FDCdata[0].DeviceClass[i].Type, sr.FDCdata[0].DeviceClass[i].DeviceID, sr.FDCdata[0].DeviceClass[i].Volume, sr.FDCdata[0].DeviceClass[i].Amount));
- string deviceType = sr.FDCdata[0].DeviceClass[i].Type;
- int deviceId = Convert.ToInt16(sr.FDCdata[0].DeviceClass[i].DeviceID);
- int nozzleId = Convert.ToInt16(sr.FDCdata[0].DeviceClass[i].NozzleNo);
- Decimal volume = FDCConvert.ToDecimal(sr.FDCdata[0].DeviceClass[i].Volume);
- Decimal amount = FDCConvert.ToDecimal(sr.FDCdata[0].DeviceClass[i].Amount);
- Decimal price = FDCConvert.ToDecimal(sr.FDCdata[0].DeviceClass[i].UnitPrice);
- OnFuelPointTotals(this, new FuelPointTotalsEventArgs(requestId, sOverallResult == FDCPOSLibrary.OverallResult.Success.ToString(),
- deviceType, deviceId, nozzleId, volume, amount, price, originalXml));
- }
- DebugLog("GetFuelPointTotalsResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetFuelPointTotalsResp Exception! " + ex);
- }
- }
- public void GetDeviceState(string deviceType, int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
- DebugLog(string.Format("GetDeviceState init: deviceId={0}, deviceType={1}", deviceId, deviceType));
-
- if (deviceType == DeviceType.DT_FuellingPoint)
- {
- ServiceRequestGetFPState sr = new ServiceRequestGetFPState();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetDeviceState posDataElem = new ServiceRequestPOSdataGetDeviceState();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = (deviceId == -1) ? "*" : Convert.ToString(deviceId);
- deviceClass.Type = deviceType;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetDeviceState[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- else if (deviceType == DeviceType.DT_TankProbe || deviceType == DeviceType.DT_TankLevelGauge)
- {
- ServiceRequestGetTPState sr = new ServiceRequestGetTPState();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetDeviceState posDataElem = new ServiceRequestPOSdataGetDeviceState();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = (deviceId == -1) ? "*" : Convert.ToString(deviceId);
- deviceClass.Type = deviceType;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetDeviceState[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- else if (deviceType == DeviceType.DT_Vir)
- {
- ServiceRequestGetVIRState sr = new ServiceRequestGetVIRState();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetDeviceState posDataElem = new ServiceRequestPOSdataGetDeviceState();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = (deviceId == -1) ? "*" : Convert.ToString(deviceId);
- deviceClass.Type = deviceType;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetDeviceState[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- else if (deviceType == DeviceType.DT_PricePole || deviceType == DeviceType.DT_PricePolePoint)
- {
- ServiceRequestGetPPState sr = new ServiceRequestGetPPState();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetDeviceState posDataElem = new ServiceRequestPOSdataGetDeviceState();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = (deviceId == -1) ? "*" : Convert.ToString(deviceId);
- deviceClass.Type = deviceType;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetDeviceState[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- else
- {
- ServiceRequestGetDeviceState sr = new ServiceRequestGetDeviceState();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetDeviceState posDataElem = new ServiceRequestPOSdataGetDeviceState();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = (deviceId == -1) ? "*" : Convert.ToString(deviceId);
- deviceClass.Type = deviceType;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetDeviceState[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- DebugLog("GetDeviceState end");
- }
- catch (Exception ex)
- {
- DebugLog("GetDeviceState Exception! " + ex);
- }
- }
- private void GetDeviceStateResp(int requestId, string sOverallResult, ServiceResponseGetDeviceState sr)
- {
- try
- {
- if (OnDeviceStateChange != null && sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- {
- for (int i = 0; i < sr.FDCdata[0].DeviceClass.Length; i++)
- {
- DebugLog(string.Format("GetDeviceStateResp type={0}, id={1}, state={2}, substate={3}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[i].DeviceID, sr.FDCdata[0].DeviceClass[i].LogicalState, sr.FDCdata[0].DeviceClass[i].LogicalSubState));
- string deviceType = sr.FDCdata[0].DeviceClass[i].Type;
- int deviceId = Convert.ToInt16(sr.FDCdata[0].DeviceClass[i].DeviceID);
- LogicalDeviceState state = this.convertLogicalDeviceState(!string.IsNullOrEmpty(sr.FDCdata[0].DeviceClass[i].LogicalState) ? sr.FDCdata[0].DeviceClass[i].LogicalState : sr.FDCdata[0].DeviceClass[i].DeviceState.DeviceState);
- LogicalDeviceState substate = convertLogicalDeviceState(!string.IsNullOrEmpty(sr.FDCdata[0].DeviceClass[i].LogicalSubState) ? sr.FDCdata[0].DeviceClass[i].LogicalSubState : sr.FDCdata[0].DeviceClass[i].DeviceSubState);
- int nozzleUp = 0;
- if (sr.FDCdata[0].DeviceClass[i].Nozzle != null)
- {
- foreach (NozzleStateClass nozzleState in sr.FDCdata[0].DeviceClass[i].Nozzle)
- {
- if (nozzleState.LogicalNozzle == "NozzleUp")
- nozzleUp = Convert.ToInt32(nozzleState.NozzleNo);
- }
- }
- OnDeviceStateChange.Invoke(this, new DeviceStateChangedEventArgs(deviceType, deviceId, state, substate, "", nozzleUp));
- }
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString());
- }
- DebugLog("GetDeviceStateResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetDeviceStateResp Exception! " + ex);
- }
- }
- private void GetFPStateResp(int requestId, string sOverallResult, ServiceResponseGetFPState sr)
- {
- try
- {
- if (OnDeviceStateChange != null && sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- {
- if (sOverallResult == OverallResult.Success.ToString())
- {
- for (int i = 0; i < sr.FDCdata[0].DeviceClass.Length; i++)
- {
- DebugLog(string.Format("GetFPStateResp type={0}, id={1}, state={2}, substate={3}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[i].DeviceID, sr.FDCdata[0].DeviceClass[i].DeviceState, sr.FDCdata[0].DeviceClass[i].DeviceSubState));
- string deviceType = sr.FDCdata[0].DeviceClass[i].Type;
- int deviceId = Convert.ToInt16(sr.FDCdata[0].DeviceClass[i].DeviceID);
- LogicalDeviceState state = this.convertLogicalDeviceState(sr.FDCdata[0].DeviceClass[i].DeviceState.DeviceState);
- LogicalDeviceState substate = convertLogicalDeviceState(sr.FDCdata[0].DeviceClass[i].DeviceSubState);
- if (!string.IsNullOrEmpty(sr.FDCdata[0].DeviceClass[i].DeviceState.Stopped) && XmlConvert.ToBoolean(sr.FDCdata[0].DeviceClass[i].DeviceState.Stopped))
- substate = LogicalDeviceState.FDC_STOPPED;
- string lockingAS = sr.FDCdata[0].DeviceClass[i].LockingApplicationSender;
- int nozzleUp = 0;
- if (sr.FDCdata[0].DeviceClass[i].Nozzle != null)
- {
- foreach (NozzleStateClass nozzleState in sr.FDCdata[0].DeviceClass[i].Nozzle)
- {
- if (nozzleState.LogicalNozzle == "NozzleUp")
- nozzleUp = Convert.ToInt32(nozzleState.NozzleNo);
- }
- }
- OnDeviceStateChange.Invoke(this, new DeviceStateChangedEventArgs(deviceType, deviceId, state, substate, lockingAS, nozzleUp));
- }
- }
- else
- DebugLog(string.Format("overallResult={0}", sOverallResult));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == FDCPOSLibrary.OverallResult.Success.ToString());
- }
- DebugLog("GetFPStateResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetFPStateResp Exception! " + ex);
- }
- }
- private void GetTPStateResp(int requestId, string sOverallResult, ServiceResponseGetTPState sr)
- {
- try
- {
- if (OnDeviceStateChange != null && sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- {
- for (int i = 0; i < sr.FDCdata[0].DeviceClass.Length; i++)
- {
- DebugLog(string.Format("GetTPStateResp type={0}, id={1}, state={2}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[i].DeviceID, sr.FDCdata[0].DeviceClass[i].DeviceState));
- string deviceType = sr.FDCdata[0].DeviceClass[i].Type;
- int deviceId = Convert.ToInt16(sr.FDCdata[0].DeviceClass[i].DeviceID);
- LogicalDeviceState state = this.convertLogicalDeviceState(sr.FDCdata[0].DeviceClass[i].DeviceState.DeviceState);
- OnDeviceStateChange.Invoke(this, new DeviceStateChangedEventArgs(deviceType, deviceId, state, LogicalDeviceState.FDC_UNDEFINED, "", 0));
- }
- }
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString());
- DebugLog("GetTPStateResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetTPStateResp Exception! " + ex);
- }
- }
- private void GetPPStateResp(int requestId, string sOverallResult, ServiceResponseGetPPState sr)
- {
- try
- {
- if (OnDeviceStateChange != null && sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- {
- for (int i = 0; i < sr.FDCdata[0].DeviceClass.Length; i++)
- {
- DebugLog(string.Format("GetPPStateResp type={0}, id={1}, state={2}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[i].DeviceID, sr.FDCdata[0].DeviceClass[i].DeviceState));
- }
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString());
- }
- DebugLog("GetPPStateResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetPPStateResp Exception! " + ex);
- }
- }
- private void GetVIRStateResp(int requestId, string sOverallResult, ServiceResponseGetVIRState sr)
- {
- try
- {
- if (OnVirStateChange != null && sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- {
- for (int i = 0; i < sr.FDCdata[0].DeviceClass.Length; i++)
- {
- int deviceId = Convert.ToInt16(sr.FDCdata[0].DeviceClass[i].DeviceID);
- if (sr.FDCdata[0].DeviceClass[i].Vir != null)
- {
- foreach (VIRStateClass virState in sr.FDCdata[0].DeviceClass[i].Vir)
- {
- DebugLog(string.Format("GetVIRStateResp type={0}, id={1}, virId={2}, state={3}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[i].DeviceID, virState.VirID, virState.DeviceState));
- LogicalDeviceState state = this.convertLogicalDeviceState(virState.DeviceState);
- DeviceConnectionState deviceState;
- if (state == LogicalDeviceState.FDC_READY)
- deviceState = DeviceConnectionState.Connected;
- else if (state == LogicalDeviceState.FDC_OFFLINE)
- deviceState = DeviceConnectionState.Disconnected;
- else
- deviceState = DeviceConnectionState.Unknown;
- OnVirStateChange(this, new VIRStateChangedEventArgs(deviceId, virState.VirID, deviceState));
- }
- }
- }
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString());
- }
- DebugLog("GetVIRStateResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetVIRStateResp Exception! " + ex);
- }
- }
- public void TerminateFuelling(int pumpId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestTerminateFuelling sr = new ServiceRequestTerminateFuelling();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataTerminateFuelling posDataElem = new ServiceRequestPOSdataTerminateFuelling();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- deviceClass.CreateZeroSale = Convert.ToString(false);
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataTerminateFuelling[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("TerminateFuelling Exception! " + ex);
- }
- }
- private void TerminateFuellingResp(int requestId, string sOverallResult, ServiceResponseTerminateFuelling sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass[0].ErrorCode;
- DebugLog(string.Format("TerminateFuellingResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[0].DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- }
- catch (Exception ex)
- {
- DebugLog("TerminateFuellingResp Exception! " + ex);
- }
- }
- public void AuthoriseFuelPoint(int pumpId, int transactionId, FuellingType fuellingType, byte reservingDeviceId, IAuthorizeParameters authParams, EventHandler<AsyncCompletedEventArgs<long>> requestCompleted, object userToken, object src)
- {
- try
- {
- DebugLog(String.Format("ISFSManager.AuthoriseFuelPoint: pumpId={0}, fuellingType={1}, reservingDeviceId={2}, request={3}, Token={4} Src={5}",
- pumpId, fuellingType, reservingDeviceId, requestCompleted, userToken, src));
- DebugLog(
- String.Format(
- "ISFSManager.AuthoriseFuelPoint: authParams: PresetType={0}, PresetValue={1}, LockToClient={2}, Prepay={3}, ConsentGiven={4}, PriceGroup={5}, AllowedFuelGrade={6}, FuelGradeMaxVolume={7}",
- authParams.PresetType, authParams.PresetValue, authParams.LockToReleaseClient, authParams.Prepay,
- authParams.ConsentGiven, authParams.PriceGroup, authParams.AllowedFuelGrade,
- authParams.FuelGradeMaxVolume));
-
- ServiceRequestAuthoriseFuelPoint sr = new ServiceRequestAuthoriseFuelPoint();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataAuthoriseFuelPoint posDataElem = new ServiceRequestPOSdataAuthoriseFuelPoint();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassAuthoriseFuelPoint authFP = new ServiceRequestDeviceClassAuthoriseFuelPoint();
- authFP.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- authFP.Type = DeviceType.DT_FuellingPoint;
- if (authParams.PresetType == PresetType.Amount)
- {
- authFP.MaxTrxVolume = FDCConvert.ToString((Decimal)0);
- authFP.MaxTrxAmount = FDCConvert.ToString(authParams.PresetValue);
- }
- else
- {
- authFP.MaxTrxVolume = FDCConvert.ToString(authParams.PresetValue);
- authFP.MaxTrxAmount = FDCConvert.ToString((Decimal)0);
- }
- authFP.LockFuelSaleTrx = Convert.ToString(authParams.LockToReleaseClient);
-
-
-
- var terminalId = 0;
- if (fuellingType == FuellingType.OptCardPaid || fuellingType == FuellingType.OptCashPaid)
- terminalId = reservingDeviceId;
- if (fuellingType == FuellingType.Prepaid)
- terminalId = authParams.PrepayReceiptNo / 10000;
- var token = AuthReleaseTokenFactory.GenerateToken(
- terminalId,
- transactionId,
- fuellingType == FuellingType.Prepaid ? (int?)(authParams.PrepayReceiptNo % 10000) : null);
- authFP.ReleaseToken = token.ToString();
- authFP.ReservingDeviceId = Convert.ToString(reservingDeviceId);
- authFP.FuellingType = Convert.ToString((int)fuellingType);
- if (authParams.Prepay)
- {
- var prepaidTrx = new PrepaidTrxElementClass();
- prepaidTrx.IsPrepaid = Convert.ToString(true);
- authFP.PrepaidTrx = prepaidTrx;
- }
- if (authParams.ConsentGiven)
- authFP.ConsentGiven = Convert.ToString(true);
- authFP.ProcessZeroSale = Convert.ToString(authParams.ProcessZeroSale);
- authFP.ApplyAuthPresetRetries = Convert.ToString(authParams.ApplyAuthPresetRetries);
- var modeNo = manager.forecourtControl.ForecourtConfiguration.GetFuelMode(fuellingType, authParams.PriceGroup);
- DebugLog(String.Format("ISFSManager.AuthoriseFuelPoint.configuration.GetFuelMode: fuellingType={0}, PriceGroup={1}, modeNo={2}",
- fuellingType, authParams.PriceGroup, modeNo));
- var pump = src as IPump;
- if (pump != null)
- {
- if ((pump.State == PumpState.Idle || pump.State == PumpState.Calling) && fuellingType == FuellingType.Postpaid)
- {
-
- modeNo = manager.forecourtControl.ForecourtConfiguration.GetFuelMode(authParams.PriceGroup, true);
- DebugLog(String.Format("ISFSManager.AuthoriseFuelPoint.configuration.GetFuelMode: fuellingType={0}, PriceGroup=Postpaid, modeNo={1}",
- fuellingType, modeNo));
- }
- }
- authFP.FuelMode = new FuelModeElementClass() { ModeNo = modeNo.ToString() };
- ReleasedProductsClass products = new ReleasedProductsClass();
- AllowedFuelGrades fgs = (AllowedFuelGrades)(authParams.AllowedFuelGrade);
- FuelGradeMaxVolumes vols = (FuelGradeMaxVolumes)(authParams.FuelGradeMaxVolume);
- int count = 0;
- products.Product = new ProductElementClass[fgs.Count];
- for (int iFuelGrade = 0; iFuelGrade < fgs.Count; iFuelGrade++)
- {
- if (fgs[iFuelGrade])
- {
- products.Product[count] = new ProductElementClass();
- products.Product[count].ProductNo = Convert.ToString(iFuelGrade);
- if ((iFuelGrade < vols.Count) && vols[iFuelGrade].HasValue)
- products.Product[count].MaxTrxVolume = FDCConvert.ToString((decimal)vols[iFuelGrade]);
- count++;
- }
- }
- authFP.ReleasedProducts = products;
- posDataElem.DeviceClass = authFP;
- ServiceRequestPOSdataAuthoriseFuelPoint[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
-
- EventHandler<AsyncCompletedEventArgs> proxy = (sender, e) => requestCompleted(sender, new AsyncCompletedEventArgs<long>(e.Success, transactionId, e.UserToken));
- clientSocket.ifsfMessages.EnqueueMessage(sr, proxy, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("AuthoriseFuelPoint Exception! " + ex);
- }
- }
- private void AuthoriseFuelPointResp(int requestId, string sOverallResult, ServiceResponseAuthoriseFuelPoint sr)
- {
- try
- {
- DebugLog("AuthoriseFuelPointResp init");
- string errorCode = (sr.FDCdata[0].FDCStatus != null) ? sr.FDCdata[0].FDCStatus : sr.FDCdata[0].DeviceClass.ErrorCode;
- if ((errorCode == ErrorCode.ERRCD_OK.ToString()) && (sOverallResult == OverallResult.Success.ToString()))
- {
-
- DebugLog(string.Format("Waiting for unsolicited FPStateChange, RequestId={0}.", requestId));
- unsolicitedFPStateChangeDictionary[Convert.ToInt16(sr.FDCdata[0].DeviceClass.DeviceID)] = requestId;
- }
- else
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, false);
- DebugLog("AuthoriseFuelPointResp end");
- }
- catch (Exception ex)
- {
- DebugLog("AuthoriseFuelPointResp Exception! " + ex);
- }
- }
- public void ChangeFuelMode(int pumpId, int mode, ushort? operationMode, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestChangeFuelMode sr = new ServiceRequestChangeFuelMode();
- if (FDCGlobal.ProtocolVersion <= FDCVersion.V0007)
- sr.RequestType = "ChangeFuelMode";
- else
- sr.RequestType = "ChangeFPFuelMode";
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataChangeFuelMode posDataElem = new ServiceRequestPOSdataChangeFuelMode();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassChangeFuelMode deviceClass = new ServiceRequestDeviceClassChangeFuelMode();
- deviceClass.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- deviceClass.FuelMode = new FuelModeElementClass();
- deviceClass.FuelMode.ModeNo = Convert.ToString(mode);
- if (operationMode.HasValue)
- {
- deviceClass.FuelMode.OperationModeSpecified = true;
- deviceClass.FuelMode.OperationMode = (ushort)operationMode;
- }
- ServiceRequestDeviceClassChangeFuelMode[] deviceClassArray = { deviceClass };
- posDataElem.DeviceClass = deviceClassArray;
- ServiceRequestPOSdataChangeFuelMode[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("ChangeFuelMode Exception! " + ex);
- }
- }
- public void ChangeFuelModeAdd(ServiceRequestChangeFuelMode sr, int pumpId, int mode, ushort? operationMode, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
-
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- DebugLog(string.Format("ChangeFuelModeAdd init: sr.ApplicationSender={0}, sr.WorkstationID={1}, pumpId={2}, mode={3}", sr.ApplicationSender, sr.WorkstationID, pumpId, mode));
- ServiceRequestPOSdataChangeFuelMode POSDataElem;
- if (sr.POSdata != null)
- POSDataElem = sr.POSdata[0];
- else
- {
- ServiceRequestPOSdataChangeFuelMode[] POSDataArray = null;
- DebugLog(string.Format("ChangeFuelModeAdd: new ServiceRequestPOSdataChangeFuelMode"));
- POSDataElem = new ServiceRequestPOSdataChangeFuelMode();
- ArrayResize(ref POSDataArray, 1);
- POSDataArray[POSDataArray.Length - 1] = POSDataElem;
- POSDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- sr.POSdata = POSDataArray;
- }
- ServiceRequestDeviceClassChangeFuelMode devicemode = null;
- if (POSDataElem.DeviceClass != null)
- {
- foreach (ServiceRequestDeviceClassChangeFuelMode devicemodeTemp in POSDataElem.DeviceClass)
- if (devicemodeTemp.DeviceID == Convert.ToString(pumpId) && devicemodeTemp.ModeNo == Convert.ToString(mode))
- {
- devicemode = devicemodeTemp;
- DebugLog(string.Format("ChangeFuelModeAdd: device/mode found"));
- }
- }
- if (devicemode == null)
- {
- DebugLog(string.Format("ChangeFuelModeAdd: new mode"));
- devicemode = new ServiceRequestDeviceClassChangeFuelMode();
- devicemode.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- devicemode.Type = DeviceType.DT_FuellingPoint;
- devicemode.FuelMode = new FuelModeElementClass();
- devicemode.FuelMode.ModeNo = Convert.ToString(mode);
- if (operationMode.HasValue)
- {
- devicemode.FuelMode.OperationModeSpecified = true;
- devicemode.FuelMode.OperationMode = (ushort)operationMode;
- }
- ServiceRequestDeviceClassChangeFuelMode[] devicemodeArray = POSDataElem.DeviceClass;
- ArrayResize(ref devicemodeArray, (devicemodeArray != null) ? devicemodeArray.Length + 1 : 1);
- DebugLog(string.Format("ChangeFuelModeAdd: resize devidemodeArray to '{0}' items", devicemodeArray.Length));
- devicemodeArray[devicemodeArray.Length - 1] = devicemode;
- POSDataElem.DeviceClass = devicemodeArray;
- }
- DebugLog("ChangeFuelModeAdd end");
- }
- public void ChangeFuelModeSend(ServiceRequestChangeFuelMode sr, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- DebugLog(string.Format("ChangeFuelModeSend init: sr.ApplicationSender={0}, sr.WorkstationID={1}", sr.ApplicationSender, sr.WorkstationID));
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- DebugLog(string.Format("ChangeFuelModeSend end: sr.ApplicationSender={0}, sr.WorkstationID={1}", sr.ApplicationSender, sr.WorkstationID));
- }
- private void ChangeFuelModeResp(int requestId, string sOverallResult, ServiceResponseFDCdataChangeFuelMode[] fdcData)
- {
- try
- {
- DebugLog(string.Format("ChangeFuelModeResp init, sOverallResult={0}", sOverallResult));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == FDCPOSLibrary.OverallResult.Success.ToString());
- if (fdcData[0] != null && fdcData[0].DeviceClass != null)
- {
- for (int i = 0; i < fdcData[0].DeviceClass.Length; i++)
- {
- if (fdcData[0].DeviceClass[i].ErrorCode != null && fdcData[0].DeviceClass[i].ErrorCode != ErrorCode.ERRCD_OK.ToString() && fdcData[0].DeviceClass[i].ErrorCode != ErrorCode.ERRCD_NO.ToString())
- {
- DebugLog(string.Format("ChangeFuelModeResp type={0}, id={1}, errorCode={2}", fdcData[0].DeviceClass[i].Type, fdcData[0].DeviceClass[i].DeviceID, fdcData[0].DeviceClass[i].ErrorCode));
- string deviceType = fdcData[0].DeviceClass[i].Type;
- int deviceId = Convert.ToInt16(fdcData[0].DeviceClass[i].DeviceID);
- int alarmId = -1;
- string alarmmsg = "Error " + fdcData[0].DeviceClass[i].ErrorCode + " changing fuel mode";
- OnDeviceAlarm.Fire(this, new DeviceAlarmEventArgs(deviceType, deviceId, alarmId, alarmmsg));
- }
- }
- }
- DebugLog("ChangeFuelModeResp end");
- }
- catch (Exception ex)
- {
- DebugLog("ChangeFuelModeResp Exception! " + ex);
- }
- }
- public void ChangeFuelPrice(int productId, Decimal price, int mode, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestChangeFuelPrice sr = new ServiceRequestChangeFuelPrice();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataChangeFuelPrice posDataElem = new ServiceRequestPOSdataChangeFuelPrice();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestProductChangeFuelPrice[] products = new ServiceRequestProductChangeFuelPrice[1];
- ServiceRequestProductChangeFuelPrice product = new ServiceRequestProductChangeFuelPrice();
- product.ProductNo = (productId == -1) ? "*" : Convert.ToString(productId);
- ServiceRequestFuelModeChangeFuelPrice[] fuelModes = new ServiceRequestFuelModeChangeFuelPrice[1];
- ServiceRequestFuelModeChangeFuelPrice fuelMode = new ServiceRequestFuelModeChangeFuelPrice();
- fuelMode.PriceNew = FDCConvert.ToString(price);
- fuelMode.ModeNo = Convert.ToString(mode);
- fuelModes[0] = fuelMode;
- product.FuelMode = fuelModes;
- products[0] = product;
- posDataElem.Product = products;
- ServiceRequestPOSdataChangeFuelPrice[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("ChangeFuelPrice Exception! " + ex);
- }
- }
- public void ChangeFuelPriceAdd(ServiceRequestChangeFuelPrice sr, int productId, Decimal price, int mode)
- {
-
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- DebugLog(string.Format("ChangeFuelPriceAdd init: sr.ApplicationSender={0}, sr.WorkstationID={1}, productId={2}, price={3}, mode={4}", sr.ApplicationSender, sr.WorkstationID, productId, price, mode));
- ServiceRequestPOSdataChangeFuelPrice POSDataElem;
- if (sr.POSdata != null)
- POSDataElem = sr.POSdata[0];
- else
- {
- ServiceRequestPOSdataChangeFuelPrice[] POSDataArray = null;
- DebugLog("ChangeFuelPriceAdd: new ServiceRequestPOSdataChangeFuelPrice");
- POSDataElem = new ServiceRequestPOSdataChangeFuelPrice();
- ArrayResize(ref POSDataArray, 1);
- POSDataArray[POSDataArray.Length - 1] = POSDataElem;
- POSDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- sr.POSdata = POSDataArray;
- }
- ServiceRequestProductChangeFuelPrice product = null;
- if (POSDataElem.Product != null)
- {
- foreach (ServiceRequestProductChangeFuelPrice productTemp in POSDataElem.Product)
- if (productTemp.ProductNo == Convert.ToString(productId) && productTemp.ModeNo == Convert.ToString(mode))
- {
- product = productTemp;
- DebugLog("ChangeFuelPriceAdd: product found");
- }
- }
- if (product == null && productId > 0)
- {
- DebugLog("ChangeFuelPriceAdd: new product");
- product = new ServiceRequestProductChangeFuelPrice();
- product.ProductNo = (productId == -1) ? "*" : Convert.ToString(productId);
- ServiceRequestProductChangeFuelPrice[] productArray = POSDataElem.Product;
- ArrayResize(ref productArray, (productArray != null) ? productArray.Length + 1 : 1);
- DebugLog(string.Format("ChangeFuelPriceAdd: resize product to '{0}' items", productArray.Length));
- productArray[productArray.Length - 1] = product;
- POSDataElem.Product = productArray;
- }
- ServiceRequestFuelModeChangeFuelPrice fuelMode = null;
- if (product.FuelMode != null)
- {
- foreach (ServiceRequestFuelModeChangeFuelPrice fuelModeTemp in product.FuelMode)
- if (product.ProductNo == Convert.ToString(productId) && fuelModeTemp.ModeNo == Convert.ToString(mode))
- {
- fuelMode = fuelModeTemp;
- DebugLog("ChangeFuelPriceAdd: fuelMode found");
- }
- }
- if (fuelMode == null && mode > 0)
- {
- fuelMode = new ServiceRequestFuelModeChangeFuelPrice();
- fuelMode.PriceNew = FDCConvert.ToString(price);
- fuelMode.ModeNo = Convert.ToString(mode);
- ServiceRequestFuelModeChangeFuelPrice[] fuelModeArray = product.FuelMode;
- ArrayResize(ref fuelModeArray, (fuelModeArray != null) ? fuelModeArray.Length + 1 : 1);
- DebugLog(string.Format("ChangeFuelPriceAdd: resize fuelMode to '{0}' items", fuelModeArray.Length));
- fuelModeArray[fuelModeArray.Length - 1] = fuelMode;
- product.FuelMode = fuelModeArray;
- }
- DebugLog(string.Format("ChangeFuelPriceAdd end: sr.ApplicationSender={0}, sr.WorkstationID={1}", sr.ApplicationSender, sr.WorkstationID));
- }
- public void ChangeFuelPriceSend(ServiceRequestChangeFuelPrice sr, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- DebugLog(string.Format("ChangeFuelPriceSend init: sr.ApplicationSender={0}, sr.WorkstationID={1}", sr.ApplicationSender, sr.WorkstationID));
- if (sr.POSdata == null)
- {
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- var posDataArray = new ServiceRequestPOSdataChangeFuelPrice[1];
- DebugLog("ChangeFuelPriceAdd: new ServiceRequestPOSdataChangeFuelPrice");
- var posDataElem = new ServiceRequestPOSdataChangeFuelPrice();
- posDataArray[0] = posDataElem;
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- sr.POSdata = posDataArray;
- }
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- DebugLog(string.Format("ChangeFuelPriceSend end: sr.ApplicationSender={0}, sr.WorkstationID={1}", sr.ApplicationSender, sr.WorkstationID));
- }
- public void CloseReconciliationPeriodAsyncSend(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- var sr = new ServiceRequestCloseReconciliationPeriod();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- var posDataElem = new ServiceRequestPOSdataCloseReconciliationPeriod();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataCloseReconciliationPeriod[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("CloseReconciliationPeriodAsyncSend Exception! " + ex);
- }
- }
- private void ChangeFuelPriceResp(int requestId, string sOverallResult, ServiceResponseFDCdataChangeFuelPrice[] fdcData)
- {
- try
- {
- DebugLog("ChangeFuelPriceResp init");
- string errorCode = (fdcData[0].FDCStatus != null) ? fdcData[0].FDCStatus : fdcData[0].ErrorCode;
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == FDCPOSLibrary.OverallResult.Success.ToString());
- DebugLog("ChangeFuelPriceResp end");
- }
- catch (Exception ex)
- {
- DebugLog("ChangeFuelPriceResp Exception! " + ex);
- }
- }
- private void CloseReconciliationPeriodResp(int requestId, string sOverallResult, ServiceResponseFDCdataCloseReconciliationPeriod[] fdcData)
- {
- try
- {
- DebugLog("CloseReconciliationPeriodResp init");
- if (fdcData != null)
- {
- string errorCode = fdcData[0].FDCStatus ?? fdcData[0].ErrorCode;
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- }
- else
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, false);
- }
- DebugLog("CloseReconciliationPeriodResp end");
- }
- catch (Exception ex)
- {
- DebugLog("CloseReconciliationPeriodResp Exception! " + ex);
- }
- }
- public void LockFuelSaleTrx(int pumpId, int transactionNo, int releaseToken, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
- ServiceRequestLockFuelSaleTrx sr = new ServiceRequestLockFuelSaleTrx();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataBaseFuelSaleTrx posDataElem = new ServiceRequestPOSdataBaseFuelSaleTrx();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassBaseFuelSaleTrx deviceClass = new ServiceRequestDeviceClassBaseFuelSaleTrx();
- deviceClass.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- deviceClass.TransactionSeqNo = Convert.ToString(transactionNo);
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataBaseFuelSaleTrx[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("LockFuelSaleTrx Exception! " + ex);
- }
- }
- private void LockFuelSaleTrxResp(int requestId, string sOverallResult, ServiceResponseLockFuelSaleTrx sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass.ErrorCode;
- DebugLog(string.Format("LockFuelSaleTrxResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass.Type, sr.FDCdata[0].DeviceClass.DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("LockFuelSaleTrxResp end");
- }
- catch (Exception ex)
- {
- DebugLog("LockFuelSaleTrxResp Exception! " + ex);
- }
- }
- public void UnlockFuelSaleTrx(int pumpId, int transactionNo, int releaseToken, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
- ServiceRequestUnlockFuelSaleTrx sr = new ServiceRequestUnlockFuelSaleTrx();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataBaseFuelSaleTrx posDataElem = new ServiceRequestPOSdataBaseFuelSaleTrx();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassBaseFuelSaleTrx deviceClass = new ServiceRequestDeviceClassBaseFuelSaleTrx();
- deviceClass.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- deviceClass.Type = Wayne.FDCPOSLibrary.DeviceType.DT_FuellingPoint;
- deviceClass.TransactionSeqNo = Convert.ToString(transactionNo);
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataBaseFuelSaleTrx[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("UnlockFuelSaleTrx Exception! " + ex);
- }
- }
- private void UnlockFuelSaleTrxResp(int requestId, string sOverallResult, ServiceResponseUnlockFuelSaleTrx sr)
- {
- try
- {
- string errorCode = (sr.FDCdata[0].FDCStatus != null) ? sr.FDCdata[0].FDCStatus : sr.FDCdata[0].DeviceClass.ErrorCode;
- DebugLog(string.Format("UnlockFuelSaleTrxResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass.Type, sr.FDCdata[0].DeviceClass.DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("UnlockFuelSaleTrxResp end");
- }
- catch (Exception ex)
- {
- DebugLog("UnlockFuelSaleTrxResp Exception! " + ex);
- }
- }
- public void ClearFuelSaleTrx(int pumpId, int transactionNo, int releaseToken, string note, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
- ServiceRequestClearFuelSaleTrx sr = new ServiceRequestClearFuelSaleTrx();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataClearFuelSaleTrx posDataElem = new ServiceRequestPOSdataClearFuelSaleTrx();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassClearFuelSaleTrx deviceClass = new ServiceRequestDeviceClassClearFuelSaleTrx();
- deviceClass.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- deviceClass.TransactionSeqNo = Convert.ToString(transactionNo);
-
-
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataClearFuelSaleTrx[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("ClearFuelSaleTrx Exception! " + ex);
- }
- }
- private void ClearFuelSaleTrxResp(int requestId, string sOverallResult, ServiceResponseClearFuelSaleTrx sr)
- {
- try
- {
- string errorCode = (sr.FDCdata[0].FDCStatus != null) ? sr.FDCdata[0].FDCStatus : sr.FDCdata[0].DeviceClass.ErrorCode;
- DebugLog(string.Format("ClearFuelSaleTrxResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass.Type, sr.FDCdata[0].DeviceClass.DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("ClearFuelSaleTrxResp end");
- }
- catch (Exception ex)
- {
- DebugLog("ClearFuelSaleTrxResp Exception! " + ex);
- }
- }
- public void SendConfig(string commandFileName, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- clientSocket.SendConfig(commandFileName);
- }
- public void GetAvailableFuelSaleTrxs(int pumpId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetAvailableFuelSaleTrxs sr = new ServiceRequestGetAvailableFuelSaleTrxs();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetAvailableFuelSaleTrxs posDataElem = new ServiceRequestPOSdataGetAvailableFuelSaleTrxs();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetAvailableFuelSaleTrxs[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetAvailableFuelSaleTrxs Exception! " + ex);
- }
- }
- private void GetAvailableFuelSaleTrxsResp(int requestId, string sOverallResult, ServiceResponseGetAvailableFuelSaleTrxs sr)
- {
- try
- {
- DebugLog("GetAvailableFuelSaleTrxsResp init");
- if (sr.FDCdata == null || sr.FDCdata[0].DeviceClass == null)
- {
- DebugLog("no fuel sale available - end");
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, true);
- return;
- }
- if (OnGetAvailableFuelSaleTrx != null && sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- {
- for (int i = 0; i < sr.FDCdata[0].DeviceClass.Length; i++)
- {
- if (sr.FDCdata[0].DeviceClass[i].ErrorCode != null && sr.FDCdata[0].DeviceClass[i].ErrorCode == ErrorCode.ERRCD_OK.ToString())
- {
- string deviceType = sr.FDCdata[0].DeviceClass[i].Type;
- int deviceId = Convert.ToInt16(sr.FDCdata[0].DeviceClass[i].DeviceID);
- int transactionNo = Convert.ToInt32(sr.FDCdata[0].DeviceClass[i].TransactionSeqNo);
- int releaseToken;
- try
- {
- releaseToken = Int32.Parse(sr.FDCdata[0].DeviceClass[i].ReleaseToken, System.Globalization.NumberStyles.HexNumber);
- }
- catch (Exception ex)
- {
- releaseToken = 0;
- }
- OnGetAvailableFuelSaleTrx(this, new FuelSaleTrxEventArgs(transactionNo, 0, 0, 0, deviceType, deviceId, 0, 0, 0, 0, 0,
- DateTime.Now, DateTime.Now, "", "", null, null, null, null, releaseToken, 0, FuellingType.Unknown));
- int timeout = 0;
- string sValue = IniFile.IniReadValue(ConfigurationParams.inifile, "FUSION-Connection", "GetFuelSaleTrxDetailTimeout");
- if (sValue.Length > 0)
- timeout = Convert.ToInt16(sValue);
- DebugLog(string.Format("GetFuelSaleTrxDetailTimeout={0}", timeout));
- Thread.Sleep(timeout);
- }
- else
- DebugLog(string.Format("Id={0} - Error={1}", sr.FDCdata[0].DeviceClass[i].DeviceID, sr.FDCdata[0].DeviceClass[i].ErrorCode));
- }
- }
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, true);
- DebugLog("GetAvailableFuelSaleTrxsResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetAvailableFuelSaleTrxsResp Exception! " + ex);
- }
- }
- public void GetFuelSaleTrxDetails(int pumpId, int transactionNo, int releaseToken, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
-
- try
- {
- ServiceRequestGetFuelSaleTrxDetails sr = new ServiceRequestGetFuelSaleTrxDetails();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetFuelSaleTrxDetails posDataElem = new ServiceRequestPOSdataGetFuelSaleTrxDetails();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassGetFuelSaleTrxDetails deviceClass = new ServiceRequestDeviceClassGetFuelSaleTrxDetails();
- deviceClass.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- deviceClass.Type = Wayne.FDCPOSLibrary.DeviceType.DT_FuellingPoint;
- deviceClass.TransactionSeqNo = (transactionNo == -1) ? "*" : Convert.ToString(transactionNo);
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetFuelSaleTrxDetails[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetFuelSaleTrxDetails Exception! " + ex);
- }
- }
- private void GetFuelSaleTrxDetailsResp(int requestId, string sOverallResult, ServiceResponseGetFuelSaleTrxDetails sr)
- {
- try
- {
- DebugLog("GetFuelSaleTrxDetailsResp init");
- if (sr.FDCdata == null || sr.FDCdata[0].DeviceClass == null)
- {
- DebugLog("no fuel sale details - end");
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, true);
- return;
- }
- if ((OnGetFuelSaleTrxDetails != null || OnFuelSaleTrx != null) && sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- {
- var serializer = new XmlSerializer(typeof(FDCMessageFuelSaleTrx));
- foreach (ServiceResponseDeviceClassGetFuelSaleTrxDetails deviceClass in sr.FDCdata[0].DeviceClass)
- {
- if (deviceClass.ErrorCode == ErrorCode.ERRCD_OK.ToString())
- {
- DebugLog(string.Format("type={0}, id={1}, nozzle={2}, price={3}, amount={4}, vol={5}, authAS={6}, lockAS={7}",
- deviceClass.Type, deviceClass.DeviceID,
- deviceClass.NozzleNo, deviceClass.UnitPrice, deviceClass.Amount, deviceClass.Volume,
- deviceClass.AuthorisationApplicationSender, deviceClass.LockingApplicationSender));
- string deviceType = deviceClass.Type;
- int deviceId = Convert.ToInt16(deviceClass.DeviceID);
- int nozzleId = Convert.ToInt16(deviceClass.NozzleNo);
- decimal volume = FDCConvert.ToDecimal(deviceClass.Volume);
- decimal amount = FDCConvert.ToDecimal(deviceClass.Amount);
- decimal price = FDCConvert.ToDecimal(deviceClass.UnitPrice);
- int transactionSeqNum = Convert.ToInt32(deviceClass.TransactionSeqNo);
-
- int fuellingSeqNum = string.IsNullOrEmpty(deviceClass.FuellingSequenceNo)
- ? transactionSeqNum
- : Convert.ToInt32(deviceClass.FuellingSequenceNo);
- Wayne.FDCPOSLibrary.FuellingState transactionState = convertFuellingState(deviceClass.State);
- int completionReason = 0;
- int fuelMode = (deviceClass.FuelMode != null && deviceClass.FuelMode.ModeNo != null && deviceClass.FuelMode.ModeNo != "") ? Convert.ToInt32(deviceClass.FuelMode.ModeNo) : 0;
- DateTime trxStartDateTime = Convert.ToDateTime(deviceClass.StartTimeStamp);
- DateTime trxEndDateTime = Convert.ToDateTime(deviceClass.EndTimeStamp);
- string authAS = deviceClass.AuthorisationApplicationSender;
- string lockingAS = deviceClass.LockingApplicationSender;
- string DSPFields = deviceClass.DSPFields;
- string CRCMode = deviceClass.CRCMode;
- string MIDLinesNarrow = deviceClass.MIDLinesNarrow;
- string MIDLinesWide = deviceClass.MIDLinesWide;
- FuellingType fuellingType = (deviceClass.FuellingType == "") ? FuellingType.Unknown : ((FuellingType)Convert.ToInt16(deviceClass.FuellingType));
- if (fuellingType == FuellingType.Unknown)
- {
- DebugLog("Fuelling of unkown type received. Converting to DetectedFromAccumulators!!!");
- fuellingType = FuellingType.DetectedFromAccumulators;
- }
- int releaseToken;
- try
- {
- IReleaseToken token = AuthReleaseTokenFactory.GenerateToken(deviceClass.ReleaseToken);
- releaseToken = token.AuthorizationId;
- }
- catch
- {
- releaseToken = 0;
- }
- byte reservingDeviceId;
- try
- {
- reservingDeviceId = Convert.ToByte(deviceClass.ReservingDeviceId);
- }
- catch (Exception ex)
- {
- reservingDeviceId = 0;
- }
- FDCMessageFDCdataFuelSaleTrx fdcData = new FDCMessageFDCdataFuelSaleTrx()
- {
- FDCTimeStamp = sr.FDCdata[0].FDCTimeStamp,
- DeviceClass = new FDCMessageDeviceClassFuelSaleTrx()
- {
- Amount = deviceClass.Amount,
- AuthorisationApplicationSender = deviceClass.AuthorisationApplicationSender,
- BlendRatio = deviceClass.BlendRatio,
- CompletionReason = "0",
- CRCMode = deviceClass.CRCMode,
- DeviceID = deviceClass.DeviceID,
- DSPFields = deviceClass.DSPFields,
- EndTimeStamp = deviceClass.EndTimeStamp,
- ErrorCode = deviceClass.ErrorCode,
- FuelPeriodSequenceNo = deviceClass.FuelPeriodSequenceNo,
- FuelMode = deviceClass.FuelMode,
- FuellingSequenceNo = deviceClass.FuellingSequenceNo,
- FuellingType = deviceClass.FuellingType,
- LockingApplicationSender = deviceClass.LockingApplicationSender,
- MIDLinesNarrow = deviceClass.MIDLinesNarrow,
- MIDLinesWide = deviceClass.MIDLinesWide,
- MaxTrxAmount = deviceClass.MaxTrxAmount,
- NozzleNo = deviceClass.NozzleNo,
- PrepaidTrx = deviceClass.PrepaidTrx,
- ProductName = deviceClass.ProductName,
- ProductNo = deviceClass.ProductNo,
- ProductNo1 = deviceClass.ProductNo1,
- ProductNo2 = deviceClass.ProductNo2,
- ProductUM = deviceClass.ProductUM,
- PumpNo = deviceClass.PumpNo,
- ReleaseToken = deviceClass.ReleaseToken,
- ReservingDeviceId = deviceClass.ReservingDeviceId,
- StartTimeStamp = deviceClass.StartTimeStamp,
- State = deviceClass.State,
- TransactionSeqNo = deviceClass.TransactionSeqNo,
- Type = deviceClass.Type,
- UnitPrice = deviceClass.UnitPrice,
- Volume = deviceClass.Volume,
- VolumeProduct1 = deviceClass.VolumeProduct1,
- VolumeProduct2 = deviceClass.VolumeProduct2,
- },
- };
- FDCMessageFuelSaleTrx fdcMessageFuelSaleTrx = new FDCMessageFuelSaleTrx()
- {
- MessageType = "FuelSaleTrx",
- ApplicationSender = sr.ApplicationSender,
- WorkstationID = sr.WorkstationID,
- MessageID = sr.RequestID,
- FDCdata = new FDCMessageFDCdataFuelSaleTrx[] { fdcData },
- };
- var builder = new StringBuilder();
- using (var writer = new StringWriter(builder))
- {
- serializer.Serialize(writer, fdcMessageFuelSaleTrx);
- }
- string derivedXml = builder.ToString();
- if (OnGetFuelSaleTrxDetails != null)
- {
- var eventPayload = new FuelSaleTrxEventArgs(
- transactionSeqNum,
- fuellingSeqNum,
- transactionState,
- completionReason,
- deviceType,
- deviceId,
- nozzleId,
- volume,
- amount,
- price,
- fuelMode,
- trxStartDateTime,
- trxEndDateTime,
- lockingAS,
- authAS,
- DSPFields,
- CRCMode,
- MIDLinesNarrow,
- MIDLinesWide,
- releaseToken,
- reservingDeviceId,
- fuellingType,
- derivedXml)
- {
- FuelPeriodSequenceNo = Convert.ToInt32(deviceClass.FuelPeriodSequenceNo)
- };
- OnGetFuelSaleTrxDetails(this, eventPayload);
- }
- if (OnFuelSaleTrx != null)
- {
- var eventPayload = new FuelSaleTrxEventArgs(
- transactionSeqNum,
- fuellingSeqNum,
- transactionState,
- completionReason,
- deviceType,
- deviceId,
- nozzleId,
- volume,
- amount,
- price,
- fuelMode,
- trxStartDateTime,
- trxEndDateTime,
- lockingAS,
- authAS,
- DSPFields,
- CRCMode,
- MIDLinesNarrow,
- MIDLinesWide,
- releaseToken,
- reservingDeviceId,
- fuellingType,
- derivedXml)
- {
- FuelPeriodSequenceNo = Convert.ToInt32(deviceClass.FuelPeriodSequenceNo)
- };
- OnFuelSaleTrx(this, eventPayload);
- }
- }
- else
- DebugLog("no fuel sale details anymore");
- }
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, true);
- }
- DebugLog("GetFuelSaleTrxDetailsResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetFuelSaleTrxDetailsResp Exception! " + ex);
- }
- }
- private void GetFuelSaleTrxDetailsResp(int requestId, string sOverallResult, ServiceResponseGetFuelSaleTrxDetailsV03 sr)
- {
- try
- {
- DebugLog("GetFuelSaleTrxDetailsRespV03 init");
- if (sr.FDCdata == null || sr.FDCdata[0].DeviceClass == null)
- {
- DebugLog("no fuel sale details - end");
- return;
- }
- if ((OnGetFuelSaleTrxDetails != null || OnFuelSaleTrx != null) && sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- {
- for (int i = 0; i < sr.FDCdata[0].DeviceClass.Length; i++)
- {
- DebugLog(string.Format("type={0}, id={1}, nozzle={2}, amount={3}, vol={4}",
- sr.FDCdata[0].DeviceClass[i].Type, sr.FDCdata[0].DeviceClass[i].DeviceID,
- sr.FDCdata[0].DeviceClass[i].NozzleNo, sr.FDCdata[0].DeviceClass[i].Amount, sr.FDCdata[0].DeviceClass[i].Volume));
- string deviceType = sr.FDCdata[0].DeviceClass[0].Type;
- int transactionSeqNum = Convert.ToInt32(sr.FDCdata[0].DeviceClass[i].TransactionNo);
- int deviceId = Convert.ToInt16(sr.FDCdata[0].DeviceClass[i].DeviceID);
- Wayne.FDCPOSLibrary.FuellingState transactionState = convertFuellingState(sr.FDCdata[0].DeviceClass[i].State);
- int completionReason = 0;
- int nozzleId = Convert.ToInt16(sr.FDCdata[0].DeviceClass[i].NozzleNo);
- decimal volume = FDCConvert.ToDecimal(sr.FDCdata[0].DeviceClass[i].Volume);
- decimal amount = FDCConvert.ToDecimal(sr.FDCdata[0].DeviceClass[i].Amount);
- decimal price = FDCConvert.ToDecimal(sr.FDCdata[0].DeviceClass[i].UnitPrice);
- int fuelMode = Convert.ToInt16(sr.FDCdata[0].DeviceClass[i].FuelMode);
- DateTime trxStartDateTime = Convert.ToDateTime(sr.FDCdata[0].DeviceClass[i].StartTimeStamp);
- DateTime trxEndDateTime = Convert.ToDateTime(sr.FDCdata[0].DeviceClass[i].EndTimeStamp);
- string lockingAS = "";
- string authAS = "";
- string DSPFields = sr.FDCdata[0].DeviceClass[i].DSPFields;
- string CRCMode = sr.FDCdata[0].DeviceClass[i].CRCMode;
- string MIDLinesNarrow = "";
- string MIDLinesWide = "";
- int authId;
- try
- {
- var token = AuthReleaseTokenFactory.GenerateToken(sr.FDCdata[0].DeviceClass[i].ReleaseToken);
- authId = token.AuthorizationId;
- }
- catch
- {
- authId = 0;
- }
- if (OnGetFuelSaleTrxDetails != null)
- OnGetFuelSaleTrxDetails(this, new FuelSaleTrxEventArgs(transactionSeqNum, 0, transactionState, completionReason, deviceType, deviceId, nozzleId, volume, amount, price, fuelMode, trxStartDateTime, trxEndDateTime, lockingAS, authAS, DSPFields, CRCMode, MIDLinesNarrow, MIDLinesWide, authId, 0, FuellingType.Unknown));
- if (OnFuelSaleTrx != null)
- OnFuelSaleTrx(this, new FuelSaleTrxEventArgs(transactionSeqNum, 0, transactionState, completionReason, deviceType, deviceId, nozzleId, volume, amount, price, fuelMode, trxStartDateTime, trxEndDateTime, lockingAS, authAS, DSPFields, CRCMode, MIDLinesNarrow, MIDLinesWide, authId, 0, FuellingType.Unknown));
- }
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, true);
- }
- DebugLog("GetFuelSaleTrxDetailsResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetFuelSaleTrxDetailsResp Exception! " + ex);
- }
- }
- public void GetProductTable(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetProductTable sr = new ServiceRequestGetProductTable();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetProductTable posDataElem = new ServiceRequestPOSdataGetProductTable();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataGetProductTable[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetProductTable Exception! " + ex);
- }
- }
- private void GetProductTableResp(int requestId, string sOverallResult, ServiceResponseGetProductTable sr)
- {
- try
- {
- DebugLog("GetProductTableResp init");
- if (sr == null || (sr.OverallResult != OverallResult.Success.ToString() && sr.OverallResult != "") ||
- sr.FDCdata == null || sr.FDCdata.Length == 0 ||
- sr.FDCdata[0].FuelProducts == null || sr.FDCdata[0].FuelProducts.Length == 0 ||
- sr.FDCdata[0].FuelProducts[0].Product == null || sr.FDCdata[0].FuelProducts[0].Product.Length == 0)
- {
- DebugLog("error in ServiceResponseGetProductTable");
- }
-
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, true, sr);
- DebugLog("GetProductTableResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetProductTableResp Exception! " + ex);
- }
- }
- public void GetModeTable(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetModeTable sr = new ServiceRequestGetModeTable();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetModeTable posDataElem = new ServiceRequestPOSdataGetModeTable();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataGetModeTable[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetModeTable Exception! " + ex);
- }
- }
- private void GetModeTableResp(int requestId, string sOverallResult, ServiceResponseGetModeTable sr)
- {
- try
- {
- DebugLog("GetModeTableResp init");
- DebugLog("GetModeTableResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetModeTableResp Exception! " + ex);
- }
- }
- public void GetFuelMode(int pumpId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetFuelMode srV07 = new ServiceRequestGetFuelMode();
- ServiceRequestGetFPFuelMode sr = new ServiceRequestGetFPFuelMode();
- srV07.ApplicationSender = this.clientSocket.applicationSender;
- srV07.WorkstationID = this.clientSocket.workstationID;
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetFuelMode posDataElem = new ServiceRequestPOSdataGetFuelMode();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = (pumpId == -1) ? "*" : Convert.ToString(pumpId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetFuelMode[] posDataArray = { posDataElem };
- srV07.POSdata = posDataArray;
- sr.POSdata = posDataArray;
- if (FDCGlobal.ProtocolVersion <= FDCVersion.V0007)
- clientSocket.ifsfMessages.EnqueueMessage(srV07, requestCompleted, userToken, src, true, 30000);
- else
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetFuelMode Exception! " + ex);
- }
- }
- private void GetFuelModeResp(int requestId, string sOverallResult, ServiceResponseFDCdataGetFuelMode[] fdcData)
- {
- try
- {
- DebugLog("GetFuelModeResp init");
- if (fdcData == null || fdcData[0].DeviceClass == null)
- {
- DebugLog("no device available - end");
- return;
- }
-
- if (OnFuelModeChange != null)
- {
- string deviceType = fdcData[0].DeviceClass[0].Type;
- int deviceId = Convert.ToInt16(fdcData[0].DeviceClass[0].DeviceID);
- int mode = 0;
- if (fdcData[0].DeviceClass[0].FuelMode.ModeNo != null)
- mode = Convert.ToInt16(fdcData[0].DeviceClass[0].FuelMode.ModeNo);
- else
- mode = Convert.ToInt16(fdcData[0].DeviceClass[0].ModeNo);
- DebugLog("Trigger FuelModeChanged");
- OnFuelModeChange.Fire(this, new FuelModeChangedEventArgs(deviceType, deviceId, mode));
- }
- if (OnOperationModeChange != null)
- {
- var deviceType = fdcData[0].DeviceClass[0].Type;
- int deviceId = Convert.ToInt16(fdcData[0].DeviceClass[0].DeviceID);
- if (fdcData[0].DeviceClass[0].FuelMode.OperationModeSpecified)
- {
- var mode = Convert.ToUInt16(fdcData[0].DeviceClass[0].FuelMode.OperationMode);
- DebugLog("Trigger OperationModeChanged");
- OnOperationModeChange.Fire(this, new OperationModeChangedEventArgs(deviceType, deviceId, mode));
- }
- }
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString());
- DebugLog("GetFuelModeResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetFuelModeResp Exception! " + ex);
- }
- }
- public void GetConfiguration(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetConfiguration sr = new ServiceRequestGetConfiguration();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetConfiguration posDataElem = new ServiceRequestPOSdataGetConfiguration();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataGetConfiguration[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetConfiguration Exception! " + ex);
- }
- }
- private void GetConfigurationResp(int requestId, string sOverallResult, ServiceResponseGetConfiguration sr)
- {
- try
- {
- DebugLog("GetConfigurationResp init: INVALID FOR V7 !");
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == "Success", sr);
- DebugLog("GetConfigurationResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetConfigurationResp Exception! " + ex);
- }
- }
- public void GetDSPConfiguration(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetDSPConfiguration sr = new ServiceRequestGetDSPConfiguration();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetConfiguration posDataElem = new ServiceRequestPOSdataGetConfiguration();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataGetConfiguration[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetDSPConfiguration Exception! " + ex);
- }
- }
- private void GetDSPConfigurationResp(int requestId, string sOverallResult, ServiceResponseGetDSPConfiguration sr)
- {
- try
- {
- DebugLog("GetDSPConfigurationResp init");
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId,
- sOverallResult == FDCPOSLibrary.OverallResult.Success.ToString(), sr);
- DebugLog("GetDSPConfigurationResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetDSPConfigurationResp Exception! " + ex);
- }
- }
- public void GetTLGConfiguration(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetTLGConfiguration sr = new ServiceRequestGetTLGConfiguration();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetConfiguration posDataElem = new ServiceRequestPOSdataGetConfiguration();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataGetConfiguration[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetTLGConfiguration Exception! " + ex);
- }
- }
- private void GetTLGConfigurationResp(int requestId, string sOverallResult, ServiceResponseGetTLGConfiguration sr)
- {
- try
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString(), sr);
- DebugLog("GetTLGConfigurationResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetTLGConfigurationResp Exception! " + ex);
- }
- }
- private void SetConfigurationResp(int requestId, string sOverallResult, ServiceResponseSetConfiguration sr)
- {
- try
- {
- DebugLog("SetConfigurationResp init");
- DebugLog("SetConfigurationResp end");
- }
- catch (Exception ex)
- {
- DebugLog("SetConfigurationResp Exception! " + ex);
- }
- }
- public void LockNozzle(int deviceId, int nozzleNo, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestLockNozzle sr = new ServiceRequestLockNozzle();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataLockNozzle posDataElem = new ServiceRequestPOSdataLockNozzle();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassLockNozzle deviceClass = new ServiceRequestDeviceClassLockNozzle();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- deviceClass.NozzleNo = (nozzleNo == -1) ? "*" : Convert.ToString(nozzleNo);
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataLockNozzle[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("LockNozzle Exception! " + ex);
- }
- }
- private void LockNozzleResp(int requestId, string sOverallResult, ServiceResponseLockNozzle sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass.ErrorCode;
- DebugLog(string.Format("LockNozzleResp type={0}, id={1}, nozzleNo={2}, errorCode={3}", sr.FDCdata[0].DeviceClass.Type, sr.FDCdata[0].DeviceClass.DeviceID, sr.FDCdata[0].DeviceClass.NozzleNo, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == FDCPOSLibrary.OverallResult.Success.ToString());
- DebugLog(string.Format("LockNozzleResp end"));
- }
- catch (Exception ex)
- {
- DebugLog("LockNozzleResp Exception! " + ex);
- }
- }
- public void UnlockNozzle(int deviceId, int nozzleNo, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestUnlockNozzle sr = new ServiceRequestUnlockNozzle();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataUnlockNozzle posDataElem = new ServiceRequestPOSdataUnlockNozzle();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassUnlockNozzle deviceClass = new ServiceRequestDeviceClassUnlockNozzle();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = Wayne.FDCPOSLibrary.DeviceType.DT_FuellingPoint;
- deviceClass.NozzleNo = (nozzleNo == -1) ? "*" : Convert.ToString(nozzleNo);
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataUnlockNozzle[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("UnlockNozzle Exception! " + ex);
- }
- }
- private void UnlockNozzleResp(int requestId, string sOverallResult, ServiceResponseUnlockNozzle sr)
- {
- try
- {
- string errorCode = (sr.FDCdata[0].FDCStatus != null) ? sr.FDCdata[0].FDCStatus : sr.FDCdata[0].DeviceClass.ErrorCode;
- DebugLog(string.Format("UnlockNozzleResp type={0}, id={1}, nozzleNo={2}, errorCode{3}", sr.FDCdata[0].DeviceClass.Type, sr.FDCdata[0].DeviceClass.DeviceID, sr.FDCdata[0].DeviceClass.NozzleNo, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("UnlockNozzleResp end");
- }
- catch (Exception ex)
- {
- DebugLog("UnlockNozzleResp Exception! " + ex);
- }
- }
- public void GetCountrySettings(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetCountrySettings sr = new ServiceRequestGetCountrySettings();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetCountrySettings posDataElem = new ServiceRequestPOSdataGetCountrySettings();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestPOSdataGetCountrySettings[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetCountrySettings Exception! " + ex);
- }
- }
- private void GetCountrySettingsResp(int requestId, string sOverallResult, ServiceResponseGetCountrySettings sr)
- {
- try
- {
- DebugLog("GetCountrySettingsResp init");
- if (sr.FDCdata[0].DecimalSign != null)
- FDCConvert.DecimalSeparator = sr.FDCdata[0].DecimalSign;
- if (sr.FDCdata[0].ThousandDelimiter != null)
- FDCConvert.ThousandSeparator = sr.FDCdata[0].ThousandDelimiter;
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, true, sr);
- this.clientSocket.mainConnectionState = DeviceConnectionState.Connected;
- DebugLog(string.Format("GetCountrySettingsResp end: DecimalSeparator={0}, ThousandSeparator={1}, connectionState={2}", FDCConvert.DecimalSeparator, FDCConvert.ThousandSeparator, this.clientSocket.mainConnectionState));
- }
- catch (Exception ex)
- {
- DebugLog("GetCountrySettingsResp Exception! " + ex);
- }
- }
- public void GetDSPLimits(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetDSPLimits sr = new ServiceRequestGetDSPLimits();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetDSPLimits posDataElem = new ServiceRequestPOSdataGetDSPLimits();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = (deviceId == -1) ? "*" : Convert.ToString(deviceId);
- deviceClass.Type = Wayne.FDCPOSLibrary.DeviceType.DT_FuelDispenser;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetDSPLimits[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetDSPLimits Exception! " + ex);
- }
- }
- private void GetDSPLimitsResp(int requestId, string sOverallResult, ServiceResponseGetDSPLimits sr)
- {
- try
- {
- if (sr.FDCdata[0] != null && sr.FDCdata[0].DeviceClass != null)
- for (int i = 0; i < sr.FDCdata[0].DeviceClass.Length; i++)
- {
- DebugLog(string.Format("GetDSPLimitsResp type={0}, id={1}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[i].DeviceID));
- }
- DebugLog("GetDSPLimitsResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetDSPLimitsResp Exception! " + ex);
- }
- }
- public void ChangeDSPLimits(int deviceId, int productNo, int modeNo, double maxTrxAmount, double maxTrxVolume, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestChangeDSPLimits sr = new ServiceRequestChangeDSPLimits();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataChangeDSPLimits posDataElem = new ServiceRequestPOSdataChangeDSPLimits();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassChangeDSPLimits deviceClass = new ServiceRequestDeviceClassChangeDSPLimits();
- deviceClass.DeviceID = (deviceId == -1) ? "*" : Convert.ToString(deviceId);
- deviceClass.Type = Wayne.FDCPOSLibrary.DeviceType.DT_FuelDispenser;
- deviceClass.ProductNo = Convert.ToString(productNo);
- deviceClass.ModeNo = Convert.ToString(modeNo);
- System.Globalization.NumberFormatInfo provider = new System.Globalization.NumberFormatInfo();
- provider.NumberDecimalSeparator = System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
- provider.NumberGroupSeparator = System.Globalization.NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
- provider.NumberGroupSizes = System.Globalization.NumberFormatInfo.CurrentInfo.NumberGroupSizes;
- deviceClass.MaxTrxAmount = string.Format(provider, "{0:F2}", maxTrxAmount);
- provider.NumberDecimalDigits = 3;
- deviceClass.MaxTrxVolume = string.Format(provider, "{0:F3}", maxTrxVolume);
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataChangeDSPLimits[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("ChangeDSPLimits Exception! " + ex);
- }
- }
- private void ChangeDSPLimitsResp(int requestId, string sOverallResult, ServiceResponseChangeDSPLimits sr)
- {
- try
- {
- DebugLog("ChangeDSPLimitsResp init");
- DebugLog("ChangeDSPLimitsResp end");
- }
- catch (Exception ex)
- {
- DebugLog("ChangeDSPLimitsResp Exception! " + ex);
- }
- }
- public void SuspendFuelling(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestSuspendFuelling sr = new ServiceRequestSuspendFuelling();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataSuspendFuelling posDataElem = new ServiceRequestPOSdataSuspendFuelling();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataSuspendFuelling[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("SuspendFuelling Exception! " + ex);
- }
- }
- private void SuspendFuellingResp(int requestId, string sOverallResult, ServiceResponseSuspendFuelling sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass[0].ErrorCode;
- DebugLog(string.Format("SuspendFuellingResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[0].DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("SuspendFuellingResp end");
- }
- catch (Exception ex)
- {
- DebugLog("SuspendFuellingResp Exception! " + ex);
- }
- }
- public void ResumeFuelling(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestResumeFuelling sr = new ServiceRequestResumeFuelling();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataResumeFuelling posDataElem = new ServiceRequestPOSdataResumeFuelling();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataResumeFuelling[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("ResumeFuelling Exception! " + ex);
- }
- }
- private void ResumeFuellingResp(int requestId, string sOverallResult, ServiceResponseResumeFuelling sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass[0].ErrorCode;
- DebugLog(string.Format("ResumeFuellingResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[0].DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("ResumeFuellingResp end");
- }
- catch (Exception ex)
- {
- DebugLog("ResumeFuellingResp Exception! " + ex);
- }
- }
- public void StopFuelPoint(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestStopFuelPoint sr = new ServiceRequestStopFuelPoint();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataStopFuelPoint posDataElem = new ServiceRequestPOSdataStopFuelPoint();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- deviceClass.CreateZeroSale = Convert.ToString(false);
-
- if (src is FUSIONPump)
- {
- FUSIONPump p = (FUSIONPump)src;
- if (p.State == PumpState.Fuelling)
- deviceClass.CreateZeroSale = Convert.ToString(true);
- }
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataStopFuelPoint[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("StopFuelPoint Exception! " + ex);
- }
- }
- private void StopFuelPointResp(int requestId, string sOverallResult, ServiceResponseStopFuelPoint sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass[0].ErrorCode;
- DebugLog(string.Format("StopFuelPointResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[0].DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("StopFuelPointResp end");
- }
- catch (Exception ex)
- {
- DebugLog("StopFuelPointResp Exception! " + ex);
- }
- }
- public void StartFuelPoint(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestStartFuelPoint sr = new ServiceRequestStartFuelPoint();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataStartFuelPoint posDataElem = new ServiceRequestPOSdataStartFuelPoint();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataStartFuelPoint[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("StartFuelPoint Exception! " + ex);
- }
- }
- private void StartFuelPointResp(int requestId, string sOverallResult, ServiceResponseStartFuelPoint sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass[0].ErrorCode;
- DebugLog(string.Format("StartFuelPointResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[0].DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("StartFuelPointResp end");
- }
- catch (Exception ex)
- {
- DebugLog("StartFuelPointResp Exception! " + ex);
- }
- }
- public void LockTank(int deviceId, int tankNo, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestLockTank sr = new ServiceRequestLockTank();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataLockTank posDataElem = new ServiceRequestPOSdataLockTank();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassLockTank deviceClass = new ServiceRequestDeviceClassLockTank();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.TankNo = Convert.ToString(tankNo);
- deviceClass.Type = DeviceType.DT_TankProbe;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataLockTank[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("LockTank Exception! " + ex);
- }
- }
- private void LockTankResp(int requestId, string sOverallResult, ServiceResponseLockTank sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass[0].ErrorCode;
- DebugLog(string.Format("LockTankResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[0].DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("LockTankResp end");
- }
- catch (Exception ex)
- {
- DebugLog("LockTankResp Exception! " + ex);
- }
- }
- public void UnlockTank(int deviceId, int tankNo, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestUnlockTank sr = new ServiceRequestUnlockTank();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataUnlockTank posDataElem = new ServiceRequestPOSdataUnlockTank();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassUnlockTank deviceClass = new ServiceRequestDeviceClassUnlockTank();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.TankNo = Convert.ToString(tankNo);
- deviceClass.Type = Wayne.FDCPOSLibrary.DeviceType.DT_TankProbe;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataUnlockTank[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("UnlockTank Exception! " + ex);
- }
- }
- private void UnlockTankResp(int requestId, string sOverallResult, ServiceResponseUnlockTank sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass[0].ErrorCode;
- DebugLog(string.Format("UnlockTankResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass[0].Type, sr.FDCdata[0].DeviceClass[0].DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("UnlockTankResp end");
- }
- catch (Exception ex)
- {
- DebugLog("UnlockTankResp Exception! " + ex);
- }
- }
- public void GetTankData(int deviceId, int tankNo, EventHandler<AsyncCompletedEventArgs<ITankReadingEx>> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetTankData sr = new ServiceRequestGetTankData();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetTankData posDataElem = new ServiceRequestPOSdataGetTankData();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassGetTankData deviceClass = new ServiceRequestDeviceClassGetTankData();
- deviceClass.DeviceID = (deviceId == -1) ? "*" : Convert.ToString(deviceId);
-
- deviceClass.Type = DeviceType.DT_TankProbe;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetTankData[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- EventHandler<AsyncCompletedEventArgs> proxy = (sender, e) => requestCompleted(sender, (AsyncCompletedEventArgs<ITankReadingEx>)e);
- clientSocket.ifsfMessages.EnqueueMessage(sr, proxy, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetTankData Exception! " + ex);
- }
- }
- private void GetTankDataResp(int requestId, string sOverallResult, ServiceResponseGetTankData sr, string originalXml)
- {
- try
- {
- ServiceResponseDeviceClassGetTankData tankdata = sr.FDCdata[0].DeviceClass[0];
- DebugLog(string.Format("GetTankDataResp init: tank={0}, date={1}", tankdata.TankNo, sr.FDCdata[0].FDCTimeStamp));
- DateTime date;
- try
- {
- date = Convert.ToDateTime(sr.FDCdata[0].FDCTimeStamp);
- }
- catch (Exception ex)
- {
- DebugLog("GetTankDataResp: Exception! " + ex);
- DebugLog("GetTankDataResp: set datetime to now");
- date = DateTime.Now;
- }
- string errorCode = sr.FDCdata[0].FDCStatus ?? tankdata.ErrorCode;
- ProbeState probeState = (errorCode != ErrorCode.ERRCD_OK.ToString()) ||
- tankdata.DeviceState != null && convertLogicalDeviceState(tankdata.DeviceState) != LogicalDeviceState.FDC_READY ? ProbeState.Failed : ProbeState.Ok;
- FUSIONTankReading tankreading;
- if (probeState == ProbeState.Ok)
- {
- tankreading = new FUSIONTankReading(Convert.ToInt32(tankdata.TankNo),
- probeState,
- date,
- FDCConvert.ToDecimal(
- tankdata.MeasurementData.ProductLevel) / 1000,
- FDCConvert.ToDecimal(
- tankdata.MeasurementData
- .TotalObservedVolume),
- 0,
- FDCConvert.ToDecimal(
- tankdata.MeasurementData.WaterLevel) / 1000,
- FDCConvert.ToDecimal(
- tankdata.MeasurementData.WaterVolume),
- FDCConvert.ToDecimal(
- tankdata.MeasurementData.AverageTemp),
- UnitOfMeasure.Liters,
- UnitOfMeasure.Liters,
- false,
- originalXml);
- DebugLog(string.Format("GetTankDataResp data received: tank={0}, state={1}, fuelLevel={2}, fuelVolume={3}, waterLevel={4}, waterVolume={5}, temperature={6}",
- tankdata.TankNo, tankdata.MeasurementData.TPStatus,
- tankdata.MeasurementData.ProductLevel,
- tankdata.MeasurementData.TotalObservedVolume,
- tankdata.MeasurementData.WaterLevel,
- tankdata.MeasurementData.WaterVolume,
- tankdata.MeasurementData.AverageTemp));
- }
- else
- {
- tankreading = new FUSIONTankReading(Convert.ToInt32(tankdata.TankNo),
- probeState,
- date,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- UnitOfMeasure.Liters,
- UnitOfMeasure.Liters,
- false,
- originalXml);
- DebugLog(string.Format("GetTankDataResp data received: tank={0}, probestate={1}",
- tankdata.TankNo, probeState));
- }
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString(), (ITankReadingEx)tankreading);
- DebugLog("GetTankDataResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetTankDataResp Exception! " + ex);
- }
- }
- public void GetTankReconciliation(int deviceId, EventHandler<AsyncCompletedEventArgs<ITankReconciliation>> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetTankReconciliation sr = new ServiceRequestGetTankReconciliation();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetTankReconciliation posDataElem = new ServiceRequestPOSdataGetTankReconciliation();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassGetTankReconciliation deviceClass = new ServiceRequestDeviceClassGetTankReconciliation();
- deviceClass.DeviceID = deviceId.ToString();
- deviceClass.Type = DeviceType.DT_TankProbe;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetTankReconciliation[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- EventHandler<AsyncCompletedEventArgs> proxy = (sender, e) => requestCompleted(sender, (AsyncCompletedEventArgs<ITankReconciliation>)e);
- clientSocket.ifsfMessages.EnqueueMessage(sr, proxy, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetTankReconciliation Exception! " + ex);
- }
- }
- private void GetTankReconciliationResp(int requestId, string sOverallResult, ServiceResponseGetTankReconciliation sr, string originalXml)
- {
- try
- {
- DebugLog("GetTankReconciliation init");
- var tankReconciliation = new TankReconciliation(originalXml);
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString(), (ITankReconciliation)tankReconciliation);
- DebugLog("GetTank ReconciliationResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetTankReconciliation Exception! " + ex);
- }
- }
- public void GetTankDelivery(int deviceId, EventHandler<AsyncCompletedEventArgs<ITankDelivery>> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestGetTankDelivery sr = new ServiceRequestGetTankDelivery();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataGetTankDelivery posDataElem = new ServiceRequestPOSdataGetTankDelivery();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassGetTankDelivery deviceClass = new ServiceRequestDeviceClassGetTankDelivery();
- deviceClass.DeviceID = deviceId.ToString();
- deviceClass.Type = DeviceType.DT_TankProbe;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetTankDelivery[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- EventHandler<AsyncCompletedEventArgs> proxy = (sender, e) => requestCompleted(sender, (AsyncCompletedEventArgs<ITankDelivery>)e);
- clientSocket.ifsfMessages.EnqueueMessage(sr, proxy, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetTankDelivery Exception! " + ex);
- }
- }
- private void GetTankDeliveryResp(int requestId, string sOverallResult, ServiceResponseGetTankDelivery sr, string originalXml)
- {
- try
- {
- DebugLog("GetTankDelivery init");
- var tankDelivery = new TankDelivery(originalXml);
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString(), (ITankDelivery)tankDelivery);
- DebugLog("GetTankDeliveryResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetTankDelivery Exception! " + ex);
- }
- }
- public void GetPumpTotals(ServiceRequestDeviceClassGetFuelPointTotals deviceClass, EventHandler<AsyncCompletedEventArgs<PumpAccumulatorReading>> requestCompleted, object userToken, object src)
- {
- try
- {
-
- DebugLog("Request all pump totals from Fusion");
- var sr = new ServiceRequestGetFuelPointTotals();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- var posDataElem = new ServiceRequestPOSdataGetFuelPointTotals();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataGetFuelPointTotals[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- EventHandler<AsyncCompletedEventArgs> completed = (sender, e) => requestCompleted(sender, (AsyncCompletedEventArgs<PumpAccumulatorReading>)e);
- clientSocket.ifsfMessages.EnqueueMessage(sr, completed, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetFuelPrices Exception! " + ex);
- }
- }
- public void GetFuelPrices(EventHandler<AsyncCompletedEventArgs<IList<IFuelPriceReading>>> requestCompleted, object userToken, object src)
- {
- try
- {
-
- DebugLog("Request all prices from Fusion");
- var sr = new ServiceRequestGetFuelPrices();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- var posDataElem = new ServiceRequestPOSdataGetFuelPrices();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- var product = new ServiceRequestProductGetFuelPrices();
- product.ProductNo = "*";
- var products = new ServiceRequestProductGetFuelPrices[] { product };
- posDataElem.Product = products;
- ServiceRequestPOSdataGetFuelPrices[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- EventHandler<AsyncCompletedEventArgs> completed = (sender, e) => requestCompleted(sender, (AsyncCompletedEventArgs<IList<IFuelPriceReading>>)e);
- clientSocket.ifsfMessages.EnqueueMessage(sr, completed, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("GetFuelPrices Exception! " + ex);
- }
- }
- private void GetFuelPricesResp(int requestId, string sOverallResult, ServiceResponseGetFuelPrices sr)
- {
- try
- {
- DebugLog("GetFuelPriceResp: init");
- var fuelPriceReadings = new List<IFuelPriceReading>();
- if (sr.FDCdata != null && sr.FDCdata[0].Prices != null && sr.FDCdata[0].Prices.Length > 0)
- {
- DebugLog("GetFuelPriceResp: Prices received from Fusion");
- foreach (var product in sr.FDCdata[0].Prices)
- {
- if (product.FuelPrice != null && product.FuelPrice.Length > 0)
- {
- foreach (var mode in product.FuelPrice)
- {
- int productNo = Convert.ToInt32(product.ProductNo);
- decimal price = FDCConvert.ToDecimal(mode.Price);
- string fuelName = product.ProductName;
- var priceGroup = manager.forecourtControl.ForecourtConfiguration.GetPriceGroup(Convert.ToInt32(mode.ModeNo), FuellingType.OptCardPaid);
- if (string.IsNullOrEmpty(fuelName))
- fuelName = string.Empty;
- DebugLog(string.Format("GetFuelPricesResp: Grade={0}, PriceGroup={1} , Price={2} , FuelName={3}",
- productNo, priceGroup, price, fuelName));
- fuelPriceReadings.Add(new FuelPriceReading(productNo, priceGroup, price, fuelName));
- }
- }
- }
- }
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString(), (IList<IFuelPriceReading>)fuelPriceReadings);
- DebugLog("GetFuelPricesResp end");
- }
- catch (Exception ex)
- {
- DebugLog("GetFuelPricesResp Exception! " + ex);
- }
- }
- public void ReserveFuelPoint(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestReserveFuelPoint sr = new ServiceRequestReserveFuelPoint();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataReserveFuelPoint posDataElem = new ServiceRequestPOSdataReserveFuelPoint();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataReserveFuelPoint[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("ReserveFuelPoint Exception! " + ex);
- }
- }
- private void ReserveFuelPointResp(int requestId, string sOverallResult, ServiceResponseReserveFuelPoint sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass.ErrorCode;
- DebugLog(string.Format("ReserveFuelPointResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass.Type, sr.FDCdata[0].DeviceClass.DeviceID, errorCode));
- if ((errorCode == ErrorCode.ERRCD_OK.ToString()) && (sOverallResult == OverallResult.Success.ToString()))
- {
-
- DebugLog(string.Format("Waiting for unsolicited FPStateChange, RequestId={0}.", requestId));
- unsolicitedFPStateChangeDictionary[Convert.ToInt16(sr.FDCdata[0].DeviceClass.DeviceID)] = requestId;
- }
- else
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, false);
- DebugLog("ReserveFuelPointResp end");
- }
- }
- catch (Exception ex)
- {
- DebugLog("ReserveFuelPointResp Exception! " + ex);
- }
- }
- public void FreeFuelPoint(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestFreeFuelPoint sr = new ServiceRequestFreeFuelPoint();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataFreeFuelPoint posDataElem = new ServiceRequestPOSdataFreeFuelPoint();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = Wayne.FDCPOSLibrary.DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataFreeFuelPoint[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("FreeFuelPoint Exception! " + ex);
- }
- }
- public void StartFuelPointTest(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestStartFuelPointTest sr = new ServiceRequestStartFuelPointTest();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataStartFuelPointTest posDataElem = new ServiceRequestPOSdataStartFuelPointTest();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataStartFuelPointTest[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("StartFuelPointTest Exception! " + ex);
- }
- }
- public void EndFuelPointTest(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestEndFuelPointTest sr = new ServiceRequestEndFuelPointTest();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataEndFuelPointTest posDataElem = new ServiceRequestPOSdataEndFuelPointTest();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataEndFuelPointTest[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("EndFuelPointTest Exception! " + ex);
- }
- }
- public void OpenFuelPoint(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestOpenFuelPoint sr = new ServiceRequestOpenFuelPoint();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataOpenFuelPoint posDataElem = new ServiceRequestPOSdataOpenFuelPoint();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataOpenFuelPoint[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("OpenFuelPoint Exception! " + ex);
- }
- }
- public void OpenDevice(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestOpenDevice sr = new ServiceRequestOpenDevice();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataOpenFuelPoint posDataElem = new ServiceRequestPOSdataOpenFuelPoint();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataOpenFuelPoint[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("Exception! " + ex);
- }
- }
- public void CloseFuelPoint(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestCloseFuelPoint sr = new ServiceRequestCloseFuelPoint();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataCloseFuelPoint posDataElem = new ServiceRequestPOSdataCloseFuelPoint();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = Wayne.FDCPOSLibrary.DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataCloseFuelPoint[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("CloseFuelPoint Exception! " + ex);
- }
- }
- public void CloseDevice(int deviceId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestCloseDevice sr = new ServiceRequestCloseDevice();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataCloseFuelPoint posDataElem = new ServiceRequestPOSdataCloseFuelPoint();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClass deviceClass = new ServiceRequestDeviceClass();
- deviceClass.DeviceID = Convert.ToString(deviceId);
- deviceClass.Type = DeviceType.DT_FuellingPoint;
- posDataElem.DeviceClass = deviceClass;
- ServiceRequestPOSdataCloseFuelPoint[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("CloseDevice Exception! " + ex);
- }
- }
- public void SetDeviceAlarm(string deviceType, int deviceId, IEnumerable<int> alarmCodes, IEnumerable<string> alarmMsgs, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
- var alarms = new List<ServiceRequestDeviceAlarmMsg>();
- if (alarmCodes != null && alarmMsgs != null)
- {
- if (alarmCodes.Count() == alarmMsgs.Count())
- {
- for (int i = 0; i < alarmCodes.Count(); i++)
- {
- var alarmElem = new ServiceRequestDeviceAlarmMsg
- {
- Number = Convert.ToString(alarmCodes.ElementAt(i)),
- Text = alarmMsgs.ElementAt(i)
- };
- alarms.Add(alarmElem);
- }
- }
- else
- {
- foreach (var alarmCode in alarmCodes)
- {
- var alarmElem = new ServiceRequestDeviceAlarmMsg
- {
- Number = Convert.ToString(alarmCode),
- Text = alarmMsgs.First()
- };
- alarms.Add(alarmElem);
- }
- }
- }
- var deviceClass = new ServiceRequestDeviceClassSetDeviceAlarm
- {
- DeviceID = Convert.ToString(deviceId),
- Type = deviceType,
- AlarmMsg = alarms.ToArray()
- };
- var posDataElem = new ServiceRequestPOSdataSetDeviceAlarm
- {
- POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat),
- DeviceClass = deviceClass
- };
-
- var sr = new ServiceRequestSetDeviceAlarm
- {
- ApplicationSender = this.clientSocket.applicationSender,
- WorkstationID = this.clientSocket.workstationID,
- POSdata = new[] { posDataElem }
- };
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("SetDeviceAlarm Exception! " + ex);
- }
- }
- public void SetDeviceAlarm(string deviceType, int deviceId, int alarmCode, string alarmMsg, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- SetDeviceAlarm(deviceType, deviceId, new[] { alarmCode }, new[] { alarmMsg }, requestCompleted, userToken, src);
- }
- private void FreeFuelPointResp(int requestId, string sOverallResult, ServiceResponseFreeFuelPoint sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass.ErrorCode;
- DebugLog(string.Format("FreeFuelPointResp type={0}, id={1}, errorCode={2}", sr.FDCdata[0].DeviceClass.Type, sr.FDCdata[0].DeviceClass.DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- }
- catch (Exception ex)
- {
- DebugLog("FreeFuelPointResp Exception! " + ex);
- }
- }
- private void StartFuelPointTestResp(int requestId, string sOverallResult, ServiceResponseStartFuelPointTest sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass.ErrorCode;
- DebugLog(string.Format("StartFuelPointTestResp type={0}, id={1}, errorCode{2}", sr.FDCdata[0].DeviceClass.Type, sr.FDCdata[0].DeviceClass.DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("StartFuelPointTestResp end");
- }
- catch (Exception ex)
- {
- DebugLog("StartFuelPointTestResp Exception! " + ex);
- }
- }
- private void EndFuelPointTestResp(int requestId, string sOverallResult, ServiceResponseEndFuelPointTest sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass.ErrorCode;
- DebugLog(string.Format("EndFuelPointTestResp type={0}, id={1}, errorCode{2}", sr.FDCdata[0].DeviceClass.Type, sr.FDCdata[0].DeviceClass.DeviceID, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("EndFuelPointTestResp end");
- }
- catch (Exception ex)
- {
- DebugLog("EndFuelPointTestResp Exception! " + ex);
- }
- }
- private void OpenFuelPointResp(int requestId, string sOverallResult, ServiceResponseOpenFuelPoint sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus;
- DebugLog(string.Format("OpenFuelPointResp requestId={0}, errorCode={1}", requestId, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("OpenFuelPointResp end");
- }
- catch (Exception ex)
- {
- DebugLog("OpenFuelPointResp Exception! " + ex);
- }
- }
- private void CloseFuelPointResp(int requestId, string sOverallResult, ServiceResponseCloseFuelPoint sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus;
- DebugLog(string.Format("CloseFuelPointResp requestId={0}, errorCode={1}", requestId, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("CloseFuelPointResp end");
- }
- catch (Exception ex)
- {
- DebugLog("CloseFuelPointResp Exception! " + ex);
- }
- }
- private void OpenDeviceResp(int requestId, string sOverallResult, ServiceResponseOpenDevice sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass[0].ErrorCode;
- DebugLog(string.Format("OpenDeviceResp requestId={0}, errorCode={1}", requestId, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("OpenDeviceResp end");
- }
- catch (Exception ex)
- {
- DebugLog("OpenDeviceResp Exception! " + ex);
- }
- }
- private void CloseDeviceResp(int requestId, string sOverallResult, ServiceResponseCloseDevice sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus ?? sr.FDCdata[0].DeviceClass[0].ErrorCode;
- DebugLog(string.Format("CloseDeviceResp requestId={0}, errorCode={1}", requestId, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("CloseDeviceResp end");
- }
- catch (Exception ex)
- {
- DebugLog("CloseDeviceResp Exception! " + ex);
- }
- }
- private void SetDeviceAlarmResp(int requestId, string sOverallResult, ServiceResponseSetDeviceAlarm sr)
- {
- try
- {
- string errorCode = sr.FDCdata[0].FDCStatus;
- DebugLog(string.Format("SetDeviceAlarmResp requestId={0}, errorCode={1}", requestId, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString() && sOverallResult == OverallResult.Success.ToString());
- DebugLog("SetDeviceAlarmResp end");
- }
- catch (Exception ex)
- {
- DebugLog("SetDeviceAlarmResp Exception! " + ex);
- }
- }
- public void OptAddSerialPort(int optId, string port, int baudRate, int dataBit, int stopBit, int parity, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
- DebugLog(string.Format("OptAddSerialPort init: tp={0}, port={1}", optId, port));
-
- ServiceRequestOPTAdd sr = new ServiceRequestOPTAdd();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataOPTAdd posDataElem = new ServiceRequestPOSdataOPTAdd();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassOPTAdd optadd = new ServiceRequestDeviceClassOPTAdd();
- optadd.DeviceID = (optId == -1) ? "*" : Convert.ToString(optId);
- optadd.Type = DeviceType.DT_OutdoorPaymentTerminal;
- ServiceRequestDeviceClassSerialPortOPTAdd serialPort = new ServiceRequestDeviceClassSerialPortOPTAdd();
- serialPort.Port = port;
- serialPort.BaudRate = Convert.ToString(baudRate);
- serialPort.DataBit = Convert.ToString(dataBit);
- serialPort.StopBit = Convert.ToString(stopBit);
- serialPort.Parity = Convert.ToString(parity);
- optadd.serialPort = serialPort;
- posDataElem.DeviceClass = optadd;
- ServiceRequestPOSdataOPTAdd[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- DebugLog(string.Format("OptAddSerialPort end: tp={0}, port={1}", optId, port));
- }
- catch (Exception ex)
- {
- DebugLog("OptAddSerialPort Exception! " + ex);
- }
- }
- public void OptAddTCP(int optId, string address, int port, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestOPTAdd sr = new ServiceRequestOPTAdd();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataOPTAdd posDataElem = new ServiceRequestPOSdataOPTAdd();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassOPTAdd optadd = new ServiceRequestDeviceClassOPTAdd();
- optadd.DeviceID = (optId == -1) ? "*" : Convert.ToString(optId);
- optadd.Type = Wayne.FDCPOSLibrary.DeviceType.DT_OutdoorPaymentTerminal;
- ServiceRequestDeviceClassTCPOPTAdd tcp = new ServiceRequestDeviceClassTCPOPTAdd();
- tcp.Address = address;
- tcp.Port = Convert.ToString(port);
- optadd.tcp = tcp;
- posDataElem.DeviceClass = optadd;
- ServiceRequestPOSdataOPTAdd[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("OptAddTCP Exception! " + ex);
- }
- }
- private void OptAddResp(int requestId, string sOverallResult, ServiceResponseOPTAdd sr)
- {
- try
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString());
- }
- catch (Exception ex)
- {
- DebugLog("OptAddResp Exception! " + ex);
- }
- }
- public void OptRemove(int optId, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- ServiceRequestOPTRemove sr = new ServiceRequestOPTRemove();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataOPTRemove posDataElem = new ServiceRequestPOSdataOPTRemove();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassOPTRemove optRemove = new ServiceRequestDeviceClassOPTRemove();
- optRemove.DeviceID = (optId == -1) ? "*" : Convert.ToString(optId);
- optRemove.Type = DeviceType.DT_OutdoorPaymentTerminal;
- posDataElem.DeviceClass = optRemove;
- ServiceRequestPOSdataOPTRemove[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- clientSocket.ifsfMessages.EnqueueMessage(sr, requestCompleted, userToken, src, true, 30000);
- }
- catch (Exception ex)
- {
- DebugLog("OptRemove Exception! " + ex);
- }
- }
- private void OptRemoveResp(int requestId, string sOverallResult, ServiceResponseOPTRemove sr)
- {
- try
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString());
- }
- catch (Exception ex)
- {
- DebugLog("OptRemoveResp Exception! " + ex);
- }
- }
- public void OptWrite(int optId, byte[] message, EventHandler<OptWriteCompletedEventArgs> requestCompleted, object userToken, object src)
- {
- try
- {
-
- if (FDCGlobal.ProtocolVersion <= FDCVersion.V0007)
- {
- ServiceRequestOPTWriteV07 sr = new ServiceRequestOPTWriteV07();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataOPTWriteV07 posDataElem = new ServiceRequestPOSdataOPTWriteV07();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassOPTWriteV07 optwrite = new ServiceRequestDeviceClassOPTWriteV07();
- optwrite.DeviceID = (optId == -1) ? "*" : Convert.ToString(optId);
- optwrite.Type = DeviceType.DT_OutdoorPaymentTerminal;
- optwrite.Message = message;
- posDataElem.DeviceClass = optwrite;
- ServiceRequestPOSdataOPTWriteV07[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- EventHandler<AsyncCompletedEventArgs> proxy = (sender, e) => requestCompleted(sender, (OptWriteCompletedEventArgs)e);
- clientSocket.ifsfMessages.EnqueueMessage(sr, proxy, userToken, src, true, 30000);
- }
- else
- {
- ServiceRequestOPTWrite sr = new ServiceRequestOPTWrite();
- sr.ApplicationSender = this.clientSocket.applicationSender;
- sr.WorkstationID = this.clientSocket.workstationID;
- ServiceRequestPOSdataOPTWrite posDataElem = new ServiceRequestPOSdataOPTWrite();
- posDataElem.POSTimeStamp = DateTime.Now.ToString(FDCConvert.DateFormat);
- ServiceRequestDeviceClassOPTWrite optwrite = new ServiceRequestDeviceClassOPTWrite();
- optwrite.DeviceID = (optId == -1) ? "*" : Convert.ToString(optId);
- optwrite.Type = DeviceType.DT_OutdoorPaymentTerminal;
- optwrite.Message = Encoding.UTF8.GetString(message, 0, message.GetLength(0)); ;
- posDataElem.DeviceClass = optwrite;
- ServiceRequestPOSdataOPTWrite[] posDataArray = { posDataElem };
- sr.POSdata = posDataArray;
- EventHandler<AsyncCompletedEventArgs> proxy = (sender, e) => requestCompleted(sender, (OptWriteCompletedEventArgs)e);
- clientSocket.ifsfMessages.EnqueueMessage(sr, proxy, userToken, src, true, 30000);
- }
- }
- catch (Exception ex)
- {
- DebugLog("OptWrite Exception! " + ex);
- }
- }
- private void OptWriteResp(int requestId, string sOverallResult, ServiceResponseOPTWrite sr)
- {
- try
- {
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, sOverallResult == OverallResult.Success.ToString());
- }
- catch (Exception ex)
- {
- DebugLog("OptWriteResp Exception! " + ex);
- }
- }
- private void HeartbeatMsg()
- {
- try
- {
-
- DebugLog("Heartbeat message received");
- heartbeat.ResetDisconnectionTimeout();
- }
- catch (Exception ex)
- {
- DebugLog("HeartbeatMsg Exception! " + ex);
- }
- }
- private void DeviceStateChangeMsg(FDCMessageDeviceStateChange msg)
- {
- try
- {
- DebugLog(string.Format("DeviceStateChangeMsg init: type={0}, id={1}, state={2}, substate={3}", msg.FDCdata[0].DeviceClass[0].Type, msg.FDCdata[0].DeviceClass[0].DeviceID, msg.FDCdata[0].DeviceClass[0].LogicalState, msg.FDCdata[0].DeviceClass[0].LogicalSubState));
- if (OnDeviceStateChange != null)
- {
- string deviceType = msg.FDCdata[0].DeviceClass[0].Type;
- int deviceId = Convert.ToInt16(msg.FDCdata[0].DeviceClass[0].DeviceID);
- LogicalDeviceState state = convertLogicalDeviceState(msg.FDCdata[0].DeviceClass[0].LogicalState);
- LogicalDeviceState substate = convertLogicalDeviceState(msg.FDCdata[0].DeviceClass[0].LogicalSubState);
- int nozzleUp = 0;
- if (msg.FDCdata[0].DeviceClass[0].Nozzle != null)
- {
- foreach (NozzleStateClass nozzleState in msg.FDCdata[0].DeviceClass[0].Nozzle)
- {
- if (nozzleState.LogicalNozzle == "NozzleUp")
- nozzleUp = Convert.ToInt32(nozzleState.NozzleNo);
- }
- }
- OnDeviceStateChange.Invoke(this, new DeviceStateChangedEventArgs(deviceType, deviceId, state, substate, "", nozzleUp));
- }
- DebugLog("DeviceStateChangeMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("DeviceStateChangeMsg Exception! " + ex);
- }
- }
- private void FPStateChangeMsg(FDCMessageFPStateChange msg)
- {
- try
- {
- DebugLog(string.Format("FPStateChangeMsg: type={0}, id={1}, state={2}, substate={3}", msg.FDCdata[0].DeviceClass[0].Type, msg.FDCdata[0].DeviceClass[0].DeviceID, msg.FDCdata[0].DeviceClass[0].DeviceState, msg.FDCdata[0].DeviceClass[0].DeviceSubState));
- int deviceId = Convert.ToInt16(msg.FDCdata[0].DeviceClass[0].DeviceID);
- int requestId;
- if (unsolicitedFPStateChangeDictionary.TryGetValue(deviceId, out requestId))
- {
- string errorCode = msg.FDCdata[0].DeviceClass[0].ErrorCode;
- DebugLog(string.Format("Got unsolicited FPStateChange mapped to RequestId={0}, ErrorCode={1}", requestId, errorCode));
- clientSocket.ifsfMessages.asyncResponseManager.SendResponse(requestId, errorCode == ErrorCode.ERRCD_OK.ToString());
- unsolicitedFPStateChangeDictionary.Remove(deviceId);
- }
- if (OnDeviceStateChange != null)
- {
- string deviceType = msg.FDCdata[0].DeviceClass[0].Type;
- LogicalDeviceState state = convertLogicalDeviceState(msg.FDCdata[0].DeviceClass[0].DeviceState.DeviceState);
- LogicalDeviceState substate = convertLogicalDeviceState(msg.FDCdata[0].DeviceClass[0].DeviceSubState);
- if (!string.IsNullOrEmpty(msg.FDCdata[0].DeviceClass[0].DeviceState.Stopped) && XmlConvert.ToBoolean(msg.FDCdata[0].DeviceClass[0].DeviceState.Stopped))
- substate = LogicalDeviceState.FDC_STOPPED;
- string lockingAS = msg.FDCdata[0].DeviceClass[0].LockingApplicationSender;
- int nozzleUp = 0;
- if (msg.FDCdata[0].DeviceClass[0].Nozzle != null)
- {
- foreach (NozzleStateClass nozzleState in msg.FDCdata[0].DeviceClass[0].Nozzle)
- {
- if (nozzleState.LogicalNozzle == "NozzleUp")
- nozzleUp = Convert.ToInt32(nozzleState.NozzleNo);
- }
- }
- OnDeviceStateChange.Invoke(this, new DeviceStateChangedEventArgs(deviceType, deviceId, state, substate, lockingAS, nozzleUp));
- }
- DebugLog("FPStateChangeMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("FPStateChangeMsg Exception! " + ex);
- }
- }
- private void TPStateChangeMsg(FDCMessageTPStateChange msg)
- {
- try
- {
- DebugLog(string.Format("TPStateChangeMsg init: type={0}, id={1}, state={2}", msg.FDCdata[0].DeviceClass[0].Type, msg.FDCdata[0].DeviceClass[0].DeviceID, msg.FDCdata[0].DeviceClass[0].DeviceState));
- if (OnDeviceStateChange != null)
- {
- string deviceType = msg.FDCdata[0].DeviceClass[0].Type;
- int deviceId = Convert.ToInt16(msg.FDCdata[0].DeviceClass[0].DeviceID);
- LogicalDeviceState state = convertLogicalDeviceState(msg.FDCdata[0].DeviceClass[0].DeviceState.DeviceState);
- OnDeviceStateChange.Invoke(this, new DeviceStateChangedEventArgs(deviceType, deviceId, state, LogicalDeviceState.FDC_UNDEFINED, "", 0));
- }
- DebugLog("TPStateChangeMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("TPStateChangeMsg Exception! " + ex);
- }
- }
- private void VIRStateChangeMsg(FDCMessageVIRStateChange msg)
- {
- try
- {
- DebugLog(string.Format("VIRStateChangeMsg init: type={0}, id={1}, state={2}, substate={3}", msg.FDCdata[0].DeviceClass[0].Type, msg.FDCdata[0].DeviceClass[0].DeviceID, msg.FDCdata[0].DeviceClass[0].DeviceState, msg.FDCdata[0].DeviceClass[0].DeviceSubState));
- if (OnVirStateChange != null)
- {
- int deviceId = Convert.ToInt16(msg.FDCdata[0].DeviceClass[0].DeviceID);
- if (msg.FDCdata[0].DeviceClass[0].Vir != null)
- {
- foreach (VIRStateClass virState in msg.FDCdata[0].DeviceClass[0].Vir)
- {
- var state = convertLogicalDeviceState(virState.DeviceState);
- DeviceConnectionState deviceState;
- if (state == LogicalDeviceState.FDC_READY)
- deviceState = DeviceConnectionState.Connected;
- else if (state == LogicalDeviceState.FDC_OFFLINE)
- deviceState = DeviceConnectionState.Disconnected;
- else
- deviceState = DeviceConnectionState.Unknown;
- DebugLog(string.Format("VIRStateChangeMsg: type={0}, id={1}, virID={2}, virstate={3}", msg.FDCdata[0].DeviceClass[0].Type, msg.FDCdata[0].DeviceClass[0].DeviceID, virState.VirID, virState.DeviceState));
- OnVirStateChange(this, new VIRStateChangedEventArgs(deviceId, virState.VirID, deviceState));
- }
- }
- }
- else
- DebugLog("OnVirStateChange == null");
- DebugLog("VIRStateChangeMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("VIRStateChangeMsg Exception! " + ex);
- }
- }
- private void FDCStoppedMsg(FDCMessageStopped msg)
- {
- try
- {
- DebugLog("FDCStoppedMsg init");
- this.clientSocket.mainConnectionState = DeviceConnectionState.Connecting;
- DebugLog("FDCStoppedMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("FDCStoppedMsg Exception! " + ex);
- }
- }
- private void FDCStartedMsg(FDCMessageStarted msg)
- {
- try
- {
- DebugLog("FDCStartedMsg init");
- DebugLog("FDCStartedMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("FDCStartedMsg Exception! " + ex);
- }
- }
- private void TwinMasterReadyMsg(FDCMessageTwinMasterIsOn msg)
- {
- try
- {
- DebugLog("TwinMasterReadyMsg init");
- if (OnTwinMasterReady != null)
- OnTwinMasterReady(this, null);
- DebugLog("TwinMasterReadyMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("TwinMasterReadyMsg Exception! " + ex);
- }
- }
- private void CurrentFuellingStatusMsg(FDCMessageCurrentFuellingStatus msg)
- {
- try
- {
- DebugLog(string.Format("CurrentFuellingStatusMsg init: type={0}, id={1}, volume={2}, amount={3}", msg.FDCdata[0].DeviceClass[0].Type, msg.FDCdata[0].DeviceClass[0].DeviceID, msg.FDCdata[0].DeviceClass[0].CurrentVolume, msg.FDCdata[0].DeviceClass[0].CurrentAmount));
- if (OnCurrentFuellingStatus != null)
- {
- var deviceClass = msg.FDCdata[0].DeviceClass[0];
- string deviceType = deviceClass.Type;
- int deviceId = Convert.ToInt16(deviceClass.DeviceID);
- int nozzleId;
- nozzleId = Convert.ToInt16(deviceClass.CurrentNozzleNo);
- if (nozzleId == 0)
- nozzleId = Convert.ToInt16(deviceClass.NozzleNo);
- Decimal volume;
- volume = FDCConvert.ToDecimal(deviceClass.CurrentVolume);
- if (volume == 0)
- volume = FDCConvert.ToDecimal(deviceClass.Volume);
- Decimal amount;
- amount = FDCConvert.ToDecimal(deviceClass.CurrentAmount);
- if (amount == 0)
- amount = FDCConvert.ToDecimal(deviceClass.Amount);
- Decimal price;
- price = FDCConvert.ToDecimal(deviceClass.CurrentUnitPrice);
- if (price == 0)
- price = FDCConvert.ToDecimal(deviceClass.UnitPrice);
- int releaseId;
- int reservingDeviceId;
- try
- {
- var token = AuthReleaseTokenFactory.GenerateToken(deviceClass.ReleaseToken);
- releaseId = token.AuthorizationId;
- reservingDeviceId = token.TerminalId;
- }
- catch
- {
- releaseId = 0;
- reservingDeviceId = 0;
- }
- var eventArgs = new CurrentFuellingStatusEventArgs(deviceType, deviceId, nozzleId, volume, amount,
- price, "")
- {
- ReleaseId = releaseId,
- ReservingDeviceId = reservingDeviceId,
- TransactionId = Convert.ToInt32(deviceClass.TransactionSeqNo),
- FuelPeriodSequenceNo = Convert.ToInt32(deviceClass.FuelPeriodSequenceNo)
- };
- OnCurrentFuellingStatus(this, eventArgs);
- }
- DebugLog("CurrentFuellingStatusMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("CurrentFuellingStatusMsg Exception! " + ex);
- }
- }
- private void DeviceAlarmMsg(FDCMessageDeviceAlarm msg)
- {
- try
- {
- DebugLog(string.Format("DeviceAlarmMsg init: type={0}, id={1}", msg.FDCdata[0].DeviceClass[0].Type, msg.FDCdata[0].DeviceClass[0].DeviceID));
- foreach (FDCMessageDeviceAlarmDeviceClass device in msg.FDCdata[0].DeviceClass)
- {
- var deviceType = device.Type;
- int deviceId = Convert.ToInt16(device.DeviceID);
- if (device.AlarmMsg != null && device.AlarmMsg.Length > 0)
- {
- foreach (FDCMessageDeviceAlarmMsg alarmmsg in device.AlarmMsg)
- {
- if (OnDeviceAlarm != null)
- {
- int alarmId = Convert.ToInt32(alarmmsg.Number);
- OnDeviceAlarm(this, new DeviceAlarmEventArgs(deviceType, deviceId, alarmId, alarmmsg.Text));
- }
- }
- }
- else if (deviceType == "TP")
- {
- if (OnDeviceAlarm != null)
- {
- OnDeviceAlarm(this, new DeviceAlarmEventArgs(deviceType, deviceId, 0, ""));
- }
- }
- }
- DebugLog("DeviceAlarmMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("DeviceAlarmMsg Exception! " + ex);
- }
- }
- private void FuelSaleTrxMsg(FDCMessageFuelSaleTrx msg, string originalMessageXml)
- {
- try
- {
- DebugLog("FuelSaleTrxMsg init");
- if (msg != null && msg.FDCdata != null && msg.FDCdata[0] != null && msg.FDCdata[0].DeviceClass != null)
- {
- FDCMessageDeviceClassFuelSaleTrx deviceClass = msg.FDCdata[0].DeviceClass;
- if (OnFuelSaleTrx != null)
- {
- DebugLog(string.Format("FuelSaleTrxMsg type={0}, id={1}, nozzle={2}, price={3}, amount={4}, vol={5}, authAS={6}, lockAS={7}",
- deviceClass.Type, deviceClass.DeviceID,
- deviceClass.NozzleNo, deviceClass.UnitPrice, deviceClass.Amount, deviceClass.Volume,
- deviceClass.AuthorisationApplicationSender, deviceClass.LockingApplicationSender));
- string deviceType = deviceClass.Type;
- int deviceId = Convert.ToInt16(deviceClass.DeviceID);
- int nozzleId = Convert.ToInt16(deviceClass.NozzleNo);
- Decimal volume = FDCConvert.ToDecimal(deviceClass.Volume);
- Decimal amount = FDCConvert.ToDecimal(deviceClass.Amount);
- Decimal price = FDCConvert.ToDecimal(deviceClass.UnitPrice);
- int transactionSeqNum = Convert.ToInt32(deviceClass.TransactionSeqNo);
-
- int fuellingSeqNum = string.IsNullOrEmpty(deviceClass.FuellingSequenceNo)
- ? transactionSeqNum
- : Convert.ToInt32(deviceClass.FuellingSequenceNo);
- Wayne.FDCPOSLibrary.FuellingState transactionState = convertFuellingState(deviceClass.State);
- int completionReason = string.IsNullOrEmpty(deviceClass.CompletionReason) ? 0 : convertCompletionReason(deviceClass.CompletionReason);
- int fuelMode = (deviceClass.FuelMode != null && deviceClass.FuelMode.ModeNo != null && deviceClass.FuelMode.ModeNo != "") ? Convert.ToInt32(deviceClass.FuelMode.ModeNo) : 0;
- DateTime trxStartDateTime = Convert.ToDateTime(deviceClass.StartTimeStamp);
- DateTime trxEndDateTime = Convert.ToDateTime(deviceClass.EndTimeStamp);
- string authAS = deviceClass.AuthorisationApplicationSender;
- string lockingAS = deviceClass.LockingApplicationSender;
- string DSPFields = deviceClass.DSPFields;
- string CRCMode = deviceClass.CRCMode;
- string MIDLinesNarrow = deviceClass.MIDLinesNarrow;
- string MIDLinesWide = deviceClass.MIDLinesWide;
- FuellingType fuellingType = (deviceClass.FuellingType == "") ? FuellingType.Unknown : ((FuellingType)Convert.ToInt16(deviceClass.FuellingType));
- if (fuellingType == FuellingType.Unknown)
- {
- DebugLog("Fuelling of unkown type received. Converting to DetectedFromAccumulators!!!");
- fuellingType = FuellingType.DetectedFromAccumulators;
- }
- int releaseToken;
- try
- {
- IReleaseToken token = AuthReleaseTokenFactory.GenerateToken(deviceClass.ReleaseToken);
- releaseToken = token.AuthorizationId;
- }
- catch
- {
- releaseToken = 0;
- }
- byte reservingDeviceId;
- try
- {
- reservingDeviceId = Convert.ToByte(deviceClass.ReservingDeviceId);
- }
- catch (Exception ex)
- {
- reservingDeviceId = 0;
- DebugLog("FuelSaleTrxMsg Exception! cannot convert ReservingDeviceId to Int32");
- }
- var eventPayload = new FuelSaleTrxEventArgs(
- transactionSeqNum,
- fuellingSeqNum,
- transactionState,
- completionReason,
- deviceType,
- deviceId,
- nozzleId,
- volume,
- amount,
- price,
- fuelMode,
- trxStartDateTime,
- trxEndDateTime,
- lockingAS,
- authAS,
- DSPFields,
- CRCMode,
- MIDLinesNarrow,
- MIDLinesWide,
- releaseToken,
- reservingDeviceId,
- fuellingType,
- originalMessageXml)
- {
- FuelPeriodSequenceNo = Convert.ToInt32(deviceClass.FuelPeriodSequenceNo)
- };
- OnFuelSaleTrx(this, eventPayload);
- }
- else
- DebugLog("FuelSaleTrxMsg OnFuelSaleTrx == null");
- }
- else
- {
- if (msg == null)
- DebugLog("FuelSaleTrxMsg msg == null");
- else if (msg.FDCdata == null)
- DebugLog("FuelSaleTrxMsg msg.FDCdata == null");
- else if (msg.FDCdata[0] == null)
- DebugLog("FuelSaleTrxMsg msg.FDCdata[0] == null");
- else if (msg.FDCdata[0].DeviceClass == null)
- DebugLog("FuelSaleTrxMsg msg.FDCdata[0].DeviceClass == null");
- }
- DebugLog("FuelSaleTrxMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("FuelSaleTrxMsg Exception! " + ex);
- }
- }
- private void FuelPriceChangeMsg(FDCMessageFuelPriceChange msg)
- {
- try
- {
- DebugLog(string.Format("FuelPriceChangeMsg init: product={0}, modeno={1}, newprice={2}, oldprice={3}",
- msg.FDCdata[0].Product[0].ProductNo,
- msg.FDCdata[0].Product[0].FuelMode.ModeNo,
- msg.FDCdata[0].Product[0].FuelMode.NewPrice,
- msg.FDCdata[0].Product[0].FuelMode.OldPrice));
- if (OnChangeFuelPrice != null)
- {
- OnChangeFuelPrice(this, new ChangeFuelPriceEventArgs(Convert.ToInt32(msg.FDCdata[0].Product[0].ProductNo), Convert.ToInt32(msg.FDCdata[0].Product[0].FuelMode.ModeNo),
- FDCConvert.ToDecimal(msg.FDCdata[0].Product[0].FuelMode.OldPrice), FDCConvert.ToDecimal(msg.FDCdata[0].Product[0].FuelMode.NewPrice)));
- }
- DebugLog("FuelPriceChangeMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("FuelPriceChangeMsg Exception! " + ex);
- }
- }
- private void FuelModeChangeMsg(FDCMessageFDCdataFuelModeChange fdcData)
- {
- try
- {
- DebugLog("FuelModeChangeMsg init");
- foreach (FDCMessageDeviceClassFuelModeChange device in fdcData.DeviceClass)
- {
- if (OnFuelModeChange != null)
- {
- string deviceType = fdcData.DeviceClass[0].Type;
- int deviceId = Convert.ToInt16(fdcData.DeviceClass[0].DeviceID);
- int mode;
- if (fdcData.DeviceClass[0].FuelMode.ModeNo != null)
- mode = Convert.ToInt16(fdcData.DeviceClass[0].FuelMode.ModeNo);
- else
- mode = Convert.ToInt16(fdcData.DeviceClass[0].ModeNo);
- OnFuelModeChange(this, new FuelModeChangedEventArgs(deviceType, deviceId, mode));
- }
- if (OnOperationModeChange != null)
- {
-
- if (fdcData.DeviceClass[0].FuelMode != null && fdcData.DeviceClass[0].FuelMode.OperationModeSpecified)
- {
- OnOperationModeChange.Fire(this,
- new OperationModeChangedEventArgs(fdcData.DeviceClass[0].Type,
- Convert.ToInt16(fdcData.DeviceClass[0].DeviceID), fdcData.DeviceClass[0].FuelMode.OperationMode));
- }
- }
- }
- DebugLog("FuelModeChangeMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("FuelModeChangeMsg Exception! " + ex);
- }
- }
- private void FDCExceptionMsg(FDCMessageFDCExceptionMsg msg)
- {
- try
- {
- DebugLog("FDCExceptionMsg init");
- DebugLog("FDCExceptionMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("FDCExceptionMsg Exception! " + ex);
- }
- }
- private void FDCMessageConfigurationChangeMsg(FDCMessageConfigurationChange msg)
- {
- try
- {
- DebugLog("FDCMessageConfigurationChangeMsg init");
- OnConfigurationChange.Invoke(this, null);
- DebugLog("FDCMessageConfigurationChangeMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("FDCMessageConfigurationChangeMsg Exception! " + ex);
- }
- }
- private void OptReadMsg(FDCMessageOPTRead msg)
- {
- try
- {
- DebugLog("OptReadMsg init");
- foreach (FDCMessageDeviceClassOPTRead optdata in msg.FDCdata[0].DeviceClass)
- {
- if (OnOptRead != null)
- {
- string deviceType = optdata.Type;
- byte[] databytes = ASCIIEncoding.ASCII.GetBytes(optdata.Message); ;
- DebugLog(string.Format("type={0}, id={1}, msg={2}", optdata.Type, optdata.DeviceID, optdata.Message));
- int deviceId = Convert.ToInt16(optdata.DeviceID);
- OnOptRead(this, new OptReadEventArgs(deviceType, deviceId, databytes));
- }
- }
- DebugLog("OptReadMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("OptReadMsg Exception! " + ex);
- }
- }
- private void OptReadMsg(FDCMessageOPTReadV07 msg)
- {
- try
- {
- DebugLog("OptReadMsg init");
- foreach (FDCMessageDeviceClassOPTReadV07 optdata in msg.FDCdata[0].DeviceClass)
- {
- if (OnOptRead != null)
- {
- string deviceType = optdata.Type;
- ASCIIEncoding encoding = new ASCIIEncoding();
- DebugLog(string.Format("type={0}, id={1}, msg={2}", optdata.Type, optdata.DeviceID, encoding.GetString(optdata.Message, 0, optdata.Message.Length)));
- int deviceId = Convert.ToInt16(optdata.DeviceID);
- byte[] message = optdata.Message;
- OnOptRead(this, new OptReadEventArgs(deviceType, deviceId, message));
- }
- }
- DebugLog("OptReadMsg end");
- }
- catch (Exception ex)
- {
- DebugLog("OptReadMsg Exception! " + ex);
- }
- }
- protected override void DoDispose()
- {
- _heartbeat.Dispose();
- }
- }
- }
|